Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

XampPause used with "HotKeySet"


  • Please log in to reply
1 reply to this topic

#1 jfcby

jfcby

    Geek Problem Solver In The Making...

  • Active Members
  • PipPipPipPipPipPip
  • 330 posts

Posted 05 October 2008 - 04:28 AM

Hi,

Included is three XamplePause codes that you can use, modify, and change as needed. When putting thes scripts together I used AutoIT3 Forum and Help File.

Code 1: Pause your script with a "HotSetKey" using the keyboard "Pause/Break" key then after un-pauseing the script it re-starts at the same location specificed by you.

Plain Text         
#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Local $msg, $lbCount, $Count, $Exit Global $Paused HotKeySet("{PAUSE}", "PaRsSameLocation") HotKeySet("{ESC}", "_Exit") GUICreate("XampPause Restart SaLoc", 275, 100); will create a dialog box that when displayed is centered         GUICtrlCreateLabel('Keboard Keys: "Esc" = Exit Script' & @LF & @LF & ' and "Pause/Break" = Pause Script', 30, 5, 175, 50, $SS_CENTER)     $lbCount = GUICtrlCreateLabel("1", 10, 75, 25, 25)     $Count = GUICtrlCreateButton("Count", 45, 75, 50, 20)       $Exit = GUICtrlCreateButton("Exit", 100, 75, 50, 20)     GUISetState();Displays an empty dialog box     ;Run the GUI until the dialog is closed     Do         $msg = GUIGetMsg()         Select             Case $msg = $Count                 MsgBox(0, "You clicked on", "Yes")                 For $i = 1 to 50                                        Sleep(500)                     GUICtrlSetData($lbCount, $i)                 Next                 For $i = 50 to 1 Step -1                                        Sleep(500)                     GUICtrlSetData($lbCount, $i)                 Next                 MsgBox(0,"", "Count Complete...")                       Case $msg = $Exit                 MsgBox(0, "You clicked", "Exit")                 _Exit()                         Case $msg = $GUI_EVENT_CLOSE                 MsgBox(0, "You clicked", "Close")                 _Exit()                     EndSelect               Until $msg = $GUI_EVENT_CLOSE Or $msg = $Exit Func PaRsSameLocation()     $Paused = NOT $Paused     While $Paused         sleep(100)         ToolTip('Script is "Paused"',395,325)     WEnd     ToolTip("") EndFunc Func _Exit()     Exit 0 EndFunc


Code 2: Pause your script with a "HotSetKey" using the keyboard "Pause/Break" key then after un-pauseing the script it re-starts at a different location specificed by you.

Plain Text         
#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Global $Paused, $lbCount Main() Func Main() Global $msg, $Count, $Exit HotKeySet("{PAUSE}", "PaRsDifferentLocation") HotKeySet("{ESC}", "_Exit") GUICreate("Xamp DiffLoc", 250, 100);Creates a centered dialog box     GUICtrlCreateLabel('Keboard Keys: "Esc" = Exit Script' & @LF & @LF & ' and "Pause/Break" = Pause Script', 30, 5, 175, 50, $SS_CENTER)     $lbCount = GUICtrlCreateLabel("1", 10, 75, 25, 25)     $Count = GUICtrlCreateButton("Count", 45, 75, 50, 20)       $Exit = GUICtrlCreateButton("Exit", 100, 75, 50, 20)     GUISetState();Displays an empty dialog box     ;Run the GUI until the dialog is closed     Do         $msg = GUIGetMsg()         Select             Case $msg = $Count                 PaRsDifferentLocation()                     Case $msg = $Exit                 MsgBox(0, "You clicked on", "Exit")                 _Exit()             Case $msg = $GUI_EVENT_CLOSE                 MsgBox(0, "You clicked on", "Close")                 _Exit()         EndSelect               Until $msg = $GUI_EVENT_CLOSE Or $msg = $Exit EndFunc Func PaRsDifferentLocation()     $Paused = NOT $Paused         While 1             Switch $Paused                 Case 0                     sleep(100)                     ToolTip('Script is "Paused"',395,325)                 Case 1                     ToolTip("")                     MsgBox(0, "You clicked on", "Yes")                         For $i = 1 to 50 ;MsgBox(0, "Count down!", $i)                             Sleep(500)                             GUICtrlSetData($lbCount, $i)                         Next                         For $i = 50 to 1 Step -1 ;MsgBox(0, "Count down!", $i)                             Sleep(500)                             GUICtrlSetData($lbCount, $i)                         Next                         MsgBox(0,"", "count Complete...")                 EndSwitch         WEnd EndFunc Func _Exit()     Exit 0 EndFunc


Code 3: Pause your script with a "HotSetKey" then after un-pauseing a button will need to be clicked to restart script.

Plain Text         
#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Global $Paused, $lbCount Global $msg, $lbCount, $Count, $Exit HotKeySet("{PAUSE}", "PaRsButtonclick") HotKeySet("{ESC}", "_Exit") GUICreate("XampPause Button Click", 250, 100);creates a centered dialog box         GUICtrlCreateLabel('Keboard Keys: "Esc" = Exit Script' & @LF & @LF & ' and "Pause/Break" = Pause Script', 30, 5, 175, 50, $SS_CENTER)     $lbCount = GUICtrlCreateLabel("1", 10, 75, 25, 25)     $Count = GUICtrlCreateButton("Count", 45, 75, 50, 20)       $Exit = GUICtrlCreateButton("Exit", 100, 75, 50, 20)     GUISetState();displays an empty dialog box Main() Func Main() ;Run the GUI until the dialog is closed     Do         $msg = GUIGetMsg()         Select             Case $msg = $Count                 MsgBox(0, "You clicked ", "Count")                 For $i = 1 to 50;Count up                                       Sleep(500)                     GUICtrlSetData($lbCount, $i)                 Next                 For $i = 50 to 1 Step -1;Count down                                     Sleep(500)                     GUICtrlSetData($lbCount, $i)                 Next                 MsgBox(0,"", "Count Complete...")                       Case $msg = $Exit                 MsgBox(0, "You clicked ", "Exit")                 _Exit()             Case $msg = $GUI_EVENT_CLOSE                 MsgBox(0, "You clicked ", "Close")                 _Exit()         EndSelect               Until $msg = $GUI_EVENT_CLOSE Or $msg = $Exit EndFunc Func PaRsButtonclick()     $Paused = NOT $Paused     While $Paused     sleep(100)     ToolTip('Script is "Paused"',395,325)     WEnd         ToolTip("")     GUICtrlSetData($lbCount, "1")     Main() EndFunc Func _Exit()     Exit 0 EndFunc


Learning to write scripts,
jfcby

Edited by jfcby, 05 October 2008 - 04:48 AM.

Determined -- Devoted -- Delivered Make your mind up -- to seriously apply yourself -- accomplishing the desired results. **** A soft answer turneth away wrath: but grievous words stir up anger. Proverbs 15:1 KJB  *** Learning to write scripts...WMP Resumer | InstaPro Launcher | XampLabel Styles | XampPause - "HotKeySet" | XampCounter | XampSpellCheck *** Forum References Remembered... 5 Tips better coder by: Omar AlBadri (AKA - Volly) | AutoIT3/SciTE - USB by: MadSc13ntist | XSkin.au3 GUI by: Valuater AutoIT MVP | Helpful Collection Autoit Scripts: Maintained By: Volly | Windows Help 101 By: beerman & others *** My Website: Frankie-Cooper.com








#2 BrettF

BrettF

    My Drunk Monkey Guerilla is gonna getcha!

  • MVPs
  • 7,662 posts

Posted 05 October 2008 - 07:29 AM

Nice! Keep up the work!

Cheers,

Brett

:P




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users