keybind for starting script over

Get help with using AutoHotkey and its commands and hotkeys
cleavy
Posts: 2
Joined: 30 Dec 2017, 05:24

keybind for starting script over

30 Dec 2017, 05:29

Hello

I have this AHK script

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#MaxThreadsPerHotkey 2"
e::
    Sleep, 20
    Send, 2		
    Sleep, 20
    Send, {4 Down}
    Sleep, 1150		
    Send, {4 Up}
    Sleep 20
    Send, {3 Down}	
    Sleep, 120		
    Send, {3 Up}
    Send, {4 down}	
    Sleep 250
    Send, {4 up}
    Sleep, 20
    Send, 1		
    Sleep, 20
    Send, {4 down}
    Sleep, 2500	
    Send, {4 up}
I want 'e' to not only start this script, but also interrupt whatever is being excecuted and start over if I press 'e' again at any point.
User avatar
Spawnova
Posts: 339
Joined: 08 Jul 2015, 00:12
Contact:

Re: keybind for starting script over

30 Dec 2017, 07:04

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#MaxThreadsPerHotkey 2
running := false

#if !running ; if 
	e::
	running := true ;running is set to true, e now reloads the script
    Sleep, 20
    Send, 2		
    Sleep, 20
    Send, {4 Down}
    Sleep, 1150		
    Send, {4 Up}
    Sleep 20
    Send, {3 Down}	
    Sleep, 120		
    Send, {3 Up}
    Send, {4 down}	
    Sleep 250
    Send, {4 up}
    Sleep, 20
    Send, 1		
    Sleep, 20
    Send, {4 down}
    Sleep, 2500	
    Send, {4 up}
	running := false ;running set to false, e no longer reloads
	return
#if running
	*e::reload
#if
cleavy
Posts: 2
Joined: 30 Dec 2017, 05:24

Re: keybind for starting script over

30 Dec 2017, 08:00

Spawnova wrote:

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#MaxThreadsPerHotkey 2
running := false

#if !running ; if 
	e::
	running := true ;running is set to true, e now reloads the script
    Sleep, 20
    Send, 2		
    Sleep, 20
    Send, {4 Down}
    Sleep, 1150		
    Send, {4 Up}
    Sleep 20
    Send, {3 Down}	
    Sleep, 120		
    Send, {3 Up}
    Send, {4 down}	
    Sleep 250
    Send, {4 up}
    Sleep, 20
    Send, 1		
    Sleep, 20
    Send, {4 down}
    Sleep, 2500	
    Send, {4 up}
	running := false ;running set to false, e no longer reloads
	return
#if running
	*e::reload
#if
Thanks for fast reply, but re-pressing 'e' while the initial sequence is running does not interrupt the script for me.
If it is possible I would like a keybind to interrupt everything going on and restart script from top, if you need a seperate keybind for this that's ok, but preferably same keybind as initial start of script.

Return to “Ask For Help”

Who is online

Users browsing this forum: AnotherUser, Athyra, Bing [Bot], Sabestian Caine and 47 guests