ImageSearch im Spiel!?

Stelle Fragen zur Automatisierung von Spielen

Moderator: jNizM

Achirty
Posts: 4
Joined: 30 Mar 2019, 20:02

ImageSearch im Spiel!?

02 Apr 2019, 21:33

Moin zusammen,
Ich hab ein kleines Script geschrieben was ein Item im Spiel sucht, wenn dieses kommt geht die Maus dorthin und schiebt es in mein Inventar, das funktioniert soweit alles ganz gut bloß wenn ich das Script im Spiel Testen möchte funktioniert es nicht... es geht nur z.b. in paint oder auf dem Desktop.

Code: Select all

#IfWinActive, Spiel
#SingleInstance, Force
#Persistent
#UseHook, On

F17::
CoordMode, Pixel, Screen
ImageSearch, XPos, YPos, 0, 0, 1920, 1080, C:\Users\t\Desktop\bkrtext.PNG

if ErrorLevel = 2
    MsgBox  The search could not be performed.
else if ErrorLevel = 1
    MsgBox Icon could not be found on the screen.
else  
    MsgBox The symbol was found at %XPos%x%YPos%
    MouseClickDrag, L, %Pos%, %YPos%, 193, 384
nacken012
Posts: 90
Joined: 22 Jul 2016, 14:39

Re: ImageSearch im Spiel!?

03 Apr 2019, 00:53

Hallo, versuche es mal mit einer tolle ranz

Code: Select all

#IfWinActive, Spiel
#SingleInstance, Force
#Persistent
#UseHook, On

F17::
CoordMode, Pixel, Screen
ImageSearch, XPos, YPos, 0, 0, 1920, 1080, *30 C:\Users\t\Desktop\bkrtext.PNG ; hier die *30 einfügen

if ErrorLevel = 2
    MsgBox  The search could not be performed.
else if ErrorLevel = 1
    MsgBox Icon could not be found on the screen.
else  
    MsgBox The symbol was found at %XPos%x%YPos%
    MouseClickDrag, L, %Pos%, %YPos%, 193, 384
gregster
Posts: 9035
Joined: 30 Sep 2013, 06:48

Re: ImageSearch im Spiel!?

03 Apr 2019, 07:59

Es bliebe noch zu ergänzen, dass die Einrückung von MouseClickDrag, L, %Pos%, %YPos%, 193, 384 nicht alleine dazu führt, dass es zum else-Zweig gehört. In deinem Skript wird diese Zeile immer ausgeführt, egal welchen Wert ErrorLevel hat.

Die erste Zeile nach If, else, while etc. wird immer abhängig ausgeführt - bei mehr als einer abhängigen Zeile, musst du { }-Blocks zum Gruppieren verwenden:

Code: Select all

else
{  
    MsgBox The symbol was found at %XPos%x%YPos%
    MouseClickDrag, L, %Pos%, %YPos%, 193, 384
}

Return to “Spiele”

Who is online

Users browsing this forum: No registered users and 35 guests