Leaderboard
Popular Content
Showing content with the highest reputation on 10/28/2019 in all areas
-
Create button with logic based on radio group selections
McMuffinTop and one other reacted to Nine for a topic
When you post code please use this tool. Also it makes our life easier if you could provide a runnable script that we could use to advise you. Not like you did with a part of a larger script that we need to modify if we want to test it. In your particular case, you can read the radio button with GUICtrlRead and execute the proper .exe with the requested parameters.2 points -
2 points
-
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.7z2 points
-
Local Proxy Server v1.00
GoogleDude reacted to ripdad for a topic
1 point -
1 point
-
You're welcome! Feel free to reach out to me directly if you ever run into any AutoIt obstacles in the future.1 point
-
@TheXman Thank you. I am glad that I did it. The last 2 days were an intensive course of learning for me and I enjoyed it. I appreciate your help.1 point
-
How to count the number of times an error occurred on a webpage IE11 ?
FrancescoDiMuro reacted to Musashi for a topic
Sometimes it is helpful to reduce the code to the process logic, as @FrancescoDiMuro has already suggested : Global $iErrorCounter = 0 Global $bErrorCondition = False ; *** For this simulation only While $iErrorCounter < 3 ConsoleWrite('> ==> LOOP : $iErrorCounter = ' & $iErrorCounter & @CRLF) ; [CODE...] $bErrorCondition = True ; Simulates --> Verification Failed If $bErrorCondition Then $iErrorCounter += 1 ConsoleWrite('! $iErrorCounter + 1 : $iErrorCounter = ' & $iErrorCounter & @CRLF) Else ; Less than 3 Errors : ; [CODE...] ExitLoop EndIf WEnd if $iErrorCounter = 3 Then MsgBox(0, 'Error : ', 'Limit of three errors reached') ; Insert additional code here EndIf1 point -
Create button with logic based on radio group selections
McMuffinTop reacted to Zedna for a topic
#include <GUIConstantsEx.au3> $gui = GUICreate("Test", 400,300) $cTab_2 = GUICtrlCreateTabItem("OA") GUIStartGroup() $hRadio_QAUS = GUICtrlCreateRadio("US", 35, 50, 100, 35) $hRadio_QAINTL = GUICtrlCreateRadio("INTL", 35, 90, 100, 35) $hRadio_STAGING = GUICtrlCreateRadio("Staging", 35, 130, 100, 35) GUIStartGroup() $hRadio_CHROME = GUICtrlCreateRadio("Chrome", 200, 50, 100, 35) $hRadio_Edge = GUICtrlCreateRadio("Edge", 200, 90, 100, 35) $hRadio_Firefox = GUICtrlCreateRadio("Firefox", 200, 130, 100, 35) $LogInButton = GUICtrlCreateButton("Log In", 20, 210, 320, 35) GUICtrlSetColor($LogInButton, 0x0000ff) GUIStartGroup() $hGroup_SERVER = GUICtrlCreateGroup("Database", 25, 35, 150, 140) $hGroup_BROWSER = GUICtrlCreateGroup("Browser", 190, 35, 145, 140) GUICtrlSetState($hRadio_QAUS, $GUI_CHECKED) GUICtrlSetState($hRadio_CHROME, $GUI_CHECKED) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $LogInButton $DB = '' If IsChecked($hRadio_QAUS) Then $DB = 'US' If IsChecked($hRadio_QAINTL) Then $DB = 'INTL' If IsChecked($hRadio_STAGING) Then $DB = 'Staging' $browser = '' If IsChecked($hRadio_CHROME) Then $browser = 'chrome.exe' If IsChecked($hRadio_Edge) Then $browser = 'edge.exe' If IsChecked($hRadio_Firefox) Then $browser = 'firefox.exe' MsgBox(0,'Result','database: ' & $DB & @CRLF & 'browser: ' & $browser) ;~ ShellExecute($browser, "myurl" & " --new-window --start-fullscreen") EndSwitch WEnd Func IsChecked($control) Return BitAND(GUICtrlRead($control), $GUI_CHECKED) = $GUI_CHECKED EndFunc1 point -
How to add leading zeros
FrancescoDiMuro reacted to TheSaint for a topic
LOL. I love it when code gets taken to the extremes. About time we had some more code contests. 1. The simplest way to do something. 2. The most complex way. 3. The cleverest. 4. The dumbest. P.S. No doubt a good learning experience on occasion.1 point -
Very nice! It looks almost exactly like the solution that I came up with. The only difference between yours and mine is that I round the milliseconds. $iSeconds = Dec(Hex(BinaryMid($xResponse, 41, 4)), $NUMBER_64BIT) ; seconds since 1900-01-01 00:00:00 $iFraction = Dec(Hex(BinaryMid($xResponse, 45, 4)), $NUMBER_64BIT) ; picosec = 1 trillionth of a second (10^-12) $iMsecs = Round($iFraction / 2^32 * 1000) ; round to the nearest integer My full script is below:1 point
-
Instead of using another key, why not use UDF ScreenCapture ? Would make more sense, IMO, take a look at it in help file...1 point
-
@TheXman After several hours of googling, I came up with the following code for calculating fractions of NTP time in millisecs. Your review and comment will be appreciated. $iMilliSecs = Int(Dec(Hex(BinaryMid($xResponse, 45, 4)), $NUMBER_64BIT)/2^32*1000) $iMilliSecs = StringFormat("%03i", $iMilliSecs)1 point
-
Get only number from webpage
FrancescoDiMuro reacted to mikell for a topic
If this 3 or 4 digits number is the first one encountered inside the <td> then this may work $Text = "ab 6 c 1234 def 5678 ghi" Msgbox (0, "", StringRegExpReplace($Text, '.*?(\d{3,4}).*', "$1") ) @FrancescoDiMuro $STR_REGEXPARRAYMATCH returns an array (monday morning is painful)1 point -
terminate is not mandatory but an exit condition increases the comfort . More important is Sleep in the While loop. The actual problem was, as @Nine has indicated, the syntax -> HotKeySet("{PRINTSCREEN}", "snap()")1 point
-
HotKeySet("{PRINTSCREEN}", "snap") HotKeySet("{ESC}", "terminate") While 1 Sleep(10) WEnd Func snap() ConsoleWrite("screenshot taken" & @CRLF) EndFunc ;==>snap Func terminate() Exit EndFunc ;==>terminate1 point
-
1 point
-
@CYCho Thank you for the kind words. Calculating milliseconds from the uint32 Fraction field can seem a bit intimidating at first. Just keep in mind that the Fraction value represents the number of picosecond units. I won't spoil the fun of figuring it out on your own unless you want me to. Feel free to ask for help if you need it (which I'm sure you probably won't).1 point
-
if you know the parent window's handle, you can test each of those duplicates with _WinAPI_GetAncestor to confirm which one is derived from the parent window thus getting the correct handle if this isn't the case add extra details as to what is the class name of those duplicates is it "#32768" by chance? ,if yes then you can easily pull out something from LarsJ function over here1 point
-
@TheXman Your code looks and works like absolutely professional. I will study it. I am glad to see that you started $xRequest with 0x23 because that was what I was thinking after reading your earlier posts. My next goal is to get and set milliseconds as well. I will try and may come back to you for help if I cannot do it alone. Thank you.1 point
-
@CYCho Here's my "quick & dirty" interpretation of the original NTP time request script with a little more error checking, a lot less binary string conversions, and a lot of extra documentation of each step in case you want to study and modify it for your own purposes. #include <Constants.au3> #include <date.au3> ntp_example() Func ntp_example() Const $NTP_SERVER = "time.windows.com" Const $MY_TZ_OFFSET = -5 ; Timezone offset in hours Local $tBuffer Local $aSocket Local $xRequest = Binary(""), $xResponse = Binary("") Local $hTimeoutTimer Local $iSeconds = 0 ; Create the NTP request using a 48 byte buffer $tBuffer = DllStructCreate("byte[48]") DllStructSetData($tBuffer, 1, 0x23) ; 00 100 011 = LI(0) / VN(4-NTPv4) / Mode(3-Client) ; Copy the buffer to a variable for sending $xRequest = DllStructGetData($tBuffer, 1) ConsoleWrite("DEBUG: Binary request = " & $xRequest & @CRLF) ; Send NTP request UDPStartup() If @error Then Exit MsgBox($MB_ICONERROR, "ERROR", "UDPStartup failed - @error = " & @error) OnAutoItExitRegister("udp_shutdown") ; Do UDPShutdown upon exit $aSocket = UDPOpen(TCPNameToIP($NTP_SERVER), 123) If @error Then Exit MsgBox($MB_ICONERROR, "ERROR", "UDPOpen failed - @error = " & @error) UDPSend($aSocket, $xRequest) If @error Then Exit MsgBox($MB_ICONERROR, "ERROR", "UDPSend failed - @error = " & @error) ; Receive NTP response $hTimeoutTimer = TimerInit() Do If TimerDiff($hTimeoutTimer) > 2000 Then ExitLoop ; If no response within 2 seconds, then exit the loop $xResponse = UDPRecv($aSocket, DllStructGetSize($tBuffer), $UDP_DATA_BINARY) If @error Then Exit MsgBox($MB_ICONERROR, "ERROR", "UDPRecv failed - @error = " & @error) Until $xResponse <> Binary("") ConsoleWrite("DEBUG: Binary response = " & Binary($xResponse) & @CRLF) ; Close the socket UDPCloseSocket($aSocket) ; If the request timed out, exit with a message If $xResponse = Binary("") Then Exit MsgBox($MB_ICONERROR, "ERROR", "UDPRecv timed out") ; Get & display timestamp ; - UTC timestamp is taken from xmit timestamp in NTP response ; - Xmit timestamp is a big-endian, uint32, at binary position 41 ; - Xmit timestamp represents the number of seconds since 1900-01-01 00:00:00 $iSeconds = Dec(Hex(BinaryMid($xResponse, 41, 4)), $NUMBER_64BIT) ConsoleWrite(StringFormat("DEBUG: Xmit timestamp = 0x%s (%s)", Hex(BinaryMid($xResponse, 41, 4)), $iSeconds) & @CRLF) ConsoleWrite("INFO: UTC date/time = " & _DateAdd("s", $iSeconds, "1900/01/01 00:00:00") & @CRLF) ConsoleWrite("INFO: Local date/time = " & _DateAdd("s", $iSeconds + (3600 * $MY_TZ_OFFSET), "1900/01/01 00:00:00") & @CRLF) EndFunc Func udp_shutdown() UDPShutdown() EndFunc1 point
-
Creating a "brushed up" Task Scheduler UDF?
seadoggie01 reacted to water for a topic
Version 1.1.0.0 released Changelog can be found on the download page and the history in the ZIP file. For download please see my signature below. Please play with this version and tell me what doesn't work or is missing!1 point -
Update system time based on NTP server time
FrancescoDiMuro reacted to TheXman for a topic
You're quite welcome. I love AutoIt and have used it for over 12 years. If I were going to choose a language to learn, at an age well over 60, I would have chosen AutoIt too. Kudos to you!1 point -
AutoIt Package Manager
seadoggie01 reacted to genius257 for a topic
Status update. I've been stuck on a host for the package registry, and finally found a solution (at least for now), thanks to the introduction of GitHub Actions. Currently the plan is only to support GitHub hosted repositories (represent packages). The package manager solution I've started to implement is heavily inspired by NPM-cli and yarn package manager. I plan on finishing initial code for the install command today, and pusing it to the au3pm repository, if anyone is interested in giving feedback or just for looking into it . Initial install command will only support getting: custom github repo/commit au3pm package with semantic versioning support local packages I will be happy to explain anything I've done so far, but i remind you that this is in the alpha stage so nothing is set in stone. Links: au3pm repository au3pm package registry (currently does nothing) au3pm dev package registry (currently used for the alpha testing with au3pm)1 point -
The query command is available only in the native system32 folder (c:windowssystem32). If you are using a x64 Windows and a x86 script, then try to set the full path to the command, using the sysnative folder. Local $cmd = "c:\windows\sysnative\query session"1 point