Jump to content

ExitLoop via hotkey


 Share

Recommended Posts

thats the script - the plan is to press a key combo, then wait 4.7seconds and press the next. $control is changed from 0 to 1 with a hotkey (and is reset with another.

so far it works that the script will pause at the end. but i want to pause to able to pause it within the key-combo-rotation.

func twister () 
    Do
        Send("+8")
        sleep(4700)
        
        send("+9")
        sleep(4700)
        
        send("+0")
        sleep(4700)

    Until $control = 1
EndFunc

well i tried some things like

if $control = 1 Then
            ExitLoop
        EndIf
        Send("+8")
        sleep(4700)

but all it does is bringing an error.

---

also i have another problem. the hotkeys are f6-f8 and when i activate the cript (f6) it also presses other keys like " T ", no clue why.

thanks for your help, Square.

Link to comment
Share on other sites

thats the script - the plan is to press a key combo, then wait 4.7seconds and press the next. $control is changed from 0 to 1 with a hotkey (and is reset with another.

so far it works that the script will pause at the end. but i want to pause to able to pause it within the key-combo-rotation.

func twister () 
    Do
        Send("+8")
        sleep(4700)
        
        send("+9")
        sleep(4700)
        
        send("+0")
        sleep(4700)

    Until $control = 1
EndFunc

well i tried some things like

if $control = 1 Then
            ExitLoop
        EndIf
        Send("+8")
        sleep(4700)

but all it does is bringing an error.

---

also i have another problem. the hotkeys are f6-f8 and when i activate the cript (f6) it also presses other keys like " T ", no clue why.

thanks for your help, Square.

You need to tell us what error you got or how can we help? I can only guess that you added the exitloop without being inside a loop. You also should make it exit if $control is 1 even if it is in a sleep.

You could have something like this which I haven't tested.

Func twister()
    Local $sequence[3] = ["+8", "+9", "+0"], $is
    Do
        For $is = 0 To 2
            If _WSend($sequence[$is], 4700) Then Return
        Next

    Until $control = 1
EndFunc   ;==>twister

Func _WSend($sS, $iT)
    Local $begin = TimerInit()
    Send($sS)
    While TimerDiff($begin) < $iT
        If $control Then Return 1
        Sleep(5)
    WEnd
    Return $control
EndFunc   ;==>_WSend
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
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
 Share

  • Recently Browsing   0 members

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