Sign in to follow this  
Followers 0
Simucal

Script Immediatly Ending

4 posts in this topic

#1 ·  Posted (edited)

Originally I had a script like the following and it worked wonderfully:

Opt("PixelCoordMode", 1); did you set coords up with window coords?  If not, you'll need to change the "0" to 1 or 2 (check help under "Opt" to explain)
Opt("MouseCoordMode", 1); same as above
Opt("SendKeyDelay", 1)
DllOpen("unprotect.dll")

HotKeySet("{F1}", "Pangya")
If Not WinActive("<Albatross18>") Then WinActivate("<Albatross18>")
Dim $Reset = 0
While 1
    Sleep(100)
    While $Reset <> 0
    If PixelGetColor(134, 702) == 0x000000 Then; replace 0x000000 with the actual colour using AutoInfo Tool
        Send("{SPACE}")
      ;Sleep(10); if it takes a long time, you might consider a sleep
        $Reset = 0
    EndIf
    WEnd
WEnd

Func Pangya()
    If $Reset = 0 Then
        $Reset = 1
        Return $Reset
    Else
        $Reset = 0
        Return $Reset
    EndIf
EndFunc

I then wanted to add another Hotkey and another function. I changed the script to:

Opt("PixelCoordMode", 1); did you set coords up with window coords?  If not, you'll need to change the "0" to 1 or 2 (check help under "Opt" to explain)
Opt("MouseCoordMode", 1); same as above
Opt("SendKeyDelay", 1)
DllOpen("unprotect.dll")

HotKeySet("{F1}", "Pangya")
HotKeySet("{F2}", "Pangya_Max")

;If Not WinActive("<Albatross18>") Then WinActivate("<Albatross18>")
Dim $Reset = 0

Func Pangya()
$Reset = 1
While 1
    MouseClick("left", 123, 729, 0)
    Sleep(1000)
    While $Reset <> 0
    If PixelGetColor(138, 702) == 0x000000 Then
        MouseClick("left", 123, 729, 0)
      ;MsgBox(4096, "Color Detection", "Black Detected at 138, 702")
        $Reset = 0
    EndIf
    WEnd
WEnd
EndFunc

Func Pangya_Max()
$Reset = 1
While 1
    MouseClick("left", 123, 729, 0)
    Sleep(500)
    While $Reset <> 0
    If PixelGetColor(501, 702) == 0x000000 Then
        MouseClick("left", 123, 729, 0)
        $Reset = 0
    EndIf
    WEnd
WEnd
$Reset = 1
While 1
    MouseClick("left", 123, 729, 0)
    Sleep(500)
    While $Reset <> 0
    If PixelGetColor(138, 702) == 0x000000 Then
        MouseClick("left", 123, 729, 0)
      ;MsgBox(4096, "Color Detection", "Black Detected at 138, 702")
        $Reset = 0
    EndIf
    WEnd
WEnd
EndFunc

Is the reason it is immediately ending because it isnt in Continuous while loop anymore until you hit a Hotkey? Should I put it in a loop to keep it continually running? Any advice, tips, etc are appreciated.

Edited by Simucal

AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Yes, that is the reason. Consider how it works (from the script's point of view)

Here's the hotkeys...

Here are the functions (but I haven't been asked to do anything in them yet)

All Done

I would add a while loop right after the hotkeys and make sure there is a Hotkey/function that terminates the script.

Opt("PixelCoordMode", 1); did you set coords up with window coords?  If not, you'll need to change the "0" to 1 or 2 (check help under "Opt" to explain)
Opt("MouseCoordMode", 1); same as above
Opt("SendKeyDelay", 1)
DllOpen("unprotect.dll")

HotKeySet("{F1}", "Pangya")
HotKeySet("{F2}", "Pangya_Max")
HotKeySet("{ESC}","Terminate")

;If Not WinActive("<Albatross18>") Then WinActivate("<Albatross18>")
Dim $Reset = 0

While 1
     Sleep(100)
Wend

Func Terminate()
     Exit
EndFunc

Func Pangya()
$Reset = 1
While 1
    MouseClick("left", 123, 729, 0)
    Sleep(1000)
    While $Reset <> 0
    If PixelGetColor(138, 702) == 0x000000 Then
        MouseClick("left", 123, 729, 0)
    ;MsgBox(4096, "Color Detection", "Black Detected at 138, 702")
        $Reset = 0
    EndIf
    WEnd
WEnd
EndFunc

Func Pangya_Max()
$Reset = 1
While 1
    MouseClick("left", 123, 729, 0)
    Sleep(500)
    While $Reset <> 0
    If PixelGetColor(501, 702) == 0x000000 Then
        MouseClick("left", 123, 729, 0)
        $Reset = 0
    EndIf
    WEnd
WEnd
$Reset = 1
While 1
    MouseClick("left", 123, 729, 0)
    Sleep(500)
    While $Reset <> 0
    If PixelGetColor(138, 702) == 0x000000 Then
        MouseClick("left", 123, 729, 0)
    ;MsgBox(4096, "Color Detection", "Black Detected at 138, 702")
        $Reset = 0
    EndIf
    WEnd
WEnd
EndFunc
Edited by SpookMeister

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Share this post


Link to post
Share on other sites

Thanks spookmeister, that was exactly what i was looking for!

One more question I have is....

Has anyone ever had the problem of only being able to send one type of input per function in Autoit?

For example:

Func Pangya_Max()
$Reset = 1
Send("{Space}")
While 1
    Sleep(500)
    While $Reset <> 0
    If PixelGetColor(501, 702) == 0x000000 Then
        MouseClick("left")
        $Reset = 0
    EndIf
    WEnd
WEnd
$Reset = 1
While 1
    While $Reset <> 0
    If PixelGetColor(138, 702) == 0x000000 Then
        MouseClick("left")
       ;MsgBox(4096, "Color Detection", "Black Detected at 138, 702")
        $Reset = 0
    EndIf
    WEnd
WEnd
EndFunc

The second mouse click doesnt work. However, if I split this function up into two like so:

Func Pangya_Max()
$Reset = 1
Send("{Space}")
While 1
    Sleep(500)
    While $Reset <> 0
    If PixelGetColor(501, 702) == 0x000000 Then
        MouseClick("left")
        $Reset = 0
        Pangya_Max2()
    EndIf
    WEnd
WEnd
EndFunc

Func Pangya_Max2()
$Reset = 1
While 1
    While $Reset <> 0
    If PixelGetColor(138, 702) == 0x000000 Then
        MouseClick("left")
       ;MsgBox(4096, "Color Detection", "Black Detected at 138, 702")
        $Reset = 0
    EndIf
    WEnd
WEnd
EndFunc

Now, both mouse clicks get processed correctly. Same goes for sending the SPACE key, only the first one gets registered unless I split into 2 functions. I thought it might be the program I am automating doing this.. but why would splitting into 2 functions fix the problem if it was on my end?


AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)

Share this post


Link to post
Share on other sites

Because your not telling it to exit the loop, your saying while 1 which is saying while there is no error., you could nest the other while inside that one.

$Reset == 1
Send("{Space}")
While WinExists("Game Title From AutoInfo")
    Sleep(500)
    While $Reset == 1
    If PixelGetColor(501, 702) == 0x000000 Then
        MouseClick("left")
        $Reset == 2
    EndIf
    WEnd
    While $Reset == 2
    If PixelGetColor(138, 702) == 0x000000 Then
        MouseClick("left")
      ;MsgBox(4096, "Color Detection", "Black Detected at 138, 702")
        $Reset == 0
    EndIf
    WEnd
WEnd

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0