jfcby Posted October 6, 2008 Share Posted October 6, 2008 (edited) Hi, This counter was designed for learning purposes and by using Valuater counter script to add some new features into another project I'm working on. I posted it for future reference and maybe for others to learn from. expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Local $msg, $lbCount, $Exit Local $Start, $Pause, $Continue, $Stop, $Reset ;Flags ~Record Count, ~Begin Count, ~Continue Count Global $rCount = 0, $bCount = 0, $cCount = 0 HotKeySet("{ESC}", "_Exit") GUICreate("XampCounter", 275, 150); will create a dialog box that when displayed is centered GUICtrlCreateLabel('Keboard Keys: "Esc" = Exit Script', 30, 5, 175, 50, $SS_CENTER) $lbCount = GUICtrlCreateLabel("1", 10, 75, 25, 25) $Start = GUICtrlCreateButton("Start", 45, 75, 50, 20) $Pause = GUICtrlCreateButton("Pause", 10, 100, 50, 20) $Continue = GUICtrlCreateButton("Continue", 65, 100, 50, 20) $Stop = GUICtrlCreateButton("Stop", 125, 100, 50, 20) $Reset = GUICtrlCreateButton("Reset", 185, 100, 50, 20) $Exit = GUICtrlCreateButton("Exit", 185, 125, 50, 20) GUISetState() ;Displays an empty dialog box ;Run the GUI until the dialog is closed Do $msg = GUIGetMsg() Select Case $msg = $Start MsgBox(0, "Start Counter", "Counter Started") $cCount = 0 $bCount = 1 AdlibEnable("Count", 100) Case $msg = $Pause _pCount() Case $msg = $Continue _cCount() Case $msg = $Stop Or $msg = $Reset MsgBox(0, "Stop Counter", "Counter Stopped") $bCount = 0 AdlibDisable() GUICtrlSetData($lbCount, "0") Case $msg = $GUI_EVENT_CLOSE Or $msg = $Exit MsgBox(0, "You clicked", "Close") _Exit() EndSelect Until $msg = $GUI_EVENT_CLOSE Or $msg = $Exit Func Count() If $bCount = 1 Then $cCount = $cCount +1 EndIf If $bCount = 2 Then $rCount = $cCount +1 EndIf GUICtrlSetData($lbCount, $cCount) EndFunc;==>Increment Count by 1 Func _pCount() Global $bCount = 2 EndFunc;==>Pause Counter Func _cCount() Global $bCount = 1 Global $cCount = $rCount EndFunc;==>Continue Count Func _Exit() Exit 0 EndFunc;==>Exit/Quit Script Learning to write scripts, jfcby Edited October 6, 2008 by jfcby 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 **** 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