Jump to content

Need Help. Pausing


Recommended Posts

using your code

#include <GuiConstants.au3>

Global $Paused

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

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

While WinExists("Your window title name")

Sleep(50)

Send("Z")

If _IsPressed('75') Then

TogglePause()

Endif

WEnd

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

***** this should do the same thing ************ not tested*********

8)

NEWHeader1.png

Link to comment
Share on other sites

  • Moderators

I don't even have to run SciTE to see that this will run errors.

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

If you were trying to say that I put too many Send("Z")'s thanks:

Revised, but please read:

#include <GuiConstants.au3>

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


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

Func ContinueSend()
   While 1
      Send("Z")
      Sleep(100)
      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

Forgot the Sleeps again!! :)

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

First and foremost... Please understand I am not here to attack anyone, my suggestions are humble, so please dont take anything offensive..ok 8)

I dont know how to write this

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

We all have areas of expertise ( mine are few) 8)

I played with your code.... and placed ";" where you do not need these in your script... hope thats ok 8) ........just suggestions

I did test this... actually i am not sure where _isPressed() applies????

#include <GuiConstants.au3>

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

Run("Notepad.exe")
sleep(2000)


While WinExists("Untitled - Notepad")
   Sleep(50)
   Send("Z")
   If _IsPressed('75') Then
      TogglePause()
   Endif
WEnd

;Func ContinueSend()
;   While 1
;     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

Func Terminate(); you left this one out
Exit 0
EndFunc

enjoy!

8)

NEWHeader1.png

Link to comment
Share on other sites

  • Moderators

Cool, now that makes sense.

And no one took you offensively. You just post so much "help" file or other scripts, that it's hard sometimes to tell if you read the script.

But this makes total sense.

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

LOL, I wrote the code he trimmed it, and he got the kudos :) ...

Nah, just kidding ... I'm glad it's working for you.

Nice catch Valuater :evil:

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