Hi,
I have made a script to automatically login to a site using Firefox. The script first opens the firefox's "options" form, sets "no proxy" in it, opens a new tab and then login to the site.
Sometimes, due to computer slowness or some other reason, the script does not work correctly. The "options" form does not open within the defined time and the script goes haywire.
In this scenerio, is there any way by which I can terminate the script by pressing a key, eg Esc.
My relevant portion of the script is given below. I tried using "loop" command but it didn't work.
Any help in this regard will be highly appreciated.
; Set "No Proxy" in Firefox and login
#IfWinActive ahk_class MozillaWindowClass
F9::
#IfWinActive ahk_class MozillaWindowClass
;WinActivate
sleep 5000
Send !to ;This opens the "options" form in FF.
Sleep 10000
/*Loop
{
Sleep, 100
GetKeyState, state, Escape, T
if state = D ; The Escape key has been pressed, so break out of the loop.
Exit
else
Continue
}
*/
Click 220,13
Sleep 4000
Click 418,155
Sleep 4000
Click 124,66
Sleep 4000
Send {Enter}
Sleep 4000
Click 278,472
Sleep 5000
Send ^t ; This opens new tab in FF.
Sleep 5000
.
.
.
.
.
Thanks and Best Regards,
Sanjay
How to stop a running script using a key press, eg escape
Started by
sanjay
, May 01 2012 07:36 AM
6 replies to this topic
#1
Posted 01 May 2012 - 07:36 AM
#2
Posted 01 May 2012 - 07:43 AM
Hi sanjay, welcome to the forum
When posting a script, please post your script within [code] [/code] tags
In fact, since you posted as a registered user, please edit your post and add the tags.
The answer to your question is yes. Please read the helpfile docs for this command
ExitApp -- Terminates the script unconditionally.
When posting a script, please post your script within [code] [/code] tags
In fact, since you posted as a registered user, please edit your post and add the tags.
The answer to your question is yes. Please read the helpfile docs for this command
ExitApp -- Terminates the script unconditionally.
#3
Posted 07 May 2012 - 02:58 AM
This is my function to effectively abort a script, but it actually reloads it.
^#!ESC::ReloadScript()
ReloadScript() {
Run %A_AhkPath% "%A_ScriptFullPath%"
ExitApp
}
#4
Posted 07 May 2012 - 03:38 AM
It might be easier to use a Firefox Add-on
<!-- m -->https://addons.mozil... ... rm=windows<!-- m -->
For example Quickproxy creates a statusbar button to turn the proxy on and off with a single click.
<!-- m -->https://addons.mozil... ... rm=windows<!-- m -->
For example Quickproxy creates a statusbar button to turn the proxy on and off with a single click.
#5
Posted 07 May 2012 - 04:11 AM
You can also try reloading the script or pausing it.
^r::reload
^p::pause
^r::reload
^p::pause
#6
Posted 07 May 2012 - 01:46 PM
Here is what I have in mine:
This code is up towards the top of your script
I have this at the bottom
I GoTo EarlyTerm during the script also for any time I want the script to end...
This code is up towards the top of your script
Hotkey, Pause, EarlyTerm ;;;QUICK KILL COMMAND. *HIT Pause KEY ON KEYBOARD AT ANY TIME TO KILL THIS SCRIPT
I have this at the bottom
EarlyTerm: ;;;STEP TO END THE HOTKEY FROM RUNNING ExitApp ;;;ENDS HOTKEY APPLICATION FROM RUNNING, ITS REMOVED FROM TOOL TRAY
I GoTo EarlyTerm during the script also for any time I want the script to end...
#7
JimmyJam
Posted 07 May 2012 - 01:58 PM
... is there any way by which I can terminate the script by pressing a key, eg Esc.
Esc::ExitApp




