c.haslam Posted May 25, 2015 Share Posted May 25, 2015 (edited) The following code is my attempt to check whether a user inserts a CD or USB stick (drive E:) within 15 seconds, but it doesn't work:Opt('TrayIconDebug') #include <timers.au3> $hGUI = GUICreate("Simple timer", 400, 320) GUISetState(@SW_SHOW) $timer = _Timer_SetTimer($hGUI, 3000, "Check_mounted") ; create timer $secs = 0 Func Check_mounted($hWnd, $iMsg, $iIDTimer, $iTime) #forceref $hWnd, $iMsg, $iIDTimer, $iTime $result = '' If FileExists('E:\') Then $result = 'loaded' Else $secs += 3 If $secs=15 Then $result = 'timed out' EndIf EndIf If $result<>'' Then MsgBox(0,'',$result) _Timer_KillTimer($hGUI,$timer) GUIDelete($hGUI) EndIf EndFunc Perhaps I have a stupid bug, or perhaps not. Suggestions? Edited May 25, 2015 by c.haslam added parameters to Check_mounted(), added sleep(5000) Spoiler CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard Link to comment Share on other sites More sharing options...
l3ill Posted May 25, 2015 Share Posted May 25, 2015 (edited) There are more elegant ways of checking for cd's and Sticks.Search the helpfile for Drive or Removable Drive...For Instance - _WinAPI_IsDoorOpenEdit: DriveStatus looks like it would work well here. Edited May 25, 2015 by l3ill My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
c.haslam Posted May 25, 2015 Author Share Posted May 25, 2015 (edited) My actual objectives::Come up with as simple an example as possible for _Timer_SetTimer() being used for an external event timing outSometimes RunWait() hangs up when doing schtasks.exe. I am trying to code telling the user when it has hung, and hopefully to figure out why/when it hangs up.I posted the above code as easier to work with than the actual case. Edited May 25, 2015 by c.haslam Spoiler CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard 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