Leaderboard
Popular Content
Showing content with the highest reputation on 05/13/2016 in all areas
-
@Trong If you put a invalid URL it will give you a COM error, as advised by Mlipok, you should do something like this: Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") Local $sURL = "https://www.autoitscriptABCD.com/forum/topic/asdf" ; Deliberately cause error by using a non-existing URL For $i = 0 To 1 Local $urlStatus = _URLStatus($sURL) If @error Then MsgBox(48, "Error: " & @error, "Connection problem: " & $urlStatus & @CRLF & "URL: " & $sURL) Switch $urlStatus Case 200 MsgBox(32, "Status", "Connection Successful: " & $urlStatus & @CRLF & "URL: " & $sURL) Case 404 MsgBox(32, "Status", "Connection Successful: " & $urlStatus & @CRLF & "URL Not Found: " & $sURL) Case Else MsgBox(48, "Status", "Connection problem: " & $urlStatus & @CRLF & "URL: " & $sURL) EndSwitch $sURL = "http://www.google.com" ; Lets use a valid URL now Next Func _URLStatus($sURL) $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1") $oHTTP.Open("HEAD", $sURL, False) If @error Then Return SetError(1, 0, 0) $oHTTP.Send() If @error Then Return SetError(2, 0, 0) Return $oHTTP.Status EndFunc ;==>_URLStatus Func _ErrFunc($oError) ; Do anything here. ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc Exit By the way, its nice to see that you were seeking knowledge to be able to help someone else.2 points
-
HyperCam (Screen Recording) UDF
willichan reacted to seangriffin for a topic
This UDF allows users to record the events occurring on their screen in real-time (otherwise known as "screen recording"). Windows XP alone doesn't include a screen recorder. However I believe Windows Vista and Windows 7 do. I wanted to find the best free screen recording UDF solution I could for Windows XP. CamStudio is clearly a popular choice in these forums. Though I was already using HyperCam prior to evaluating CamStudio. After comparing the two applications, I found them to both be almost identical, with one major exception. HyperCam includes a COM interface. It was therefore the ideal choice for an AutoIT UDF. REQUIREMENTS: AutoIt3 3.2 or higherA HyperCam is installed & registeredLIST OF FUNCTIONS: EXAMPLE: The following example demonstrates how the HyperCam UDF can be used to record activities on the screen. On running the script, a full resolution screen recording (of the entire screen) will be performed for 3 seconds, with the result stored in the file "c:\full resolution 3 second recording.avi". Immediately after this, another screen recording is performed, on a 400 x 300 pixel area of the screen, also for 3 seconds, with the result stored in the file "c:\400x300 3 second recording.avi". HyperCam example.au3 DOWNLOAD: Latest Version - v0.1 (18/06/10) HyperCam.au31 point -
Better is post #9 But the following one : Opt("MustDeclareVars", 1) #AutoIt3Wrapper_Run_AU3Check=Y #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 #include <MsgBoxConstants.au3> _Example("https://www.somenotexistingurl.com") Func _Example($sURL) Local $sURL_Status = _ULRNotifier(_URL_CheckStatus($sURL)) If @error Then Return SetError(@error, @extended, $sURL_Status) MsgBox($MB_OK + $MB_ICONINFORMATION, 'SUCCESS', '$sURL_Status=' & $sURL_Status) EndFunc ;==>_Example Func _URL_CheckStatus($sURL) _URLChecker_COMErrDescripion("") Local $oErrorHandler = ObjEvent("AutoIt.Error", "_URLChecker_COMErrFunc") #forceref $oErrorHandler Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1") $oHTTP.Open("HEAD", $sURL, False) If @error Then Return SetError(1, @error, '') $oHTTP.Send() Local $iError = @error Local $sStatus = $oHTTP.Status If @error Then Return SetError(3, @error, $sStatus) If $iError Then Return SetError(2, $iError, $sStatus) Return $sStatus EndFunc ;==>_URL_CheckStatus Func _URLChecker_COMErrFunc($oError) _URLChecker_COMErrDescripion($oError.description) Return ; you can comment/dlete this return to show full error descripition ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "$oError.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "$oError.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "$oError.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "$oError.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "$oError.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "$oError.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "$oError.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "$oError.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "$oError.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_URLChecker_COMErrFunc Func _URLChecker_COMErrDescripion($sDescription = Default) Local Static $sDescription_static = '' If $sDescription <> Default Then $sDescription_static = $sDescription Return $sDescription_static EndFunc ;==>_URLChecker_COMErrDescripion Func _ULRNotifier($vResult, $iError = @error, $iExtended = @extended) If $iError Then ConsoleWrite( _ "! @error = " & $iError & " @extended = " & $iExtended & " $vResult = " & $vResult & @CRLF & _ "! " & _URLChecker_COMErrDescripion() & @CRLF _ ) Return SetError($iError, $iExtended, $vResult) EndFunc ;==>_ULRNotifier is the best - at least for the moment when I post it1 point
-
1 point
-
You should use COM Error Handler. Check for: ObjEvent ( "AutoIt.Error" [, "function"] ) The first example for ObjEvent() in HelpFile shows how to handle COM Errors1 point
-
Try to find one and if found write a bug ticket.1 point
-
Free library for resetting windows password?
clariceo0 reacted to JLogan3o13 for a topic
@clariceo0 Usually we follow more of a "teach a man to fish" motto rather than just handing folks scripts, but I had this one lying about. It should give you an idea how to proceed anyway; you will probably need to modify to your needs. Also you'll want to test heavily; it is an older script which I have not tested on Windows 10. Let me know if you have any questions: #include <EditConstants.au3> #include <GUIConstantsEx.au3> Local $sUserName, $sPassword $hGUI = GUICreate("Reset Local Password", 300, 300) GUISetState(@SW_SHOW) GUISetFont(11, 400, Default, "Arial") $lblUserName = GUICtrlCreateLabel("Username", 115, 10, 65, 30) $lblPassword = GUICtrlCreateLabel("Choose New Password", 75, 90, 150, 30) $lblVerify = GUICtrlCreateLabel("Verify New Password", 75, 170, 150, 30) $inpUserName = GUICtrlCreateInput(@UserName, 10, 40, 280, 30, $ES_CENTER) $inpPassword = GUICtrlCreateInput("", 10, 120, 280, 30, $ES_PASSWORD) $inpVerify = GUICtrlCreateInput("", 10, 200, 280, 30, $ES_PASSWORD) $btnGo = GUICtrlCreateButton("Change Password", 10, 250, 125, 35) $btnClose = GUICtrlCreateButton("Exit", 165, 250, 125, 35) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $btnClose ExitLoop Case $btnGo If GUICtrlRead($inpPassword) == GUICtrlRead($inpVerify) Then $sUserName = GUICtrlRead($inpUserName) $sPassword = GUICtrlRead($inpPassword) _changePW($sUserName, $sPassword) Else MsgBox(0, "Reset Local Password", "Passwords do not match!") EndIf EndSwitch WEnd Func _changePW($UserName, $Password) $oUser = ObjGet("WinNT://" & @ComputerName & "/" & $UserName) If IsObj($oUser) Then $oUser.SetPassword($Password) $oUser.SetInfo EndIf EndFunc Edit: Also, although you posted in a C++ forum you didn't specify that you need this done in C++/C. Are you just looking to get the job done, or do you have a language requirement that it needs to be coded in?1 point -
Hi. Putting the Master Password "clear text" into your script is IMHO definitely not a good idea. So generate a HASH code of your password, and put that one in your script, then check the user input's hash against the hash stored "inside" your script. #include <Crypt.au3> #Region PasswdCheck $PWD = "" $PW_hash = "0x83CA415FC4A7FCE3163736F7BB472D7753070832" Do $PWD = InputBox("Special Access", "Your password, please", "", "*") Until $PWD <> "" _Crypt_Startup() $Hash_Input = _Crypt_HashData($PWD, $CALG_SHA1) If $Hash_Input <> $PW_hash Then MsgBox(64, "Wrong Password", "The password you specified is not valid!", 10) Exit EndIf _Crypt_Shutdown() #EndRegion PasswdCheck Note: Have a look to the constants block inside CRYPT.AU3, there you have even more choices you can use by uncommenting e.g. ; Global Const $CALG_SHA_256 = 0x0000800c regards, Rudi.1 point
-
Array delete blank element
beautifulsoup reacted to Bowmore for a topic
An example of how to remove blanks using only the original array. Func _ArryRemoveBlanks(ByRef $arr) $idx = 0 For $i = 0 To UBound($arr) - 1 If $arr[$i] <> "" Then $arr[$idx] = $arr[$i] $idx += 1 EndIf Next ReDim $arr[$idx] EndFunc ;==>_ArryRemoveBlanks ;Some code just to show it working #include <array.au3> Dim $arr1[10] $arr1[0] = "" $arr1[1] = "ABC" $arr1[2] = "" $arr1[3] = "xyz" $arr1[4] = "def" $arr1[5] = "" $arr1[6] = "" $arr1[7] = "ffr" $arr1[8] = "" $arr1[9] = "Z33" _ArrayDisplay($arr1, "Before") _ArryRemoveBlanks($arr1) _ArrayDisplay($arr1, "After")1 point -
Something like this ? #include <Array.au3> dim $arr1[4] $arr1[0]="" $arr1[1]="ABC" $arr1[2]="" $arr1[3]="xyz" $arr2 = _RemoveEmptyArrayElements ( $arr1 ) _ArrayDisplay ( $arr2 ) Func _RemoveEmptyArrayElements ( $_Array ) Local $_Item For $_Element In $_Array If $_Element= '' Then _ArrayDelete ( $_Array, $_Item ) Else $_Item+=1 EndIf Next Return ( $_Array ) EndFunc ;==> _RemoveEmptyArrayElements ( )1 point