Jump to content

Need Help. Pausing


Recommended Posts

Ok, so i have a script like this:

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

and so on, and i have the Hotkeys in there to pause it..but it will not allow me to pause in the middle of those. I am making an script to continually press z for a game, but i want F6 to pause it. It pauses at any other time after the pressing of Z's and before, but they main function is to press Z, and i need to be able to pause it.

Any help will be greatly appreciated.

Link to comment
Share on other sites

straight from beta help

; Press Esc to terminate script, Pause/Break to "pause"

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage") ;Shift-Alt-d

;;;; Body of program would go here;;;;
While 1
    Sleep(100)
WEnd
;;;;;;;;

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

Func ShowMessage()
    MsgBox(4096,"","This is a message.")
EndFunc

this should do the trick

8)

NEWHeader1.png

Link to comment
Share on other sites

  • Moderators

@LiquidWarlock

Can you be more explicit on this:

but it will not allow me to pause in the middle of those

Like what exactly your trying to accomplish?

@Valuater

That's in the regular version of AutoIt too

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

@LiquidWarlock

Can you be more explicit on this:

Like what exactly your trying to accomplish?

@Valuater

That's in the regular version of AutoIt too

<{POST_SNAPBACK}>

Well yeah i have all of what he said in my script, but i want to be able to pause the script at any given time inbetween those Z's. like i cannot randomly press F6 (my pause button) to pause the script, although if its before or after the Z's it pauses fine
Link to comment
Share on other sites

maybe i could post my script, or tell what i want it to do and someone can write me one to show me what i am trying to do.. it is a very small script so shouldnt be bad.

Because even though you guys are giving me a lot of help, im not exactly sure what to do with the help given

Edited by LiquidWarlock
Link to comment
Share on other sites

  • Moderators

If you post your code, maybe we can assist you more. I'm going to read this post for the 3rd time to see if I can decipher it, but your code would speed things up tremendously.

Right now it's like reading between the lines (that's like staring at the middle finger) :evil::)

Edited by ronsrules

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Hmm here it is:

Woops..

Global $Paused

HotKeySet("{PAUSE}", "TogglePause")

HotKeySet("{ESC}", "Terminate")

HotKeySet("+!d", "ShowMessage") ;Shift-Alt-d

Run ("notepad.exe")

Sleep (2000)

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

Send("Z")

;;;; Body of program would go here;;;;

While 1

Sleep(100)

WEnd

;;;;;;;;

Func TogglePause()

$Paused = NOT $Paused

While $Paused

sleep(100)

ToolTip('Script is "Paused"',0,0)

WEnd

ToolTip("")

EndFunc

Func Terminate()

Exit 0

EndFunc

Func ShowMessage()

MsgBox(4096,"","This is a message.")

EndFunc

Edited by LiquidWarlock
Link to comment
Share on other sites

  • Moderators

sorry not sure how you do the code thing...to post it like you guys do. I am always looking through these forums, but decided to register today

<{POST_SNAPBACK}>

[code

]

then

; your code

[/code

]

the above ] brackets go next tot he "e" (not where they are now)

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

Ok, I was testing a "test" script, and racking my brain to see what I could do to help.

I am under the firm belief you have to use a UDF that I'm not sure on how to write the script:

_IsPressed()

So I'm assuming and I'm sure I will be corrected:

Send("Z")
If _IsPressed() = 1 Then; I'm sure I'm way off
; Waiting for "unpause"
Endif
Send("Z")
If _IsPressed() = 1 Then; I'm sure I'm way off
; Waiting for "unpause"
Endif

Etc... Etc... and so on

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

Have to run to the store real quck:

Try looking up in "search": _IsPressed

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

This will do what you want

I tested it

#include <GuiConstants.au3>

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")


While 1
    Send("Z")
    sleep(20)
WEnd

Func TogglePause()
$Paused = NOT $Paused
While $Paused
sleep(100)
ToolTip('Script is "Paused"',0,0)
WEnd
ToolTip("")
EndFunc

Func Terminate()
Exit 0
EndFunc

your welcome

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

  • Moderators

says no topics found

<{POST_SNAPBACK}>

Here is the UDF I believe for it: _IsPressed

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

This will do what you want

I tested it

#include <GuiConstants.au3>

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
While 1
    Send("Z")
    sleep(20)
WEnd

Func TogglePause()
$Paused = NOT $Paused
While $Paused
sleep(100)
ToolTip('Script is "Paused"',0,0)
WEnd
ToolTip("")
EndFunc

Func Terminate()
Exit 0
EndFunc

your welcome

8)

<{POST_SNAPBACK}>

So for my own benefit:

He has a function going w/ all the "Send("Z")'s, and your saying that it will interrupt his current script w/ the togglepause() function? That a key pressed intervenes when a scripti is in motion or a function is in motion? I would imagine that it would have to wait till the end of the loop or function call before it took action itself.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

So for my own benefit:

He has a function going w/ all the "Send("Z")'s, and your saying that it will interrupt his current script w/ the togglepause() function?  That a key pressed intervenes when a scripti is in motion or a function is in motion?  I would imagine that it would have to wait till the end of the loop or function call before it took action itself.

<{POST_SNAPBACK}>

First.. The "z"'s are sent in the "loop" not a function

2nd.. yes it will interupt the script with the toggle/pause

3rd.. the key will interupt a script/motion, but

4th.. not normally a function (it depends)

5th... your right it does have to wait for the loop to complete, however, the loop is very-very short, thus appearing to stop it instantly

hope that helps

8)

NEWHeader1.png

Link to comment
Share on other sites

  • Moderators

First.. The "z"'s are sent in the "loop" not a function

2nd.. yes it will interupt the script with the toggle/pause

3rd.. the key will interupt a script/motion, but

4th.. not normally a function (it depends)

5th... your right it does have to wait for the loop to complete, however, the loop is very-very short, thus appearing to stop it instantly

hope that helps

8)

<{POST_SNAPBACK}>

Sorry, none of my scripts are this short, and they all call to something else.

I would of done something silly like this:

#include <GuiConstants.au3>

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")


While WinExists("Your window title name")
   Sleep(500)
   Send("Z")
   If _IsPressed('75') Then
      TogglePause()
   Endif
   Send("Z")
   If _IsPressed('75') Then
      TogglePause()
   Endif
   Send("Z")
   If _IsPressed('75') Then
      TogglePause()
   Endif
   Send("Z")
   If _IsPressed('75') Then
      TogglePause()
   Endif
   Send("Z")
   If _IsPressed('75') Then
      TogglePause()
   Endif
   Send("Z")
   If _IsPressed('75') Then
      TogglePause()
   Endif
   Send("Z")
   If _IsPressed('75') Then
      TogglePause()
   Endif
   Send("Z")
   If _IsPressed('75') Then
      TogglePause()
   Endif
   Send("Z")
   If _IsPressed('75') Then
      TogglePause()
   Endif
   Send("Z")
   If _IsPressed('75') Then
      TogglePause()
   Endif
   Send("Z")
   If _IsPressed('75') Then
      TogglePause()
   Endif
   Send("Z")
   If _IsPressed('75') Then
      TogglePause()
   Endif
WEnd

Func ContinueSend()
   While 1
      Send("Z")
      If _IsPressed('75') Then
         TogglePause()
      Endif
      Send("Z")
      If _IsPressed('75') Then
         TogglePause()
      Endif
      Send("Z")
      If _IsPressed('75') Then
         TogglePause()
      Endif
      Send("Z")
      If _IsPressed('75') Then
         TogglePause()
      Endif
      Send("Z")
      If _IsPressed('75') Then
         TogglePause()
      Endif
      Send("Z")
      If _IsPressed('75') Then
         TogglePause()
      Endif
      Send("Z")
      If _IsPressed('75') Then
         TogglePause()
      Endif
      Send("Z")
      If _IsPressed('75') Then
         TogglePause()
      Endif
      Send("Z")
      If _IsPressed('75') Then
         TogglePause()
      Endif
      Send("Z")
      If _IsPressed('75') Then
         TogglePause()
      Endif
      Send("Z")
      If _IsPressed('75') Then
         TogglePause()
      Endif
      Send("Z")
      If _IsPressed('75') Then
         TogglePause()
      Endif
   WEnd
 ;Etc, if you want more sends
EndFunc ;==>ContinueSend

Func _IsPressed($hexKey)
   Local $aR, $bO
   
   $hexKey = '0x' & $hexKey
   $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey)
   If Not @error And BitAND($aR[0], 0x8000) = 0x8000 Then
      $bO = 1
   Else
      $bO = 0
   EndIf
   
   Return $bO
EndFunc;==>_IsPressed

Func TogglePause()
$Paused = NOT $Paused
While $Paused
sleep(100)
WEnd
ContinueSend()
EndFunc

Is my logic flawed? Or am I just barking up the wrong tree?

These examples don't help me know, but I can see how they would in the future!!

EDIT: Would of put some Sleep(100) 's between the EndIf 's

Edited by ronsrules

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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