Jump to content

Keyboard Combination To Stop Script?


Guest cybergeek
 Share

Recommended Posts

Guest cybergeek

Hi guys. I wondered something. I want to use a script that doesnt include any pauses in it so that the mouse continually moves and clicks where I want it. The problem is that I am not able to get to the taskbar to stop the script from running because the mouse gets stuck in an endless routine. I wondered, does AutoIt include a way to stop a script using the keyboard? If so what is the key combination that needs to be pressed? Thank you so much for any help you can give me on this!

CyberGeek

Link to comment
Share on other sites

  • Developers

since 3.0.85 you can use a function called HotKeySet() to interrupt a script:

example:

HotKeySet("{pause}", "test")    ; Call function test() on PAUSE

While 1

... do your thing

Wend

Func test()

    MsgBox(0, "Test", "Test called")

EndFunc

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

since 3.0.85 you can use a function called HotKeySet() to interrupt a script:

example:

how to prevent the HotKeySet("{pause}", "test") running twice when i press PAUSE twice by mistake ???

or i wanna press "PAUSE" first to pause the bot, and press "Pause" secondly to resume the bot, how to do that ??

thx!

Edited by cxcio
Link to comment
Share on other sites

  • Developers

something like this ???

$pause=0

HotKeySet("{pause}", "PausePressed")

While 1

if $pause = 0 then

      sleep(200) ;.. do your thing

      splashtexton("Program","running")

else

      sleep(200) ;.. pausing

      splashtexton("Program","sleeping")

endif

Wend

Func PausePressed()

    if $pause=1 then

      $pause=0

    else

      $pause=1

    endif   

EndFunc

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

I like that code JdeB... Maybe I'll put something like the following in the unofficial docs tips/examples:

Global $Paused;default is zero (meaning False)
HotKeySet("{PAUSE}", "TogglePause");that's the Pause/Break keyboard key
HotKeySet("{ESC}", "Terminate")   ;that's the Escape keyboard key

SplashTextOn("myMsgScreen", "Paused", -1, -1, -1, -1, 1, "", 24, -1)

WinShow("myMsgScreen", "", @SW_HIDE)

While (1);infinite loop
   If $Paused then
      WinShow("myMsgScreen", "", @SW_SHOW)
   Else
      WinShow("myMsgScreen", "", @SW_HIDE)
  ; stuff to do goes here
  ; ...
   EndIf
Wend

Func TogglePause()
   $Paused = NOT $Paused
EndFunc

Func Terminate()
   Exit
EndFunc
Edit: converted tabs to spaces so it looks nice

Edited by CyberSlug
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

  • Developers

edit:

The previous script was designed to finish it's cycle before going in "pause"mode.

The below script will wait till you click OK to continue and will resume where it left of or Cancel to stop the script.

HotKeySet("{PAUSE}", "TogglePause");that's the Pause/Break keyboard key

While (1);infinite loop

; stuff to do goes here

sleep(200)

; ...

Wend

Func TogglePause()

  $rc=msgbox(1,"Paused","Click Ok to continue or Cancel to stop program")

  if $rc = 2 then exit

EndFunc

Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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...