Leaderboard
Popular Content
Showing content with the highest reputation on 11/19/2019 in all areas
-
How do i get the .EXE name of the active window
Professor_Bernd and one other reacted to Jos for a topic
-or- ; Retrieve the handle of the Notepad window using the classname of Notepad. Local $hWnd = WinGetHandle("[ACTIVE]") ; Retrieve the identifier of the thread and pass a variable to the $iPID parameter to store the PID. Local $iPID = 0 Local $iThread = _WinAPI_GetWindowThreadProcessId($hWnd, $iPID) ; Display the process thread, PIDof, processname and processfilename ConsoleWrite(' Process thread:' & $iThread & ' Process ID (PID): ' & $iPID & " Processname:" & _WinAPI_GetProcessName($iPID) & " filename:" & _WinAPI_GetProcessFileName($iPID) & @CRLF) Jos2 points -
ToDo Items In script
seadoggie01 and one other reacted to Jos for a topic
I assume this is in a .au3 file? I have hardcoded the #Region/#EndRegion logic in au3lexer to make the remaining part a "Comment" and use that Format. To give the "#todo line" the same color as #Region, you just add it to this line in autoit3wrapper.keywords.properties: au3.keywords.special=#endregion #forcedef #forceref #ignorefunc #pragma #region #todo Jos2 points -
IPC UDF via FileMapping (2018.04.04)
Andreik reacted to argumentum for a topic
I was in need of an IPC (Interprocess communication) between system, admin and user levels, and ended up writing this UDF to suit my wantings. Hope you find it useful too. Works from WinXP/Server2003 to the now current Win10/Server2016. It communicates between any mix of x32, x64, Admin, User. In the zip file, there is the UDF and an example: FMIPC(v0.2018.04.04).zip Special thanks to @RTFC for the help in the support forum1 point -
Use _FileListToArrayRec (<path>, "filename*.*, 1) Use _ArraySort to sort by name or use FileGetTime to find the latest version first.1 point
-
RegExp Multiline Comments
seadoggie01 reacted to jchd for a topic
Would that fit? Local $s = "#include <Inet.au3>" & @CRLF & _ "#ToDo: This is a really long explanation about something _" & @CRLF & _ "# that is very in-depth and needs to take up a lot of _" & @CRLF & _ "# space in a ToDo comment" & @CRLF & _ 'Global $variables = "Bad"' & @CRLF & _ "#ToDo: This is another long explanation about something _" & @CRLF & _ "# that is very in-depth and needs to take up a lot of space in a ToDo comment" & @CRLF & _ "#include <IE.au3>" Local $aToDo = StringRegExp($s, "(?im)^\h*(#todo:(?:.* +_\R)*(?:.* *\R))", 3) For $c In $aToDo ConsoleWrite($c & @LF) Next1 point -
As water said + previous versions can be downloaded from here https://www.autoitscript.com/autoit3/files/archive/autoit/1 point
-
The AutoIt history can be found here: https://www.autoitscript.com/autoit3/docs/history.htm1 point
-
ToDo Items In script
mLipok reacted to seadoggie01 for a topic
One of my favorite things about coding in other languages/IDEs is the ability to put a ToDo comment in to remind myself to do something later that isn't important yet. Like when I run a script once a month and I need to manually change the column in Excel each time. Or something that I want to fix some other day. So I've been exploring LUA and SciTE and managed to add some highlighting to it with this: #~ SciTEUser.properties ~# # #~ Make "#ToDo" a "special" keyword # keywords6.$(au3)=#todo $(au3.keywords.special) $(autoit3wrapper.keywords.special) Which makes it look like the middle one: I would really like to seperate it from the other keywords if possible to make it stand out even more since I could add different background then. I'm also curious why #Region has a secondary green color as all of the text following it and if it would be possible to mimic that with #ToDo (Sorry if this doesn't go here, but I thought since it related to SciTE more than AutoIt it should)1 point -
GOLGRILL a lot of tasty BUTTONS on a GRILL
coffeeturtle reacted to t0nZ for a topic
Often I need to create a panel to monitor a lot of things (users, files, items etc) so I use this piece of code to create a dynamic grid of buttons. The number of buttons is variable, and it's related to the size of the gui, the size of the buttons and the distance between buttons. Every "button" is a set of three with a real button stacked on the top of two labels, imagine reading a .CSV file or an array or a database and displaying all the things using the labels (Text and COLOR too) and clickin' on the relative button you can call further info on the item or call a particular function. So you can decide the number of the buttons, the width of the buttons, and also the distance between buttons. It's quick and dirty, simple and very improvable (I know..) so fell free to play with the code. ;TEST ;GOL-Grill ;Grill test/template ; (c) 2019 NSC ; V.0.6 #Region ;************ Includes ************ #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <EditConstants.au3> #include <ProgressConstants.au3> #include <_GOLLOG.au3>; NSC first UDF #EndRegion ;************ Includes ************ Dim $agButton[1] Global $ButtonU, $rProgress, $form1, $labeltot, $ntotButtonS ; the number of buttons is variable based on the guisize, the button size and button distance, three examples.... ;Global $guiwidth = 850, $guiheight = 500, $buttonW = 150, $buttonHDistance = 10, $buttonVDistance = 20 ; SMALL GUI / BIG BUTTONS <- try it ! Global $guiwidth = 1500, $guiheight = 700, $buttonW = 90 , $buttonHDistance = 29, $buttonVDistance = 3; BIG GUI / SMALL BUTTONS ;Global $guiwidth = 1200, $guiheight = 800, $buttonW = 300, $buttonHDistance = 30, $buttonVDistance = 7; last two variables are horizontal and vertical distance between buttons Global $ver = "V.0.6" Gollog(">>>>> START") Dim $aResult[11] = [10, "a", "b", "c", "d", "e", "f", "g", "h", "i", "j"] ; this is an example, it can be an array, a DB, a .text file read in real time. Gui() Gollog("start analyzing...") Monitor() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE CLOSEClicked() Exit Case $ButtonU Monitor() Case Else For $i = 1 To $ntotButtonS If $nMsg = $agButton[$i] Then $Bhit = GUICtrlRead($agButton[$i]) infoB($Bhit) EndIf Next EndSwitch WEnd Func Gui() $form1 = GUICreate("Buttons on a grill " & $ver & " (c) NSC 2019", $guiwidth, $guiheight, 90, 10) $ButtonU = GUICtrlCreateButton("Update", 2, 2, 170, 50) $labeltot = GUICtrlCreateLabel("Total found", 5, 55) $Gollogedit = GUICtrlCreateEdit("", 2, $guiheight - 255, 180, 250, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN, $WS_BORDER)) $rProgress = GUICtrlCreateProgress($guiwidth - 18, 5, 16, $guiheight - 7, BitOR($PBS_SMOOTH, $PBS_VERTICAL, $WS_BORDER)) GUICtrlSetColor(-1, 0x00FF00) GUICtrlSetBkColor(-1, 0x000000) GUISetState(@SW_SHOW) EndFunc ;==>Gui Func Monitor() GUIDelete($form1) Gui() $leftSTART = 186 ;left align $topSTART = 5 ;start from top $lineDOWN = 45 + $buttonVDistance ; vertical line distance 45 is buttons very near $extraHSTEP = 3 ; extra line distance $buttonSEMIH = 15 ; height of one of the 3 vertical impiled semibuttons $separatorSEMIH = 2 ;vertical distance between 3 semibuttons $separatorW = 2 ;aux horizontal distance ;---------- derived measures $rightLIMIT = $guiwidth - 123 ; right limit befor Carriage Return $leftINCREMENT = $buttonHDistance + $buttonW ; horizontal increment button after button $leftSTEP = $leftSTART ;incremental horizontal $topSTEP = $topSTART ;incremental vertical $foundB = $aResult[0] GUICtrlSetData($labeltot, "Found n°" & $foundB) $ntotButtonS = 0 $nomorebuttons = 0 For $i = 1 To $foundB Local $itemFound = $aResult[$i] ;\TA1000 Gollog($itemFound) GUICtrlCreateGroup('', $leftSTEP, $topSTEP - 3, $buttonW + 3, 50) ;______first-----------------------------_______line___________________UNO________11111_____\\\\\\\\\\------------ Local $textbutton = "button n°" & $i _ArrayAdd($agButton, GUICtrlCreateButton($textbutton, $leftSTEP + $separatorSEMIH, $topSTEP + $extraHSTEP, $buttonW, $buttonSEMIH, $BS_flat)) GUICtrlSetBkColor(-1, 0xccffcc) ;green, sort of GUICtrlSetFont(-1, 7, -1, -1, 'verdana') GUICtrlSetColor(-1, 0x000000) ;___second__________line___________________DUE ________222222-------------------------------------------------------------------- Local $textLINE2 = $itemFound GUICtrlCreateLabel($textLINE2, $leftSTEP + $separatorW, $topSTEP + $buttonSEMIH + $separatorSEMIH, $buttonW, $buttonSEMIH, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, 0xD2D7A8) GUICtrlSetFont(-1, 7, -1, -1, 'verdana') GUICtrlSetColor(-1, 0x000000) ; __third______line________tre___________________________________________________________333333-3333333-333333333-333333-33333-33333-3333-------------------------------- Local $textLINE3 = "line3" GUICtrlCreateLabel($textLINE3, $leftSTEP + $separatorW, $topSTEP + $buttonSEMIH + $buttonSEMIH + $separatorSEMIH, $buttonW, $buttonSEMIH, BitOR($SS_CENTER, $SS_CENTERIMAGE)) ; NSC modify GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetFont(-1, 7, -1, -1, 'verdana') GUICtrlSetColor(-1, 0x000000) $ntotButtonS += 1 GUICtrlSetData($rProgress, (100 * $ntotButtonS / $foundB)) If $leftSTEP + $buttonW < $rightLIMIT Then ; $leftSTEP += $leftINCREMENT ;53 Else $leftSTEP = $leftSTART $topSTEP += $lineDOWN If $topSTEP >= $guiheight - 50 Then $nomorebuttons = 1 Gollog("displayed " & $ntotButtonS & " buttons") Gollog("NO more buttons !") EndIf EndIf Sleep(100) ; REMOVE is only for demo Next While $nomorebuttons = 0 ; draw empty buttons (nice to do) $ntotButtonS += 1 _ArrayAdd($agButton, GUICtrlCreateButton("B-" & $ntotButtonS, $leftSTEP + $separatorSEMIH, $topSTEP + $extraHSTEP, $buttonW, $buttonSEMIH, $BS_flat)) If $leftSTEP + $buttonW < $rightLIMIT Then ; $leftSTEP += $leftINCREMENT Else $leftSTEP = $leftSTART $topSTEP += $lineDOWN If $topSTEP >= $guiheight - 50 Then $nomorebuttons = 1 Gollog("displayed " & $ntotButtonS & " buttons") Gollog("NO more buttons !") EndIf EndIf WEnd GUISetState(@SW_SHOW) EndFunc ;==>Monitor Func infoB($Bhit) ; this function act on the pressed button, it's an example so assign the task you need. gollog("infoB -> " & $Bhit) EndFunc ;==>infoB Func CLOSEClicked() MsgBox(64, "exit", "program exiting", 1) Gollog("<---STOP") Exit EndFunc ;==>CLOSEClicked You will need also the Include from this post for the LOG (Gollog) instructions, but you can also just remove the gollog and the EDIT box. Look at the screenshot, It's from an APP made using this code. 21/11/2019 V.0.6 Script lightly updated with better management of buttons size and distance.1 point -
This week there have been some posts regarding use of compiled code in AutoIt through dll files and through C# and VB code via .NET. Use of compiled code is based, among other things, on Variants and Safearrays. This is an opportunity to distribute the latest updated version of these UDFs: Variant.au3 and SafeArray.au3. Variants and Safearrays are also used in UI Automation threads (Framework, UIASpy, Using) and in AutoItObject. In addition, references to these UDFs can be found in quite a number of posts. If you search for the UDFs it can be difficult to find the newest version. Hence this thread. Variant.au3: #include-once ; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ; Copied from AutoItObject.au3 by the AutoItObject-Team: monoceres, trancexx, Kip, ProgAndy ; https://www.autoitscript.com/forum/index.php?showtopic=110379 Global Const $tagVARIANT = "word vt;word r1;word r2;word r3;ptr data; ptr" ; The structure takes up 16/24 bytes when running 32/64 bit ; Space for the data element at the end represents 2 pointers ; This is 8 bytes running 32 bit and 16 bytes running 64 bit Global Const $VT_EMPTY = 0 ; 0x0000 Global Const $VT_NULL = 1 ; 0x0001 Global Const $VT_I2 = 2 ; 0x0002 Global Const $VT_I4 = 3 ; 0x0003 Global Const $VT_R4 = 4 ; 0x0004 Global Const $VT_R8 = 5 ; 0x0005 Global Const $VT_CY = 6 ; 0x0006 Global Const $VT_DATE = 7 ; 0x0007 Global Const $VT_BSTR = 8 ; 0x0008 Global Const $VT_DISPATCH = 9 ; 0x0009 Global Const $VT_ERROR = 10 ; 0x000A Global Const $VT_BOOL = 11 ; 0x000B Global Const $VT_VARIANT = 12 ; 0x000C Global Const $VT_UNKNOWN = 13 ; 0x000D Global Const $VT_DECIMAL = 14 ; 0x000E Global Const $VT_I1 = 16 ; 0x0010 Global Const $VT_UI1 = 17 ; 0x0011 Global Const $VT_UI2 = 18 ; 0x0012 Global Const $VT_UI4 = 19 ; 0x0013 Global Const $VT_I8 = 20 ; 0x0014 Global Const $VT_UI8 = 21 ; 0x0015 Global Const $VT_INT = 22 ; 0x0016 Global Const $VT_UINT = 23 ; 0x0017 Global Const $VT_VOID = 24 ; 0x0018 Global Const $VT_HRESULT = 25 ; 0x0019 Global Const $VT_PTR = 26 ; 0x001A Global Const $VT_SAFEARRAY = 27 ; 0x001B Global Const $VT_CARRAY = 28 ; 0x001C Global Const $VT_USERDEFINED = 29 ; 0x001D Global Const $VT_LPSTR = 30 ; 0x001E Global Const $VT_LPWSTR = 31 ; 0x001F Global Const $VT_RECORD = 36 ; 0x0024 Global Const $VT_INT_PTR = 37 ; 0x0025 Global Const $VT_UINT_PTR = 38 ; 0x0026 Global Const $VT_FILETIME = 64 ; 0x0040 Global Const $VT_BLOB = 65 ; 0x0041 Global Const $VT_STREAM = 66 ; 0x0042 Global Const $VT_STORAGE = 67 ; 0x0043 Global Const $VT_STREAMED_OBJECT = 68 ; 0x0044 Global Const $VT_STORED_OBJECT = 69 ; 0x0045 Global Const $VT_BLOB_OBJECT = 70 ; 0x0046 Global Const $VT_CF = 71 ; 0x0047 Global Const $VT_CLSID = 72 ; 0x0048 Global Const $VT_VERSIONED_STREAM = 73 ; 0x0049 Global Const $VT_BSTR_BLOB = 0xFFF Global Const $VT_VECTOR = 0x1000 Global Const $VT_ARRAY = 0x2000 Global Const $VT_BYREF = 0x4000 Global Const $VT_RESERVED = 0x8000 Global Const $VT_ILLEGAL = 0xFFFF Global Const $VT_ILLEGALMASKED = 0xFFF Global Const $VT_TYPEMASK = 0xFFF ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ;Global Const $tagVARIANT = "word vt;word r1;word r2;word r3;ptr data; ptr" ; The structure takes up 16/24 bytes when running 32/64 bit ; Space for the data element at the end represents 2 pointers ; This is 8 bytes running 32 bit and 16 bytes running 64 bit #cs DECIMAL structure https://msdn.microsoft.com/en-us/library/windows/desktop/ms221061(v=vs.85).aspx From oledb.h: typedef struct tagDEC { USHORT wReserved; ; vt, 2 bytes union { ; r1, 2 bytes struct { BYTE scale; BYTE sign; }; USHORT signscale; }; ULONG Hi32; ; r2, r3, 4 bytes union { ; data, 8 bytes struct { #ifdef _MAC ULONG Mid32; ULONG Lo32; #else ULONG Lo32; ULONG Mid32; #endif }; ULONGLONG Lo64; }; } DECIMAL; #ce Global Const $tagDEC = "word wReserved;byte scale;byte sign;uint Hi32;uint Lo32;uint Mid32" ; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ; Variant functions ; Copied from AutoItObject.au3 by the AutoItObject-Team: monoceres, trancexx, Kip, ProgAndy ; https://www.autoitscript.com/forum/index.php?showtopic=110379 ; #FUNCTION# ==================================================================================================================== ; Name...........: VariantClear ; Description ...: Clears the value of a variant ; Syntax.........: VariantClear($pvarg) ; Parameters ....: $pvarg - the VARIANT to clear ; Return values .: Success - 0 ; Failure - nonzero ; Author ........: Prog@ndy ; Modified.......: ; Remarks .......: ; Related .......: VariantFree ; Link ..........: http://msdn.microsoft.com/en-us/library/ms221165.aspx ; Example .......: ; =============================================================================================================================== Func VariantClear($pvarg) ; Author: Prog@ndy Local $aCall = DllCall("OleAut32.dll", "long", "VariantClear", "ptr", $pvarg) If @error Then Return SetError(1, 0, 1) Return $aCall[0] EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: VariantCopy ; Description ...: Copies a VARIANT to another ; Syntax.........: VariantCopy($pvargDest, $pvargSrc) ; Parameters ....: $pvargDest - Destionation variant ; $pvargSrc - Source variant ; Return values .: Success - 0 ; Failure - nonzero ; Author ........: Prog@ndy ; Modified.......: ; Remarks .......: ; Related .......: VariantRead ; Link ..........: http://msdn.microsoft.com/en-us/library/ms221697.aspx ; Example .......: ; =============================================================================================================================== Func VariantCopy($pvargDest, $pvargSrc) ; Author: Prog@ndy Local $aCall = DllCall("OleAut32.dll", "long", "VariantCopy", "ptr", $pvargDest, 'ptr', $pvargSrc) If @error Then Return SetError(1, 0, 1) Return $aCall[0] EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: VariantInit ; Description ...: Initializes a variant. ; Syntax.........: VariantInit($pvarg) ; Parameters ....: $pvarg - the VARIANT to initialize ; Return values .: Success - 0 ; Failure - nonzero ; Author ........: Prog@ndy ; Modified.......: ; Remarks .......: ; Related .......: VariantClear ; Link ..........: http://msdn.microsoft.com/en-us/library/ms221402.aspx ; Example .......: ; =============================================================================================================================== Func VariantInit($pvarg) ; Author: Prog@ndy Local $aCall = DllCall("OleAut32.dll", "long", "VariantInit", "ptr", $pvarg) If @error Then Return SetError(1, 0, 1) Return $aCall[0] EndFunc ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Func VariantChangeType( $pVarDest, $pVarSrc, $wFlags, $vt ) Local $aRet = DllCall( "OleAut32.dll", "long", "VariantChangeType", "ptr", $pVarDest, "ptr", $pVarSrc, "word", $wFlags, "word", $vt ) If @error Then Return SetError(1,0,1) Return $aRet[0] EndFunc Func VariantChangeTypeEx( $pVarDest, $pVarSrc, $lcid, $wFlags, $vt ) Local $aRet = DllCall( "OleAut32.dll", "long", "VariantChangeTypeEx", "ptr", $pVarDest, "ptr", $pVarSrc, "word", $lcid, "word", $wFlags, "word", $vt ) If @error Then Return SetError(1,0,1) Return $aRet[0] EndFunc Func VarAdd( $pVarLeft, $pVarRight, $pVarResult ) Local $aRet = DllCall( "OleAut32.dll", "long", "VarAdd", "ptr", $pVarLeft, "ptr", $pVarRight, "ptr", $pVarResult ) If @error Then Return SetError(1,0,1) Return $aRet[0] EndFunc Func VarSub( $pVarLeft, $pVarRight, $pVarResult ) Local $aRet = DllCall( "OleAut32.dll", "long", "VarSub", "ptr", $pVarLeft, "ptr", $pVarRight, "ptr", $pVarResult ) If @error Then Return SetError(1,0,1) Return $aRet[0] EndFunc ; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ; BSTR (basic string) functions ; Copied from AutoItObject.au3 by the AutoItObject-Team: monoceres, trancexx, Kip, ProgAndy ; https://www.autoitscript.com/forum/index.php?showtopic=110379 Func SysAllocString( $str ) Local $aRet = DllCall( "OleAut32.dll", "ptr", "SysAllocString", "wstr", $str ) If @error Then Return SetError(1, 0, 0) Return $aRet[0] EndFunc Func SysFreeString( $pBSTR ) If Not $pBSTR Then Return SetError(1, 0, 0) DllCall( "OleAut32.dll", "none", "SysFreeString", "ptr", $pBSTR ) If @error Then Return SetError(2, 0, 0) EndFunc Func SysReadString( $pBSTR, $iLen = -1 ) If Not $pBSTR Then Return SetError(1, 0, "") If $iLen < 1 Then $iLen = SysStringLen( $pBSTR ) If $iLen < 1 Then Return SetError(2, 0, "") Return DllStructGetData( DllStructCreate( "wchar[" & $iLen & "]", $pBSTR ), 1 ) EndFunc Func SysStringLen( $pBSTR ) If Not $pBSTR Then Return SetError(1, 0, 0) Local $aRet = DllCall( "OleAut32.dll", "uint", "SysStringLen", "ptr", $pBSTR ) If @error Then Return SetError(2, 0, 0) Return $aRet[0] EndFunc ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Func VarBstrCat( $pBSTRLeft, $pBSTRRight, $pBSTRResult ) Local $aRet = DllCall( "OleAut32.dll", "long", "VarBstrCat", "ptr", $pBSTRLeft, "ptr", $pBSTRRight, "ptr", $pBSTRResult ) If @error Then Return SetError(1,0,1) Return $aRet[0] EndFunc SafeArray.au3: #include-once Global Const $tagSAFEARRAYBOUND = _ "ulong cElements;" & _ ; The number of elements in the dimension. "long lLbound;" ; The lower bound of the dimension. Global Const $tagSAFEARRAY = _ "ushort cDims;" & _ ; The number of dimensions. "ushort fFeatures;" & _ ; Flags, see below. "ulong cbElements;" & _ ; The size of an array element. "ulong cLocks;" & _ ; The number of times the array has been locked without a corresponding unlock. "ptr pvData;" & _ ; The data. $tagSAFEARRAYBOUND ; One $tagSAFEARRAYBOUND for each dimension. ; fFeatures flags Global Const $FADF_AUTO = 0x0001 ; An array that is allocated on the stack. Global Const $FADF_STATIC = 0x0002 ; An array that is statically allocated. Global Const $FADF_EMBEDDED = 0x0004 ; An array that is embedded in a structure. Global Const $FADF_FIXEDSIZE = 0x0010 ; An array that may not be resized or reallocated. Global Const $FADF_RECORD = 0x0020 ; An array that contains records. When set, there will be a pointer to the IRecordInfo interface at negative offset 4 in the array descriptor. Global Const $FADF_HAVEIID = 0x0040 ; An array that has an IID identifying interface. When set, there will be a GUID at negative offset 16 in the safearray descriptor. Flag is set only when FADF_DISPATCH or FADF_UNKNOWN is also set. Global Const $FADF_HAVEVARTYPE = 0x0080 ; An array that has a variant type. The variant type can be retrieved with SafeArrayGetVartype. Global Const $FADF_BSTR = 0x0100 ; An array of BSTRs. Global Const $FADF_UNKNOWN = 0x0200 ; An array of IUnknown*. Global Const $FADF_DISPATCH = 0x0400 ; An array of IDispatch*. Global Const $FADF_VARIANT = 0x0800 ; An array of VARIANTs. Global Const $FADF_RESERVED = 0xF008 ; Bits reserved for future use. ; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ; Safearray functions ; Copied from AutoItObject.au3 by the AutoItObject-Team: monoceres, trancexx, Kip, ProgAndy ; https://www.autoitscript.com/forum/index.php?showtopic=110379 Func SafeArrayCreate($vType, $cDims, $tsaBound) ; Author: Prog@ndy Local $aCall = DllCall("OleAut32.dll", "ptr", "SafeArrayCreate", "dword", $vType, "uint", $cDims, "struct*", $tsaBound) If @error Then Return SetError(1, 0, 0) Return $aCall[0] EndFunc Func SafeArrayDestroy($pSafeArray) ; Author: Prog@ndy Local $aCall = DllCall("OleAut32.dll", "int", "SafeArrayDestroy", "ptr", $pSafeArray) If @error Then Return SetError(1, 0, 1) Return $aCall[0] EndFunc Func SafeArrayAccessData($pSafeArray, ByRef $pArrayData) ; Author: Prog@ndy Local $aCall = DllCall("OleAut32.dll", "int", "SafeArrayAccessData", "ptr", $pSafeArray, "ptr*", 0) If @error Then Return SetError(1, 0, 1) $pArrayData = $aCall[2] Return $aCall[0] EndFunc Func SafeArrayUnaccessData($pSafeArray) ; Author: Prog@ndy Local $aCall = DllCall("OleAut32.dll", "int", "SafeArrayUnaccessData", "ptr", $pSafeArray) If @error Then Return SetError(1, 0, 1) Return $aCall[0] EndFunc Func SafeArrayGetUBound($pSafeArray, $iDim, ByRef $iBound) ; Author: Prog@ndy Local $aCall = DllCall("OleAut32.dll", "int", "SafeArrayGetUBound", "ptr", $pSafeArray, "uint", $iDim, "long*", 0) If @error Then Return SetError(1, 0, 1) $iBound = $aCall[3] Return $aCall[0] EndFunc Func SafeArrayGetLBound($pSafeArray, $iDim, ByRef $iBound) ; Author: Prog@ndy Local $aCall = DllCall("OleAut32.dll", "int", "SafeArrayGetLBound", "ptr", $pSafeArray, "uint", $iDim, "long*", 0) If @error Then Return SetError(1, 0, 1) $iBound = $aCall[3] Return $aCall[0] EndFunc Func SafeArrayGetDim($pSafeArray) Local $aResult = DllCall("OleAut32.dll", "uint", "SafeArrayGetDim", "ptr", $pSafeArray) If @error Then Return SetError(1, 0, 0) Return $aResult[0] EndFunc ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Func SafeArrayCopy( $psaSource, ByRef $psaDestination ) Local $aRet = DllCall( "OleAut32.dll", "int", "SafeArrayCopy", "ptr", $psaSource, "ptr*", 0 ) If @error Then Return SetError(1,0,1) $psaDestination = $aRet[2] Return $aRet[0] EndFunc Func SafeArrayCopyData( $psaSource, $psaDestination ) Local $aRet = DllCall( "OleAut32.dll", "int", "SafeArrayCopyData", "ptr", $psaSource, "ptr", $psaDestination ) If @error Then Return SetError(1,0,1) Return $aRet[0] EndFunc Func SafeArrayCreateEmptyWr( $vType ) Local $tsaBound = DllStructCreate( $tagSAFEARRAYBOUND ) DllStructSetData( $tsaBound, "cElements", 0 ) DllStructSetData( $tsaBound, "lLbound", 0 ) Return SafeArrayCreate( $vType, 0, $tsaBound ) EndFunc Func SafeArrayDestroyData( $pSafeArray ) Local $aRet = DllCall( "OleAut32.dll", "int", "SafeArrayDestroyData", "ptr", $pSafeArray ) If @error Then Return SetError(1,0,1) Return $aRet[0] EndFunc Func SafeArrayGetVartype( $pSafeArray, ByRef $iVartype ) Local $aRet = DllCall( "OleAut32.dll", "int", "SafeArrayGetVartype", "ptr", $pSafeArray, "ptr*", 0 ) If @error Then Return SetError(1,0,1) $iVartype = $aRet[2] Return $aRet[0] EndFunc Func SafeArrayRedim( ByRef $pSafeArray, $tsaBound ) Local $aRet = DllCall( "OleAut32.dll", "int", "SafeArrayRedim", "ptr", $pSafeArray, "struct*", $tsaBound ) If @error Then Return SetError(1,0,1) $pSafeArray = $aRet[1] Return $aRet[0] EndFunc SafeArrayCreateEmptyWr() is a wrapper function to create an empty safearray. It's not a translation of a similar Windows API function. AutoIt arrays are safearrays Note that AutoIt arrays are stored internally as safearrays. AutoIt arrays are accessed through normal AutoIt variables, and a set of operators and functions have been created to manipulate the arrays. This makes AutoIt arrays proprietary arrays that cannot be easily used in other programming languages. Zip-file You need AutoIt 3.3.12 or later. Tested on Windows 7 and Windows 10. Comments are welcome. Let me know if there are any issues. VariantsSafearrays.7z1 point
-
Check if Win10 system is LEGACY or UEFI installed
coffeeturtle reacted to TheDcoder for a topic
@coffeeturtle Very nice. Back when I did it, MBR2GPT did not exist... so I had to go the old route and back up all my important files (I did not have a spare drive back then) and then totally reformat the drive to GPT If I had known better, I would have been using GPT from the start!1 point -
and you do not must to use: Sleep(5000) try this: do Sleep(10) Until ControlCommand("[Class:IEFrame]","","[ClassNN:DirectUIHWND1]","IsVisible", "")1 point
-
Lately, in this forum, there were many questions and problems referring to the use of ie.au3 UDF using the latest version of AutoIt v3.3.14.x. I would like to present the correct usage of the UDF. I hope that it will help many users to prevent problems. #include <ie.au3> #include <MsgBoxConstants.au3> ; STEP 1 ; YOU MUST SET ANY COM ERROR HANDLER IN ONE OF THE FOLLOWING WAY ; STEP 1: CASE 1 ; you should set COM Error Handler Function for ie.au3 UDF _IEErrorHandlerRegister(_User_ErrFunc) ; STEP 1: CASE 2 ; eventually if you not want to recieve additional information ; you can use just the same function without parameter ; _IEErrorHandlerRegister() ; STEP 1: CASE 3 ; or use your own global COM Error Handler ;~ Global $oCOMErrorHandler = ObjEvent("AutoIt.Error", _User_ErrFunc) ; STEP 2 ; if you do not wish to get in Console Output Pane information like the following: ; --> IE.au3 T3.0-2 Error from function _IEAction(click), $_IESTATUS_InvalidDataType ; You can uncomment this following line: ; _IEErrorNotify(False) _Example() Func _Example() ; First lets create some IE Object Local $oIE = _IECreate('google.com') ; you should always check for @error in any function (even you own made) If @error Then MsgBox($MB_ICONERROR, '_IECreate', '@error = ' & @error & @CRLF & '@extended = ' & @extended) ; Set @error when you return from function with Failure Return SetError(1,0,0) Endif ; here we try to get reference to LuckyStrike button Local $oLuckyStrike = _IEGetObjByName($oIE, 'btnI') ; you should always check for @error in any function (even you own made) If @error Then MsgBox($MB_ICONERROR, '_IEGetObjByName', '@error = ' & @error & @CRLF & '@extended = ' & @extended) ; Set @error when you return from function with Failure Return SetError(2,0,0) Endif ; here we try to click LuckyStrike button with previously achieved Object which is a reference to HTML DOM OBJECT in IE Instance _IEAction($oLuckyStrike, 'click') ; you should wait when page is loading _IELoadWait($oIE) ; some user interaction If MsgBox($MB_YESNO, 'Question', 'Do you want to back ?') = $IDYES Then _IEAction($oIE, 'back') EndIf EndFunc ;==>_Example ; User's COM error function. ; After SetUp with ObjEvent("AutoIt.Error", ....) will be called if COM error occurs Func _User_ErrFunc($oError) ; Do anything here. ConsoleWrite(@ScriptFullPath & " (" & $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 ;==>_User_ErrFunc Regards, mLipok1 point
-
Interact with "Save As" dialog
JoeBar reacted to vladtsepesh for a topic
Hi all, I'm trying to download a file as a result of an interrogation to a report server, this means I don't have a direct URL from which to download directly the file. I need to interact with the classic "Save as" dialog box To perform this task I wrote a simple piece of code I'm supposed to work, it could be summarized as follows Local $hWndDwnld=WinActivate("Download del file") Sleep(500) If @error Then ConsoleWrite('WinActivate' & '@error = ' & @error & @CRLF & '@extended = ' & @extended) ConsoleWrite("Wait for download file dialog..." & @CRLF) Local $hWndDwnld=WinWaitActive("Download del file") ConsoleWrite(".. found." & @CRLF) WinActivate($hWndDwnld) Endif ;~ waiting for window ControlSend($hWndDwnld, "", "", "!v") ;~ send ctrl+v WinWait("Salva con nome") WinActivate("Salva con nome") ControlSetText("Salva con nome", "", "[CLASS:ToolbarWindow32; INSTANCE:3]", $dest) Sleep(1500) ControlSetText("Salva con nome","","[CLASS:Edit; INSTANCE:1]","") Sleep(1500) $filename="aReport.csv" ;~ ControlSetText("Salva con nome","&Salva","Edit1", $filename) ControlSetText("Salva con nome","","[CLASS:Edit; INSTANCE:1]", $filename) Sleep(1500) $filename=ControlGetText("Salva con nome","&Salva","Edit1") ConsoleWrite(" --> " & $filename & @CRLF) ControlClick("Salva con nome","","Button1")It's based mostly on this post: https://www.autoitscript.com/forum/topic/134561-automating-the-ie-save-as-file-dialog/ What I'would like to obtain is changing the filename and the directory as in the two variables $filename and $dest. Instead I get the file named as provided by the report server and suggested at first in the SaveAs window and dowloaded in the last folder browsed, to be more clear none of the ControlSetText instructions in the snippet above work. TIA for any help. PS: the script is based on the Italian language settings for the WinOS, for the English language the "Download del file" and "Salva con nome" strings should be replaced by "File Download" and "Save As" respectively.1 point -
It's what the title says, module file player. To be more specific those with .xm extension (Fast Tracker). You don't need any external file for the player, it's capable of doing everything on its own. Special technique of dll subrogation is used to load embedded dll. Go thru code to see what I mean if you are inerested. It's kinda advanced. Very similar to "running dll from memory". It's also experimental so there could be bugs. I included some xm files in the archive. I find one of those the best XM ever written. I won't tell which though. XM Player.zip Btw, available functions for embedded dll are: LoadFromFileLoadFromResource (this one is cool)PlayStopGetTimeGetOrderGetRowFree1 point
-
a little function called _AssembleIt() makes Wards "embedded" FASM-Assembler more embedded. The function is a "wrapper" for all the FASMxxx() and FASMyyy()-stuff. EDIT 03-20-2011: AssembleIt now includes a possibility to show the content of registers, flags,XMM-registers, FPU-registers and the stack during the runtime of the asm-code. Someone called this a "Debugger", it´s really not a debugger, it´s a chaotic piece of a script. */Sry, but i am not be able to put pictures or links in this post/* There are some nice features (i.e. running the asm-code until a register contains a specific content), so it could help sometimes... You can find AssembleIt and an example how to use it here or in the attached zipfile. Have fun! After including the AssembleIt.au3 the Assemblercode can be written like: ;Example for _AssembleIt() ;32 Bit only! #include <AssembleIt.au3> Func _Add_int() ;any functionname, used by _AssembleIt() _("use32") ;32 Bit _("mov eax,dword[esp+4]") ;read 1st parameter in Register EAX=22 _("add eax,dword[esp+8]") ;add 2nd parameter EAX=EAX+33 _("ret") ;Returns result in EAX back to the calling function ;NO STACK CLEANING NECESSARY! EndFunc ;==>_Add_int ;_AssembleIt($Returntype, $Name_of_Func_with_code, $Type1 = "type", $Param1 = 0, $Type2 = "type", $Param2 = 0....up to 20 params) $ret = _AssembleIt("int", "_Add_int", "int", 22, "int", 33) ;thats all^^ MsgBox(0, 'Result _Add_int()', $ret) ;no array returned by _AssembleIt() Syntax check is integrated, and some more. See the examples! If your Assemblercode is running well and you don´t want to drag all the _ASMcode()-functions, AssembleIt.au3, FASM.au3 and MemoryDll.au3 with your script, it is now easy to make a "standalone" Version using a CallWindowProcW-call (which is much faster btw.) If you have a Script: #include <AssembleIt.au3> #include <GDIPlus.au3> ;32Bit only! Func _grayscale() _("use32") ;32Bit! _("mov esi,dword[esp+4]") ;Startadress Bitmapdata (Pixel) _("mov ecx,dword[esp+8]") ;number of Pixel _("mov edi,21845") ;konstant, *21845/2^16 is approximately 1/3 (replaces the slow DIV 3) _("_loop1:") ;until ecx=0 _("mov edx,[esi]") ;load pixel AARRGGBB (RR+GG+BB)/3 = colour grayscale _("mov al,dl") ;lowbyte (BB) Pixel to lowbyte al _("movzx bx,dh") ;highbyte (GG) Pixel to lowbyte of bx (bh is 0) _("shr edx,8") ;shift RR into dh _("add ax,bx") ;BB + GG _("movzx bx,dh") ;highbyte (RR) Pixel to lowbyte of bx (bh ist 0) _("add ax,bx") ;and add: dx=RR+GG+BB _("mul edi") ;ax=ax*21845 *21845/2^16 is about 1/3 _("shr eax,16") ;ax=ax/2^16 in al is now the greyscale colour for RR, GG und BB _("movzx dx,al") ;grayscale to dl, dh = 0 _("shl edx,16") ;grayscale to RR, AA = 0! _("mov dh,al") ;grayscale to GG _("mov dl,al") ;grayscale to BB edx is now 00alalal = grayscale AARRGGBB _("mov [esi],edx") ;write pixel _("add esi,4") ;address next pixel: 4 Byte = 1 dword = 1 Pixel _("sub ecx,1") ;counter (next pixel) _("ja _loop1") ;until ecx=0 ;upper 3 lines are faster than _("loop _loop1") ;until ecx=0 _("ret ") ;return EndFunc ;==>_grayscale $file = FileOpenDialog("Select 24 or 32 Bpp image!", @ScriptDir, "Image (*.jpg;*.bmp)", 1 + 2) if @error then exit _GDIPlus_Startup() $hBitmap = _GDIPlus_BitmapCreateFromFile($file) $iWidth = _GDIPlus_ImageGetWidth($hBitmap) $iHeight = _GDIPlus_ImageGetHeight($hBitmap) $hBitmapData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $iWidth, $iHeight, BitOR($GDIP_ILMREAD, $GDIP_ILMWRITE), $GDIP_PXF32RGB) $Scan = DllStructGetData($hBitmapData, "Scan0") $Stride = DllStructGetData($hBitmapData, "Stride") $tPixelData = DllStructCreate("dword[" & (Abs($Stride * $iHeight)) & "]", $Scan) ;$_ASSEMBLEIT_FLAG = 0 ;after uncomment this line, run the script, and replace the following line with the content of the clipboard, then delete #include <AssembleIt.au3> and the _grayscale()-function $ret=_AssembleIt("ptr","_grayscale","ptr", DllStructGetPtr($tPixelData), "int", $iWidth * $iHeight) ;ptr als Rückgabe, um die hexzahlen schön zu sehen _GDIPlus_BitmapUnlockBits($hBitmap, $hBitmapData) _GDIPlus_ImageSaveToFile($hBitmap, @ScriptDir & "\greyscale.jpg") _GDIPlus_Shutdown() ShellExecute(@ScriptDir & "\greyscale.jpg")uncomment the line "$_ASSEMBLEIT_FLAG = 0" and run the script again._AssembleIt() creates now 3 lines AutoItcode and writes them into the Clipboard. Replace the line "$_ASSEMBLEIT_FLAG = 0" with the content of the clipboard (ctrl+v) and replace the param-variables (types were transfered) with the right ones from the "$ret=_AssembleIt("ptr"....blahblah)". Delete the "#include <AssembleIt.au3>" and the the function _grayscale() to get the following script #include <GDIPlus.au3> ;32Bit only! $file = FileOpenDialog("Select 24 or 32 Bpp image!", @ScriptDir, "Image (*.jpg;*.bmp)", 1 + 2) if @error then exit _GDIPlus_Startup() $hBitmap = _GDIPlus_BitmapCreateFromFile($file) $iWidth = _GDIPlus_ImageGetWidth($hBitmap) $iHeight = _GDIPlus_ImageGetHeight($hBitmap) $hBitmapData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $iWidth, $iHeight, BitOR($GDIP_ILMREAD, $GDIP_ILMWRITE), $GDIP_PXF32RGB) $Scan = DllStructGetData($hBitmapData, "Scan0") $Stride = DllStructGetData($hBitmapData, "Stride") $tPixelData = DllStructCreate("dword[" & (Abs($Stride * $iHeight)) & "]", $Scan) Global $tCodeBuffer = DllStructCreate("byte[61]") ;reserve Memory for opcodes DllStructSetData($tCodeBuffer, 1,"0x8B7424048B4C2408BF555500008B1688D0660FB6DEC1EA086601D8660FB6DE6601D8F7E7C1E810660FB6D0C1E21088C688C2891683C60483E90177D1C3") ;write opcodes into memory $ret=DllCall("user32.dll", "ptr", "CallWindowProcW", "ptr", DllStructGetPtr($tCodeBuffer),"int",DllStructGetPtr($tPixelData), "int", $iWidth * $iHeight,"int",0,"int",0) _GDIPlus_BitmapUnlockBits($hBitmap, $hBitmapData) _GDIPlus_ImageSaveToFile($hBitmap, @ScriptDir & "\greyscale.jpg") _GDIPlus_Shutdown() ShellExecute(@ScriptDir & "\greyscale.jpg")I have written a "tutorial" (unfortunately for you in german language) how to put and get AutoIt-variables into the ASM-code. There are also some examples how to use ASM-variables (VAR db 8 dup(7) ) in the ASM-code without a "org "&FasmGetBasePtr($Fasm), SSE-examples, speedup ASM with LUT and more....please feel free to ask me if you have questions. I am not an Assembler-"crack", but i like to speed up some functions with a little ASM... After i had written this tutorial, i wrote _AssembleIt() . And now i am too lazy to rewrite all FASMxxx()-stuff-examples into _AssembleIt()-style . Apologize.... I see _AssembleIt() as a proof of concept, so i expect your comments/tips/hints/improvements! AssembleIt.zip1 point
-
Here a full memory read example (dll and chip tune completely read from the memory) Download: click me (source code + compiled exe) or source code only (not running as x64 only x32!) Sorry, source code is too long to post and my attachment buffer is nearly full! UEZ1 point