Jump to content

Recommended Posts

Posted (edited)

Been dorking around with Autoit for about a week and this language is the first i've ever even attempted to learn and i'm really loving all the cool automation that is possible with this languie. In no, shape, or form am I an expert as you'll see below from my very basic code.

I've made a basic outline of this very basic script I am trying to make and it works flawlessly, only issue is I want this script to run until I press a hotkey. How would I go about making a start and a stop hotkey for a whole script?

WinActivate("Runner")
sleep(250)
MouseClick("left",957,590)
Sleep(5500)
MouseClick("left",951,637)
Sleep(3500)
MouseClick("left",939,585)
sleep(2500)
MouseClick("left",1037,568)
Sleep(6750)
MouseClick("left",1036,572)
Sleep(2000)
MouseClick("left",951,472)
Sleep(3750)
MouseClick("left",927,501)
Sleep(7250)
MouseClick("left",780,584)
Sleep(4000)
 

 

 

 

Edited by Keegaroo
Posted
  On 6/5/2020 at 3:13 PM, Keegaroo said:

WinActivate("Runner")

Expand  

Is this a game ?

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Posted (edited)
  On 6/5/2020 at 3:13 PM, Keegaroo said:

How would I go about making a start and a stop hotkey for a whole script?

Expand  

Here a simulation with MouseMove :

; Press Esc to terminate script, Pause/Break to "pause"
Global $g_bPaused = False

HotKeySet("{PAUSE}", "_TogglePause")
HotKeySet("{ESC}", "_Terminate")
HotKeySet("+!d", "_StartScript") ; Shift-Alt-d

While True
    Sleep(100)
WEnd

Func _TogglePause()
    $g_bPaused = Not $g_bPaused
    While $g_bPaused
        Sleep(100)
        ToolTip('Script is "Paused"', 0, 0)
    WEnd
    ToolTip("")
EndFunc   ;==>_TogglePause

Func _Terminate()
    Exit
EndFunc   ;==>_Terminate

Func _StartScript()
    ToolTip("Script is running > move mouse to 10,100", 0, 0)
    MouseMove(10, 100)
    Sleep(2000)

    ToolTip("move mouse to 200,200", 0, 0)
    MouseMove(200, 200)
    Sleep(2000)

    ToolTip("move mouse to 400,200", 0, 0)
    MouseMove(400, 200)
    Sleep(2000)

    ToolTip("move mouse to 600,300", 0, 0)
    MouseMove(600, 300)
    Sleep(2000)
    ToolTip("", 0, 0)
EndFunc   ;==>_StartScript
  Quote

No, isn't posting automation about gaming not allowed?

Expand  

Automation or script interaction with games or game servers, regardless of the game, is not allowed.

Edited by Musashi

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Posted

@Musashi's script works well because it basically traps the flow of the script at any time, meaning you can pause between actions in a function.

There are some cases where you may need that the script continues and not be stuck in a loop like that, for those cases you can go with something like this:

Global $g_bPaused = 1

HotKeySet("{F2}", "_TogglePause")
HotKeySet("{ESC}", "_Terminate")

While 1
    If $g_bPaused = 0 Then
    ;Stuff
    EndIf
WEnd

Func _TogglePause()
    If $g_bPaused = 0 Then
    $g_bPaused = 1
    ToolTip('Script is "Paused"', 0, 0)
    Else
    $g_bPaused = 0
    ToolTip('Script is "Running"', 0, 0)
    EndIf
    Sleep(1000)
    ToolTip("")
EndFunc   ;==>_TogglePause

Func _Terminate()
    Exit
EndFunc   ;==>_Terminate

It's different in that, the loop keeps going and other things may still work, if you have them in the main loop, but this would not stop in the middle of the action, it would only pause at the end of the actions, i hope i can get the message across, sometimes is difficult to me.

  Reveal hidden contents

IUIAutomation - Topic with framework and examples

Au3Record.exe

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...