waynew Posted February 21, 2010 Posted February 21, 2010 (edited) #Include <HotKey.au3> Global Const $VK_ESCAPE = 0x1B Global Const $VK_F12 = 0x7B Global $testFlg _HotKeyAssign($VK_F12, 'test', $HK_FLAG_DEFAULT) ; Assign "CTRL-ESC" with Quit() _HotKeyAssign(BitOR($CK_CONTROL, $VK_ESCAPE), 'Quit') While 1 Sleep(10) WEnd Func Quit() Exit EndFunc ;==>Quit Func test() $testFlg = Not $testFlg If Not $testFlg Then Beep() Local $io = 0 While $testFlg Sleep(1000) $io += 1 ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $io = ' & $io & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console WEnd EndFunc i want to start or stop the function "test" use the same key ,but it seemed don't work,what's wrong.HotKey.au3 Edited February 21, 2010 by waynew
Developers Jos Posted February 21, 2010 Developers Posted February 21, 2010 (edited) Ensure the func test() ends to be able to fire it again with the same HotKey and do the testing for $testFlg in the mainloop. Edited February 21, 2010 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Yashied Posted February 21, 2010 Posted February 21, 2010 @waynewYour code design is wrong. You should not stop the interrupting function - Test(). Here's one way to fix this.#Include <HotKey.au3> Global Const $VK_ESCAPE = 0x1B Global Const $VK_F12 = 0x7B Global $testFlg = False, $io _HotKeyAssign($VK_F12, 'Test', $HK_FLAG_NOOVERLAPCALL) _HotKeyAssign(BitOR($CK_CONTROL, $VK_ESCAPE), 'Quit') While 1 Sleep(10) WEnd Func Quit() Exit EndFunc ;==>Quit Func Test() $testFlg = Not $testFlg If $testFlg Then $io = 0 AdlibRegister('Debug', 1000) Else AdlibUnRegister('Debug') Beep() EndIf EndFunc ;==>Test Func Debug() $io += 1 ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $io = ' & $io & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console EndFunc ;==>Debug My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
t0ddie Posted February 21, 2010 Posted February 21, 2010 from the helpfile ; Press Esc to terminate script, Pause/Break to "pause" Global $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") HotKeySet("+!d", "ShowMessage") ;Shift-Alt-d ;;;; Body of program would go here ;;;; While 1 Sleep(100) WEnd ;;;;;;;; Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Func Terminate() Exit 0 EndFunc Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.
waynew Posted February 23, 2010 Author Posted February 23, 2010 thanks a lot but i want to use the function _HotKeyAssign,i think there should be a way to solve this.
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