newcomer44 Posted November 10, 2011 Posted November 10, 2011 Hello, as the title says, I want to break a script without pressing a key and resume it per hotkey. Many thanks in advance.
sleepydvdr Posted November 10, 2011 Posted November 10, 2011 Example: #include <date.au3> Global $Paused HotKeySet("{PAUSE}", "TogglePause") #include <GUIConstants.au3> $Form1 = GUICreate("Form1", 294, 85, 193, 125) $Label1 = GUICtrlCreateLabel("Label1", 24, 24, 236, 28) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch $time = _NowCalc() GUICtrlSetData($Label1, $time) Sleep(50) WEnd Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc #include <ByteMe.au3>
DicatoroftheUSA Posted November 10, 2011 Posted November 10, 2011 (edited) HotKeySet("{f5}", "_process") Global $giStep = 0 main() Func main() While 1 Sleep(10) WEnd EndFunc ;==>main Func _process() Switch $giStep Case 0 $giStep += _step($giStep) Return (1) Case 1 $giStep += _step($giStep) Return (1) Case 2 $giStep += _step($giStep) Return (1) Case 3 Exit EndSwitch EndFunc ;==>_process Func _Step($giStep) ConsoleWrite(@LF & "This should do stuff! " & $giStep & @LF) Return (1) EndFunc ;==>_Step Edited November 10, 2011 by DicatoroftheUSA Statism is violence, Taxation is theft. Autoit Wiki
newcomer44 Posted November 10, 2011 Author Posted November 10, 2011 (edited) Hello, thanks for your proposals. This is nearly what I mean: Run("notepad.exe") WinWaitActive("[CLASS:Notepad]") Send("This is a testline before the enter key was pressed." & @LF) Send("This is a testline before the enter key was pressed." & @LF) ; -------------------------------------------------------------------- #include<Misc.au3> $dll = DllOpen("user32.dll") While 1 Sleep(250) If _IsPressed("0D", $dll) Then ; enter ExitLoop Else MsgBox(0, "confirmation", "Press <ENTER> to confirm") EndIf WEnd DllClose($dll) ; -------------------------------------------------------------------- Sleep(500) Send(@LF) Send(@LF) Send("This is a testline after the enter key was pressed." & @LF) Send("This is a testline after the enter key was pressed." & @LF) Exit The problem is, that I have to press the enter key too long, in order to continue the script flawlessly. Edited November 10, 2011 by newcomer44
AdmiralAlkex Posted November 10, 2011 Posted November 10, 2011 But you coded it to take a long time. Imagine that Enter is pressed straight after the _IsPressed(), you have a 250 ms Sleep() so it would have to be pressed for 250 ms! Unless you need the Enter for something else, use HotKeySet() instead of _IsPressed(). Or since it's just notepad you're automating, one of the Control*() functions, or write directly to the file with something like FileWrite(). .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
newcomer44 Posted November 12, 2011 Author Posted November 12, 2011 Now I understand. All I had to do, was to reduce the Sleep(250) value to Sleep(10). Thanks at all.
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