Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/05/2021 in all areas

  1. Nine

    Error accessing 2D array

    Here how you would do it : #include <Array.au3> Local $aPrograms[0][2] Local $aWinList = WinList() For $i = 1 To $aWinList[0][0] If $aWinList[$i][0] <> "" And BitAND(WinGetState($aWinList[$i][1]), 2) Then ReDim $aPrograms[UBound($aPrograms) + 1][2] $aPrograms[UBound($aPrograms)-1][0] = $aWinList[$i][0] $aPrograms[UBound($aPrograms)-1][1] = $aWinList[$i][1] EndIf Next _ArrayDisplay($aPrograms) MsgBox(0, "", UBound($aPrograms))
    2 points
  2. As it says in help file : If the dll does not implement the 'DllGetVersion' function in its own DLL, you cannot use _WinAPI_DllGetVersion.
    1 point
  3. Musashi

    Error accessing 2D array

    Just in case you prefer a solution with _ArrayAdd (actually superfluous after @Nine presented his one ). #include <Array.au3> Local $aPrograms[0][2] Local $aWinList = WinList() For $i = 1 To $aWinList[0][0] If $aWinList[$i][0] <> "" And BitAND(WinGetState($aWinList[$i][1]), 2) Then _ArrayAdd($aPrograms, $aWinList[$i][0] & "|" & $aWinList[$i][1]) EndIf Next _ArrayDisplay($aPrograms) MsgBox(0, "", UBound($aPrograms))
    1 point
  4. ptrex

    Hex Editor COM Control

    HEX Editor COM Control You can find the HEX Editor GUI example based on this ActiveX control https://www.codeproject.com/Articles/1384/Hex-Editor-OCX-Control It was a challenge to make it all work, but due the Lars his bright solution the final piece of the puzzle was in place. See here where all the magic is happening ! I made 2 slight optimizations : 1. No need for an external VBScript 2. No need to register the OCX control on Windows PREQUISITES : 1. Download the HexEdit.ocx see attached. And put it is your script folder (No registration needed ! ) 2. Download IRunningObjectTable.au3 3. Run this script ; https://www.codeproject.com/Articles/1384/Hex-Editor-OCX-Control #AutoIt3Wrapper_UseX64=N ;~ Opt("WinTitleMatchMode", 2) #include <ColorConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <FileConstants.au3> #include "IRunningObjectTable.au3" #include <Array.au3> ; Initialize COM error handler $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") Global $hFileOD Global $hFile Global $hActiveX ; Load ActiveX module $hActiveX = DllOpen(@ScriptDir & "\HexEdit.ocx") ; Object identifiers Global Const $sCLSID = "{2E93307E-777D-49E4-886A-D5B04470796A}" Global Const $sIID = Default ; Create a simple GUI for our output Local $hHexEdit = GUICreate ( "Hex Editor", 1000, 580,(@DesktopWidth-1000)/2, (@DesktopHeight-580)/2 ) Local $idButton_About = GUICtrlCreateButton("About", 100, 10, 85, 25) Local $idButton_FileOpen = GUICtrlCreateButton("FileOpen", 10, 10, 85, 25) GUICtrlCreateGroup("Columns", 790, 40, 190, 90) Local $idInput = GUICtrlCreateInput("20", 800, 80, 60, 25) GUICtrlCreateUpdown($idInput) $sInput = GUICtrlRead($idInput) Local $idButton_Auto = GUICtrlCreateButton("Auto", 880, 80, 75, 25) GUICtrlCreateGroup("Address", 790, 180, 190, 90) Local $idAscii = GUICtrlCreateCheckbox("Address", 800, 180, 185, 25) Local $idAddress1 = GUICtrlCreateRadio("WORD", 800, 210, 120, 20) Local $idAddress2 = GUICtrlCreateRadio("DWORD", 800, 235, 120, 20) GUICtrlSetState($idAddress1, $GUI_CHECKED) GUICtrlCreateGroup("Data", 790, 280, 190, 90) Local $idData1 = GUICtrlCreateRadio("BYTE", 800, 300, 120, 20) Local $idData2 = GUICtrlCreateRadio("WORD", 800, 320, 120, 20) Local $idData3 = GUICtrlCreateRadio("DWORD", 800, 340, 120, 20) GUICtrlSetState($idData1, $GUI_CHECKED) Local $idAscii = GUICtrlCreateCheckbox("Show ASCII", 800, 400, 185, 25) GUICtrlSetState(-1, 1) Local $idInvert = GUICtrlCreateCheckbox("Invert Color", 800, 430, 185, 25) Local $idLabel = GUICtrlCreateLabel("Modified : ", 800, 540, 185, 25) ; Create Com Object ;~ Local $oHexEdit = ObjCreate("HEXEDIT.HexEditCtrl.1") Local $oHexEdit = ObjCreate($sCLSID, $sIID, $hActiveX) If IsObj($oHexEdit) = 0 Then MsgBox(48, "Error", "Could not create the object, Common problem ActiveX not registered.") ConsoleWrite(IsObj($oHexEdit) & @CRLF) Exit EndIf $oHexEdit.Appearance = 1 $oHexEdit.AllowChangeSize = 0 $oHexEdit.BackColor = 0x000000 $oHexEdit.ForeColor = 0xffffff $oHexEdit.Fontheight = 16 $oHexEdit.Columns = Int($sInput) $GUIActiveX = GUICtrlCreateObj ($oHexEdit, 10, 40, 750, 520) GUICtrlSetResizing ( $GUIActiveX, $GUI_DOCKAUTO) GUICtrlSetData($idLabel, "Modified ; " & $oHexEdit.DataModified) ; Show GUI GUISetState () ; Loop GUI While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_PRIMARYDOWN GUICtrlSetData($idLabel, "Modified ; " & $oHexEdit.DataModified) If $oHexEdit.DataModified = True Then GUICtrlSetColor($idLabel, $COLOR_RED) EndIf Case $idButton_About $oHexEdit.AboutBox() Case $idButton_Auto $oHexEdit.Columns = 0 Case $idInput $oHexEdit.Columns = GUICtrlRead($idInput) Case $idAscii If BitAND(GUICtrlRead($idAscii), $GUI_CHECKED) = $GUI_CHECKED Then $oHexEdit.ShowAscii = 1 Else $oHexEdit.ShowAscii = 0 EndIf Case $idInvert If BitAND(GUICtrlRead($idInvert), $GUI_CHECKED) = $GUI_CHECKED Then $oHexEdit.BackColor = 0xffffff $oHexEdit.ForeColor = 0x000000 Else $oHexEdit.BackColor = 0x000000 $oHexEdit.ForeColor = 0xffffff EndIf Case $idButton_FileOpen Set_Data(GetFile()) If BitAND(GUICtrlRead($idAddress1), $GUI_CHECKED) = $GUI_CHECKED Then $oHexEdit.DigitsInAddress = 4 EndIf If BitAND(GUICtrlRead($idAddress2), $GUI_CHECKED) = $GUI_CHECKED Then $oHexEdit.DigitsInAddress = 8 EndIf If BitAND(GUICtrlRead($idData1), $GUI_CHECKED) = $GUI_CHECKED Then $oHexEdit.DigitsInData = 2 EndIf If BitAND(GUICtrlRead($idData2), $GUI_CHECKED) = $GUI_CHECKED Then $oHexEdit.DigitsInData = 4 EndIf If BitAND(GUICtrlRead($idData2), $GUI_CHECKED) = $GUI_CHECKED Then $oHexEdit.DigitsInData = 8 EndIf EndSwitch WEnd ; Function File Open Func GetFile() $hFileOD = FileOpenDialog("Select EXE File", @ScriptDir & "\", "EXE (*.exe)") $hFileOpen = FileOpen($hFileOD, 16) If $hFileOpen = -1 Then MsgBox(48, "Error", "Unable to open file, or no file selected !!") Else ; Read the contents of the file using the handle returned by FileOpen. Local $sFileRead = FileRead($hFileOpen) Return $sFileRead EndIf ; Close the handle returned by FileOpen. FileClose($hFileOpen) EndFunc Func Set_Data($dBinary) ; https://www.autoitscript.com/forum/topic/202618-implementing-irunningobjecttable-interface/?do=findComment&comment=1471171 Local $sDictionaryData = "DictionaryData" ROT_RegisterObject( Default, $sDictionaryData ) ; Default => Object = Dictionary object Local $oROTobj = ObjGet( $sDictionaryData ) ; Dictionary object $oROTobj( "oHexEdit" ) = $oHexEdit $oROTobj( "dBinary" ) = $dBinary Local $code= 'Dim oROTobj, oHexEdit, dBinary' $code=$code & @CRLF & 'Set oROTobj = GetObject( "DictionaryData" )' $code=$code & @CRLF & 'Set oHexEdit = oROTobj( "oHexEdit" )' $code=$code & @CRLF & 'dBinary = oROTobj( "dBinary" )' $code=$code & @CRLF & 'oHexEdit.SetData dBinary, 0' Local $vbs = ObjCreate("ScriptControl") $vbs.language="vbscript" $vbs.addcode($code) ;~ ROT_Revoke($oROTobj) EndFunc ; COM Error Handler Func MyErrFunc() $HexNumber=hex($oMyError.number,8) Msgbox(0,"AutoItCOM","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & $HexNumber & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) SetError(1) Endfunc Enjoy !! PS : I did not implement the write back to file yet. Feel free to add this if needed. HexEdit.zip
    1 point
  5. ptrex

    Hex Editor COM Control

    @Chimp Thanks for the tip ! I will give it a try when I see some time available.
    1 point
  6. Guys, many thanks for the test So it's a good idea to always keep $WS_EX_COMPOSITED in case the user's OS is Win7 (or maybe Win8) and it shouldn't hurt if his OS is Win10, very interesting ! This 1st step being done, I can now move to the 2nd step and post another script here... when it will be ready
    1 point
  7. @dranzer006 Could you please post the entire UI tree from simplespy or UIASpy?
    1 point
  8. This looks troublesome. Why would you have to set the time back In order to use a piece of software?
    1 point
  9. @Professor_Bernd You have 2 problems, one that can be fixed the other is not possible : 1. To get rid of the COM error. You run x86 COM object on a x64 OS. This will not work. You need to tell the vbscript host to execute it as x86 like this : run %windir%\SysWoW64\cmd.exe and next your vbscript : wscript Test.vbs 2. The vbscript running AutoITX will run but not show anything. Because vbs does not have access to the Windows API's out of the box. extend your script by adding this line : msgbox "This was a tooltip" And run again. WORK AROUNDS : 1. Let vbscript run a AutoIT compiled script to show the ToolTip 2. Use DYNACALL to extend vbscript to access Windows API's https://www.itprotoday.com/devops-and-software-development/rem-calling-win32-api-vbscript-code Example calling a msgbox using WinAPI:
    1 point
  10. @pixelsearch Microsoft Windows 10 Pro, 10.0.18362 build 18362 No flickering with and without $WS_EX_COMPOSITED
    1 point
  11. Win 7 Pro version 6.1 (build 7601: SP1) Label is not blinking if $WS_EX_COMPOSITED is set. Label is blinking if $WS_EX_COMPOSITED is not set.
    1 point
  12. @Cyphon68, Thanks for the kudos. According to the specs, you would need to do something like this -- _WD_Window($sSession, 'rect', '{"y":"-10000"}') FWIW, _WD_Window isn't currently designed to accept an object for the $sOption parameter. Not enough details to be able to suggest a fix. You could try running your script with the following settings -- $_WD_DEBUG = $_WD_DEBUG_Info _WD_Option('console', 'c:\path\to\your\log\webdriver.log') and post the resulting file here. Be sure to sanitize first to avoid giving out login details. 😅 Dan P.S. WDE!
    1 point
  13. If it doesn't have to be by name you could use something like this to set the parameters by number. Means: The first parameter goes to element 1 of the parameter array and so on. Example: Global $iParamsCount = 12 ; Maximum number of parameters of the function you want to call Global $aParams[$iParamsCount + 1] = ["CallArgArray"] ; Optional: Set all parameters to "Default" For $i = 1 To UBound($aParams)-1 $aParams[$i] = Default Next ; Set the needed parameters $aParams[3] = 123 Call(_TestFunction, $aParams) Exit Func _TestFunction($vP1 = Default, $vP2 = Default, $vP3 = Default, $vP4 = Default, $vP5 = Default, $vP6 = Default, $vP7 = Default, $vP8 = Default, $vP9 = Default, $vP10 = Default, $vP11 = Default, $vP12 = Default) ConsoleWrite("Number of Parameters: " & @NumParams & @CRLF) For $i = 1 To @NumParams $vParam = Eval("vP" & $i) ConsoleWrite("Parameter " & $i & ": " & $vParam & @CRLF) Next EndFunc ;==>_TestFunction
    1 point
  14. @Professor_Bernd This is the registration free AutoIT example that shows a TOOLTIP on your screen. #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Version=beta #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=Y Global $hActiveX ; Load the ActiveX Module If @AutoItX64 Then $hActiveX = DllOpen(@ScriptDir & "\AutoItX3_x64.dll") Else $hActiveX = DllOpen(@ScriptDir & "\AutoItX3.dll") EndIf ;MsgBox(0,"x64",@AutoItX64) ; Object identifiers Global Const $sCLSID = "{1A671297-FA74-4422-80FA-6C5D8CE4DE04}" Global Const $sIID = Default ; Or use keyword Default if you want to use the Default interface ID ; Error Monitoring Global $oError = ObjEvent("AutoIt.Error", "_ErrFunc") Func _ErrFunc() ConsoleWrite("! COM Error ! Number: 0x" & Hex($oError.number, 8) & " ScriptLine: " & $oError.scriptline & " - " & $oError.windescription & @CRLF) Return EndFunc ;==>_ErrFunc ; Create the hActiveX Local $oAutoIt = ObjCreate($sCLSID, $sIID, $hActiveX) If $oAutoIt = 0 Then MsgBox(16,"Error", "Could not create the object, Common problem ActiveX not registered.") ; This will create a tooltip in the upper left of the screen $oAutoIt.ToolTip ("This is a tooltip", 450, 200) $oAutoIt.Sleep (3000) ; Sleep to give tooltip time to display $oAutoIt = "" DllClose($hActiveX) Enjoy !
    1 point
  15. Fwiw, the second window WinWait("Microsoft Visual C++ 2010 X86 Redistributable Setup") does not get activated before the click is sent, in the OPs version. Maybe it doesn’t matter, maybe it does.
    1 point
  16. Aelc

    If loop killing script

    well i would use something like _WinExistAct("MagTek HID Secure Card Reader Authenticator API Setup") If @error Then _Error() MouseClick("primary", 152, 220, 1, 0) _WinExistAct("Microsoft Visual C++ 2010 X86 Redistributable Setup") If @error Then _Error() MouseClick("primary", 52, 265, 1, 0) Sleep(2000) MouseClick("primary", 365, 446, 1, 0) _WinExistAct("Microsoft Visual C++ 2010 X86 Redistributable Setup", "Installation Is Complete") If @error Then _Error() MouseClick('primary', 439, 446, 1, 0) Func _Error() MsgBox(48, "error", "timeout reached") Exit EndFunc ;==>_Error Func _WinExistAct($title, $text = "", $timeout = 10) $timeout = $timeout * 1000 Local $timer = TimerInit() Do Sleep(50) Local $diff = TimerDiff($timer) Until WinExists($title, $text) Or $diff >= $timeout If $timer > $timeout Then Return SetError(-1, 0, -1) If Not WinActive($title, $text) Then WinActivate($title, $text) Return 0 EndFunc ;==>_WinExistAct and also i would use ControlClick and ControlGetText in a do until loop to check if controls exist when it's same title of the window, instead of using mouseclick and sleep - to be fast as possible... like this you are always waiting 2 seconds. if the installer finished or not. maybe some people have slower or faster PCs and then this doesn't work anymore or it takes more time as necessary
    1 point
  17. The actual loop. “If's” are not loops. This, OTOH, loops forever: While True If WinExists("MagTek HID Secure Card Reader Authenticator API Setup") Then WinActivate("MagTek HID Secure Card Reader Authenticator API Setup") Sleep(2000) MouseClick('primary', 152, 220, 1, 0) WinWait("Microsoft Visual C++ 2010 X86 Redistributable Setup") MouseClick('primary', 52, 265, 1, 0) Sleep(2000) MouseClick('primary', 365, 446, 1, 0) WinWait("Microsoft Visual C++ 2010 x86 Redistributable Setup", "Installation Is Complete") WinActivate("Microsoft Visual C++ 2010 x86 Redistributable Setup", "Installation Is Complete") MouseClick('primary', 439, 446, 1, 0) EndIf Sleep(1000) WEnd Change the While True to whatever condition you want to exit the loop.
    1 point
  18. Hi mLipok. You can do something like this: Local $hwinspool = DllOpen("winspool.drv") Local $bRet = DllCall($hwinspool, "bool", "GetDefaultPrinterW", "ptr", 0, "dword*", 0) Local $pcchBuffer = $bRet[2] Local $tBuffer = DllStructCreate("wchar[" & $pcchBuffer & "]") Local $pBuffer = DllStructGetPtr($tBuffer, 1) $bRet = DllCall($hwinspool, "bool", "GetDefaultPrinterW", "ptr", $pBuffer, "dword*", $pcchBuffer) Local $sPrinter = DllStructGetData($tBuffer, 1) MsgBox(0, $pcchBuffer, "Default Printer Name: " & $sPrinter) $bRet = DllCall($hwinspool, "bool", "OpenPrinterW", "wstr", $sPrinter, "handle*", 0, "ptr", 0) Local $hPrinter = $bRet[2] MsgBox(0, "Printer Handle:", $hPrinter) $bRet = DllCall($hwinspool, "bool", "ClosePrinter", "handle", $hPrinter) DllClose($hwinspool) Saludos
    1 point
  19. Easier way: $String = BinaryToString(StringToBinary($String), 4)
    1 point
×
×
  • Create New...