Hyflex Posted March 8, 2012 Share Posted March 8, 2012 (edited) Hey, I have written the below and have got some problems with the "TogglePause" if I use HotKeySet it doesn't detect it when I'm using a different program, but with the _IsPressed it works but sometimes it stops and starts or starts then stops too fast like if I was to hold the button down it would start, stop, start, stop...etc Please could someone help me fix it (also if there is a better way of doing what im doing please say.) expandcollapse popup#include <misc.au3> Global $Paused = True Global $Active = True Global $WinMoved = True ;HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") $Win01 = "01" $Win02 = "02" $Ance = "Ance.exe" $CMP = "CMP.exe" While 1 If _IsPressed("13") Then Call("TogglePause") Sleep(1000) EndIf If $WinMoved = False Then If WinExists($Win01) Then WinMove($Win01, "", 0, 0) ConsoleWrite($Win01 & " " & "Moved" & @CRLF) EndIf If WinExists($Win02) Then WinMove($Win02, "", 1920, 0) ConsoleWrite($Win02 & " " & "Moved" & @CRLF) EndIf $WinMoved = True EndIf If $Active = False Then If $WinMoved = True Then If $Active = False Then If FileExists(@ScriptDir & "" & $CMP) Then Run(@ScriptDir & "" & $CMP) EndIf If FileExists(@ScriptDir & "" & $Ance) Then Run(@ScriptDir & "" & $Ance) EndIf ConsoleWrite("Started" & @CRLF) $Active = True EndIf EndIf EndIf Sleep(100) WEnd Func TogglePause() $Paused = Not $Paused While $Paused Sleep(100) If $Active = True Then If ProcessExists($CMP) Then ProcessClose($CMP) EndIf If ProcessExists($Ance) Then ProcessClose($Ance) EndIf EndIf If $WinMoved = True Then ConsoleWrite("Killed" & @CRLF) EndIf If _IsPressed("13") Then Call("TogglePause") Sleep(1000) EndIf $WinMoved = False $Active = False $ProcessesClosed = False WEnd EndFunc ;==>TogglePause Func Terminate() Exit 0 EndFunc ;==>Terminate Edited March 8, 2012 by XxXGoD Link to comment Share on other sites More sharing options...
bogQ Posted March 8, 2012 Share Posted March 8, 2012 Do Sleep(10) Until Not _IsPressed("13") TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
Hyflex Posted March 8, 2012 Author Share Posted March 8, 2012 (edited) Do Sleep(10) Until Not _IsPressed("13") It automatically restarts my scripts... I must be doing something wrong with that bit of code... Edited March 8, 2012 by XxXGoD Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now