Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Once a script has been started, is there a way to stop it?


  • Please log in to reply
22 replies to this topic
deadlydog
  • Members
  • 19 posts
  • Last active: Jul 03 2016 04:13 PM
  • Joined: 09 Dec 2011

Hmmmm, Esc::ExitApp doesn't seem to work when my code is in the middle of a loop.  For example, if I am executing this loop:

Loop, 100
{
    Send, {Space}{Tab 3}
}

nothing happens when I hit Escape until the loop has finished; then the script exits.  I want a way to kill a script, even if it's in the middle of executing some code.  Is that possible?

 

Thanks in advance



robert_ilbrink
  • Members
  • 561 posts
  • Last active: Mar 10 2015 08:36 PM
  • Joined: 05 May 2012

Try adding a Sleep, 1 inside your loop. This will give the loop enough time to trigger on the Esc.

And if you want to "regain" some of the lost time, use SendInput instead of Send.



Nicholas
  • Members
  • 15 posts
  • Last active: Oct 21 2014 02:57 PM
  • Joined: 17 Jan 2014

Here is my script:

 

F4::
Loop, 10
{
ControlClick, x529 y230, Chrome
Sleep 100
Send ^{Tab}
Sleep 100
}
F9::ExitApp
Return
 
I'd like to be able to use F9 to stop the script and reset it. With the current code, F9 just quits the script completely and I have to click "run script" again. I use this script about 60 times/day and I'd like F9 to just stop and reset the script, not quit it. Any ideas?


Oldman
  • Members
  • 2475 posts
  • Last active: Feb 18 2015 04:57 PM
  • Joined: 01 Dec 2013

F9::Reload


Si ton labeur est dur et que tes résultats sont minces, souviens toi du grand chêne qui avant n'était qu'un gland....comme toi ! (anonyme) ;)

L'art de lire, c'est l'art de penser avec un peu d'aide. (É. Faguet)

Windows 3.1. Collector's Edition.     (www.avaaz.org)


Nicholas
  • Members
  • 15 posts
  • Last active: Oct 21 2014 02:57 PM
  • Joined: 17 Jan 2014

Badass. Thank you so much.



Cedobeard
  • Members
  • 3 posts
  • Last active: Nov 24 2014 04:37 PM
  • Joined: 05 Nov 2014

Hey all! This is my first post on the forums.
The quoted line below doesn't seem to work for me in any of my 9 scripts.

Here is a shortened version of my code... I don't see an option to make a box for it like everyone else does, so it's in bold/italic.

 

#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.
 
^+7::Soundbeep
; more stuff runs here for about 20 seconds with plenty of sleep 2000, sleep 500, etc.
send 4
send {f7}
Soundbeep
 
esc::soundbeep
reload

 

So when I hit escape, I hear a beep, but the script just runs on to completion. How do you make it work?

 

F9::Reload

 



Leef_me
  • Moderators
  • 8510 posts
  • Last active: Sep 10 2015 05:50 AM
  • Joined: 08 Apr 2009

You need to start your education by >working< through the tutorial

http://www.autohotke...cs/Tutorial.htm

 

In the interest of answerin your immediate question, I direct you to the section "Launching a program or document"

http://www.autohotke...rial.htm#Launch

 

If you don't understand how that section applies, search for the word 'single' in that section.



Cedobeard
  • Members
  • 3 posts
  • Last active: Nov 24 2014 04:37 PM
  • Joined: 05 Nov 2014

You need to start your education by >working< through the tutorial

http://www.autohotke...cs/Tutorial.htm

 

In the interest of answerin your immediate question, I direct you to the section "Launching a program or document"

http://www.autohotke...rial.htm#Launch

 

If you don't understand how that section applies, search for the word 'single' in that section.

Thanks. It is indeed work! Much of it doesn't make sense to me but I have to believe I'll get good at this eventually.
I found out, the reason it was working inconsistently was partly due to what you said above.

I say partly, because of the real problem. I was writing all my hotkeys in 8 different scripts and running them all individually. Some I wrote correctly, others tried to break the first/single line rule and failed.

With multiple scripts, though, the ESC key tries to reload all of them but only succeeds in reloading one or two, so it seems, and randomly?

 

Nonetheless, my scripts have since been combined so ESC now reloads everything in one stroke with esc::reload