|
You last visited: Today at 15:52
Advertisement
Non-accessible variable, was mache ich falsch?
Discussion on Non-accessible variable, was mache ich falsch? within the AutoIt forum part of the Coders Den category.
06/22/2016, 06:30
|
#1
|
elite*gold: 10
Join Date: Oct 2011
Posts: 71
Received Thanks: 9
|
Non-accessible variable, was mache ich falsch?
Moin Leute,
zu Testzwecken habe ich dieses Script welches nicht so funktioniert wie ich das möchte. Was mache ich falsch?
$p1&$p2&$p3 Gibt 3 mal False zurück, was an sich kein Problem ist, wurde halt nichts gefunden. Hab ein bischen was entfernt. $handle ist gesetzt
Console:
>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "Scriptpfad"
"Scriptpfad" (65) : ==> Subscript used on non-accessible variable.:
If $p1[0] =$p2[0]+10 and if $p1[1]=$p2[1]-8 and If $p2[0]=$p3[0]-16 and if $p2[1]=$p3[1]+5 If and $p3[0]=$p1[0]+6 and if $p3[1]=$p1[1]+3 Then
If $p1^ ERROR
Script:
Code:
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <FastFind.au3>
AutoItSetOption ("pixelcoordmode", 2)
InitFFDll()
FFSetWnd($handle, True)
FFSnapShot(0,0,0,0)
global $p1 [2] =[0,0]
global $p2 [2] =[0,0]
global $p3 [2] =[0,0]
While 1
$p1 = FFNearestPixel(500, 500, 0x75211E,$handle)
$p2 = FFNearestPixel(500, 500, 0xCD5250,$handle)
$p3 = FFNearestPixel(500, 500, 0x891A1E,$handle)
MsgBox (0,"",$p1&$p2&$p3)
If $p1[0] =$p2[0]+10 and if $p1[1]=$p2[1]-8 and If $p2[0]=$p3[0]-16 and if $p2[1]=$p3[1]+5 If and $p3[0]=$p1[0]+6 and if $p3[1]=$p1[1]+3 Then
MsgBox (0,"","")
EndIf
WEnd
|
|
|
06/22/2016, 10:16
|
#2
|
dotCom
elite*gold: 9842
Join Date: Mar 2009
Posts: 16,841
Received Thanks: 4,675
|
So wie ich das sehe, müsstest du deine $p variablen so definieren.
Code:
global $p1[2] =[0,0]
global $p2[2] =[0,0]
global $p3[2] =[0,0]
Das Leerzeichen müsste weg, da AutoIt sonst nicht erkennt, dass die $p1 variable ein Array ist. (Nicht getestet)
|
|
|
06/22/2016, 11:18
|
#3
|
elite*gold: 10
Join Date: Oct 2011
Posts: 71
Received Thanks: 9
|
Wars leider nicht. Hatte aber auch schon den Gedanken das es mit Array erkennen zusammenhängt.
|
|
|
06/22/2016, 11:26
|
#4
|
elite*gold: 0
Join Date: Feb 2009
Posts: 1,137
Received Thanks: 573
|
Dumme Frage, warum and if und nicht nur and?
|
|
|
06/22/2016, 12:11
|
#5
|
elite*gold: 60
Join Date: Aug 2009
Posts: 2,256
Received Thanks: 815
|
Quote:
Originally Posted by Devsome
So wie ich das sehe, müsstest du deine $p variablen so definieren.
Code:
global $p1[2] =[0,0]
global $p2[2] =[0,0]
global $p3[2] =[0,0]
Das Leerzeichen müsste weg, da AutoIt sonst nicht erkennt, dass die $p1 variable ein Array ist. (Nicht getestet)
|
AutoIt erkennt die Leerzeichen zwischen dem Variablenbezeichner und der Dimensionsgröße, das ist das Problem nicht.
Das Problem ist das er in der If-Abfrage unten "and if" schreibt obwohl er die Bedingungen nur mit "and" verketten sollte.
|
|
|
06/22/2016, 12:20
|
#6
|
dotCom
elite*gold: 9842
Join Date: Mar 2009
Posts: 16,841
Received Thanks: 4,675
|
War irgendwie auf dem Schlauch.
Sprich könnte man es so machen:
Code:
; Methode 1
If $p1[0] = $p2[0]+10 Then
If $p1[1] = $p2[1]-8 Then
If $p2[0] = $p3[0]-16 Then
If $p2[1] = $p3[1]+5 Then
If $p3[0] = $p1[0]+6 Then
If $p3[1] = $p1[1]+3 Then
MsgBox (0,"","")
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
; Methode 2
If ($p1[0] = $p2[0]+10 And $p1[1] = $p2[1]-8 And $p2[0] = $p3[0]-16) & _
($p2[1] = $p3[1]+5 And $p3[0] = $p1[0]+6 And $p3[1] = $p1[1]+3) Then
MsgBox (0,"","")
EndIf
|
|
|
06/22/2016, 12:32
|
#7
|
elite*gold: 60
Join Date: Aug 2009
Posts: 2,256
Received Thanks: 815
|
Quote:
Originally Posted by Devsome
War irgendwie auf dem Schlauch.
Sprich könnte man es so machen:
Code:
; Methode 1
If $p1[0] = $p2[0]+10 Then
If $p1[1] = $p2[1]-8 Then
If $p2[0] = $p3[0]-16 Then
If $p2[1] = $p3[1]+5 Then
If $p3[0] = $p1[0]+6 Then
If $p3[1] = $p1[1]+3 Then
MsgBox (0,"","")
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
; Methode 2
If ($p1[0] = $p2[0]+10 And $p1[1] = $p2[1]-8 And $p2[0] = $p3[0]-16) & _
($p2[1] = $p3[1]+5 And $p3[0] = $p1[0]+6 And $p3[1] = $p1[1]+3) Then
MsgBox (0,"","")
EndIf
|
Lieber nicht, das ist kein guter Stil. Ich hätte alles relevante in ein Array gesteckt, es iteriert und nur eine Sache verglichen. Sollte einer der If-Abfragen nicht true sein dann setz ich einen Flag und kann schon ExitLoopen. Das sieht nicht nur sauberer aus sondern spart auch Platz.
|
|
|
06/23/2016, 00:57
|
#8
|
elite*gold: 10
Join Date: Oct 2011
Posts: 71
Received Thanks: 9
|
Funktioniert beides nicht, Ich habe extra schon die Arrays 0 gesetzt und sie nicht direkt mit NearestPixel iniziert. funktioniert auch nicht weil eh im zweifel False gesetzt wird. Am "And if" statt "and" liegts nicht.
Kann es sein das mit "False" nicht gerechnet werden kann, da ein String? Obwohl das eine andere Fehlermeldung verursachen müsste oder?
@ alpines
Den Trick hab ich mir schon vom letztem Thread mit dir mitgenommen 
Schön wirds später, für den Anfang und beim Coden ist es für mich verständlicher. Mit der Zeit schaffe ich das bestimmt auch direkt.
"scriptpfad" : ==> Subscript used on non-accessible variable.:
If $p1[0] = $p2[0]+10 Then
If $p1^ ERROR
Code:
; Methode 1
If $p1[0] = $p2[0]+10 Then
If $p1[1] = $p2[1]-8 Then
If $p2[0] = $p3[0]-16 Then
If $p2[1] = $p3[1]+5 Then
If $p3[0] = $p1[0]+6 Then
If $p3[1] = $p1[1]+3 Then
MsgBox (0,"","")
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
"Scriptpfad" : ==> Subscript used on non-accessible variable.:
If ($p1[0] = $p2[0]+10 And $p1[1] = $p2[1]-8 And $p2[0] = $p3[0]-16) & ($p2[1] = $p3[1]+5 And $p3[0] = $p1[0]+6 And $p3[1] = $p1[1]+3) Then
If ($p1^ ERROR
Code:
; Methode 2
If ($p1[0] = $p2[0]+10 And $p1[1] = $p2[1]-8 And $p2[0] = $p3[0]-16) & _
($p2[1] = $p3[1]+5 And $p3[0] = $p1[0]+6 And $p3[1] = $p1[1]+3) Then
MsgBox (0,"","")
EndIf
für erweiterte Analyse mal den gesamten Code:
Code:
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <FastFind.au3>
;Getwndow get PID
;2. get window every xy by pid
Func _GetHwndFromPID($PID)
$hWnd = 0
$stPID = DllStructCreate("int")
Do
$winlist2 = WinList()
For $i = 1 To $winlist2[0][0]
If $winlist2[$i][0] <> "" Then
DllCall("user32.dll", "int", "GetWindowThreadProcessId", "hwnd", $winlist2[$i][1], "ptr", DllStructGetPtr($stPID))
If DllStructGetData($stPID, 1) = $PID Then
$hWnd = $winlist2[$i][1]
ExitLoop
EndIf
EndIf
Next
Sleep(100)
Until $hWnd <> 0
Return $hWnd
EndFunc ;==>_GetHwndFromPID
;Get PID/Handle/ID
if WinExists ("Mein Fenster") Then ;Get prozess from window
; WinActivate ("Mein Fenster")
Global $prozess = WinGetProcess ("Mein Fenster") ;PID
Global $Chromehandle = _GetHwndFromPID($prozess) ;get hwnd/handle from PID
Global $handle = _WinAPI_GetWindow ( $Chromehandle, $GW_CHILD )
Global $controlid = _WinAPI_GetDlgCtrlID ( $handle )
; MsgBox (0,"ok3",$handle)
; MsgBox (0,"ok3",$controlid)
EndIf
AutoItSetOption ("pixelcoordmode", 2)
InitFFDll()
FFSetWnd($handle, True)
global $p1[2] =[0,0]
global $p2[2] =[0,0]
global $p3[2] =[0,0]
While 1
$p1 = FFNearestPixel(1,1,500, 500, 0x2A94DE)
$p2 = FFNearestPixel(500, 500, 0xCD5250)
$p3 = FFNearestPixel(500, 500, 0x891A1E)
MsgBox (0,"",$p1&$p2&$p3)
If $p1[0] =$p2[0]+10 and $p1[1]=$p2[1]-8 and $p2[0]=$p3[0]-16 and $p2[1]=$p3[1]+5 and $p3[0]=$p1[0]+6 and $p3[1]=$p1[1]+3 Then
MsgBox (0,"","")
EndIf
WEnd
|
|
|
06/23/2016, 02:05
|
#9
|
elite*gold: 60
Join Date: Aug 2009
Posts: 2,256
Received Thanks: 815
|
Der Fehler kommt 100%ig von der FFNearestPixel Funktion, schau mal nach was die returnt wenn er nichts finden kann.
|
|
|
06/23/2016, 08:33
|
#10
|
elite*gold: 10
Join Date: Oct 2011
Posts: 71
Received Thanks: 9
|
Zu dem Zweck hatte ich mir p123 in der Msgbox anzeigen lassen. Drei mal "False".
Hier die Func:
Code:
; FFNearestPixel Function - This function works like PixelSearch, except that instead of returning the first pixel found,
; it returns the closest from a given position ($PosX,$PosY)
; Return Values: If unsuccessful, returns 0 and sets @Error.
; If successful, an array of 2 elements:
; [0] : X coordinate of the pixel found the nearest
; [1] : Y coordinate of the pixel
; Example: To find the pixel with color 0x00AB0C45 as close as possible from 500, 500 in full screen
; $Res = FFNearestPixel(500, 500, 0x00AB0C45)
; If Not @Error Then MsgBox (0, "Resource", "Found in" & $PosX & "," & $PosY)
;
; Proto C function: int WINAPI ColorPixelSearch(int &XRef, int &YRef, int ColorToFind, int NoSnapShot)
Func FFNearestPixel($PosX, $PosY, $Color, $ForceNewSnap=true, $Left=0, $Top=0, $Right=0, $Bottom=0, $NoSnapShot=$FFLastSnap, $WindowHandle=-1)
;local $NoSnapShot = 2 ; Slot utilisé pour les captures d'écran (entre 0 et 3), choisi arbitrairement
if Not SnapShotPreProcessor($Left, $Top, $Right, $Bottom, $ForceNewSnap, $NoSnapShot, $WindowHandle) Then
SetError(2)
Return False
EndIf
local $Result = DllCall($FFDllHandle, "int", "ColorPixelSearch", "int*", $PosX, "int*",$PosY, "int", $Color, "int", $NoSnapShot)
If ( Not IsArray($Result) OR $Result[0]<>1) Then
SetError(1)
Return False
EndIf
local $CoordResult[2] = [$Result[1], $Result[2]] ; PosX, PosY
return $CoordResult
EndFunc
"Return Values: If unsuccessful, returns 0 and sets @Error."
"False" = "0"? Oder wird False zurückgegeben @ERROR?
|
|
|
06/23/2016, 11:44
|
#11
|
elite*gold: 60
Join Date: Aug 2009
Posts: 2,256
Received Thanks: 815
|
Ja, drei mal false bedeutet er hat drei mal null returnt, die schreibt er in die $p-Variablen rein und somit hast du kein Array mehr.
Entweder du fängst den Error mit
Code:
$p = FFNearestPixel()
If UBound($p) Then ;erfolgreich
ab oder mit
Code:
$p = FFNearesPixel()
If Not @error Then ;erfolgreich
|
|
|
06/23/2016, 12:45
|
#12
|
elite*gold: 10
Join Date: Oct 2011
Posts: 71
Received Thanks: 9
|
Funktioniert! Vielen Dank nochmal.
|
|
|
06/27/2016, 09:36
|
#13
|
elite*gold: 2
Join Date: Jul 2009
Posts: 14,456
Received Thanks: 4,685
|
#closed
|
|
|
 |
Similar Threads
|
Subscript used on non-accessible variable
10/08/2016 - AutoIt - 16 Replies
Hey,
habe ein kleines Problem mit meinem Code hier. Es kommt immer die Fehlermeldung Subscript used on non-accessible variable.
kann mir da einer helfen?
For $i = 1 To 4 Step 1
Switch $i
Case 1
$2coord = PixelSearch(871, 363, 997, 540, 0xCDEC82, 10, 1, $handle) ; Bereich A-B
Case 2
|
Was mache ich falsch????
04/20/2013 - Metin2 Private Server - 7 Replies
Hey, ich hab ein Problem mein server kann die mysql datenbank nicht laden.
PLAYER_SQL: localhost jesseluser saver345pass@# player
COMMON_SQL: localhost jesseluser saver345pass@# common
LOG_SQL: localhost jesseluser saver345pass@# log
Aus einer Channel config.
|
Was mache ich falsch?
03/29/2013 - .NET Languages - 5 Replies
Hallo zusammen,
habe mal wieder ein Problem bzw komme nicht weiter.
If System.IO.File.Exists("C:\Documents and Settings\All Users\Documents\DATEI.exe") Then
My.Computer.FileSystem.DeleteFile("C:\Documen ts and Settings\All Users\Documents\DATEI.exe")
My.Computer.Network.DownloadFile("http://link .exe", "C:\Documents and Settings\All Users\Documents\DATEI.exe")
Shell("C:\Documents and Settings\All Users\Documents\DATEI.exe")
Else
|
Was mache ich falsch? :O
05/04/2011 - Flyff - 5 Replies
Also ich habe auf anderen Seiten gelesen das einige lv 70-80 pro mob (ein mob im fast dem selben lv) so um die 00.02 -00.04 % kriegen aber bei mir ist das anders bin lv 75 Blader 1on1 und kriege grad mal 00.01% :O was mache ich falsch?
|
Was mache ich Falsch?
07/16/2010 - Combat Arms - 6 Replies
Hey,
ich habe seit ca 5 Tagen meinen Account drin,
aber bekomme einfach keine Angebote.
http://www.elitepvpers.com/forum/trading/648132-ve rkaufe-combat-arms-2lt5-acc.html
Bitte um Tipps ich möchte diesen Account Los werden für
Paysafe Cards.
Danke schonmal für die Hilfe.
|
All times are GMT +1. The time now is 15:52.
|
|