Search the Community
Showing results for tags 'catch'.
-
Hi, I wrote a small script that displays a web page within autoit GUI. Is there a way to "catch" the clicks on the links on that web page? The web page is customizable, so I can define the link in any way I want... Tnx
-
Is there a way to catch errors in AutoIt? SImilar to java's "Try-Catch" methods? My program keeps on throwing errors and I need them to just go away, my program works fine, other than these errors. Here's my code: #NoTrayIcon #include #include #include #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #Obfuscator_Parameters=/cs /cf #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;Opt("TrayMenuMode",1) ;$menu = TrayCreateItem("DriveLocker") ;$menu2 = TrayCreateItem("") ;$menuLock = TrayCreateItem("Lock Drive") ;TraySetState() HotKeySet("{F9}", "_LockDrive") HotKeySet("{PAUSE}", "_Switch") $running = True While 1 While ($running) $letter = DriveGetDrive("REMOVABLE") If IsArray($letter) Then For $i = 1 to $letter[0] _Check($letter[$i]) Next EndIf $time = TimerInit() While TimerDiff($time) < 10000 If IsArray($letter) Then For $i = 1 to $letter[0] _Check($letter[$i]) Next EndIf Sleep(100) WEnd WEnd Sleep(10*1000) WEnd Func _Switch() If ($running) Then $running = False Else $running = True EndIf EndFunc Func _Check($strDriveLetter) If ($running) Then If FileExists($strDriveLetter & "\AutoIt3\Locker\IAmLocked") Then _Unlock($strDriveLetter) ElseIf FileExists($strDriveLetter & "\lock.txt") Then _Unlock($strDriveLetter) EndIf EndIf EndFunc Func _Unlock($strDriveLetter) If ($running) Then $strPassword = InputBox("Security Check", "Enter your password.", "", "*", "", "", @DesktopWidth/2, @DesktopHeight/2,8, "passwordBox") ToolTip("Enter Password NOW.") _MouseTrap(@DesktopWidth, @DesktopHeight-100) If ($strPassword = "PASSWORD") Then _MouseTrap() ToolTip("") FileDelete($strDriveLetter & "\AutoIt3\Locker\IAmLocked") FileDelete($strDriveLetter & "\lock.txt") _ReAnimate($strDriveLetter) ElseIf ($strPassword = "PASSWORDFAILSAFE") Then _MouseTrap() ToolTip("") FileDelete($strDriveLetter & "\AutoIt3\Locker\IAmLocked") FileDelete($strDriveLetter & "\lock.txt") _ReAnimate($strDriveLetter) Else EjectVolume($strDriveLetter) ToolTip("") _MouseTrap() EndIf EndIf EndFunc Func _ReAnimate($strDriveLetter) ;Run(StringUpper($letter[$i]) & "\") ;Run(StringUpper($letter[$i]) & "\new.txt.lnk") ;Run(StringUpper($letter[$i]) & "\you.lnk") ;WinClose("AutoPlay") ;ProcessClose("mcagent.exe") EndFunc Func _LockDrive() $letter = DriveGetDrive("REMOVABLE") If IsArray($letter) Then For $i = 1 To $letter[0] If MsgBox(36,"Lock This Drive?","Do you wish to lock the " & StringUpper($letter[$i]) & " drive?") = 6 Then FileWrite($letter[$i] & "\AutoIt3\Locker\IAmLocked","Locked") _FileCreate($letter[$i] & "\lock.txt") ;EjectVolume($letter[$i]) EndIf Next EndIf EndFunc