Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/22/2022 in all areas

  1. Yeap that is again one of those exceptions. I've made several changes under the hood which should now also fix this one. It also contains a fix for another minor issue with directive lines. It is available in the Beta directory. Jos
    2 points
  2. Use glyphosate sparingly, it's bad for environment!
    2 points
  3. Nine

    Screen scraping

    My UDF always starts at 0,0. You can manipulate (resize, enhance, etc) the bitmap result (see _GetScreen_GetBitMap) with GDI+ in any way you want...
    1 point
  4. @TheAutomator the following script takes about 10ms to run, because of the Sleep(10) instruction so the condition is checked only twice. Also, there is no value from Sleep(1) to Sleep(9) in AutoIt, the minimum is Sleep(10) ms Local $i = 0, $hTimer = TimerInit() While $i < 1     $i += 1      Sleep(10) WEnd ConsoleWrite(Int(TimerDiff($htimer)) & " ms" & "   i = " & $i & @crlf) Now, without the Sleep(10) instruction, you'll need (at least) the following equivalent code to run in 10ms : Local $i = 0, $hTimer = TimerInit() While $i < 5000     $i += 1 WEnd ConsoleWrite(Int(TimerDiff($htimer)) & " ms" & "   i = " & $i & @crlf) The condition will have to be checked 5000 times (or 10.000 or more, depending on your computer speed) to exit the loop in 10ms, then CPU heats up. So the condition was checked only twice in the 1st example and 5.000+ times in the 2nd example, that's a big difference in 10ms ! Yes, but those tiny sleeps are all = 10ms (not less when AutoIt Sleep is used) which means that Sleep(100) will call ten times this function : DllCall("Kernel32.dll", "none", "Sleep", "dword", 10) Some interesting links below : https://www.autoitscript.com/forum/topic/93496-tutorial-on-dllcall-dllstructs/?do=findComment&comment=698697 https://www.autoitscript.com/forum/topic/177648-sleep-problem/?do=findComment&comment=1275022 https://www.autoitscript.com/forum/topic/143520-sleep-less-than-1/ https://github.com/ellysh/au3src/blob/master/src/utility.cpp Check for the word sleep : 2030        // Set the minimum Sleep accuracy 2031        if (g_oVersion.IsWin9x()) 2032            dwMin = 55; 2033        else 2034            dwMin = 10;
    1 point
  5. You need an RoundUp function for that. one way of doing that is: $input = 7.00004374 ConsoleWrite(_RoundUp( $input, 0) & @CRLF) ConsoleWrite(_RoundUp( $input, 1) & @CRLF) ConsoleWrite(_RoundUp( $input, 2) & @CRLF) ConsoleWrite(_RoundUp( $input, 3) & @CRLF) ConsoleWrite(_RoundUp( $input, 4) & @CRLF) ConsoleWrite(_RoundUp( $input, 5) & @CRLF) ConsoleWrite(_RoundUp( $input, 6) & @CRLF) ConsoleWrite(_RoundUp( $input, 7) & @CRLF) ConsoleWrite(_RoundUp( $input, 8) & @CRLF) ConsoleWrite(_RoundUp( $input, 9) & @CRLF) ConsoleWrite(_RoundUp( $input, 10) & @CRLF) Func _RoundUp( $iValue, $iDec) $oValue = Round($iValue,$iDec) If $oValue < $iValue Then $oValue = Round($iValue + (0.5 / (10 ^ $idec)),$iDec) EndIf return $oValue EndFunc result: 8 7.1 7.01 7.001 7.0001 7.00005 7.000044 7.0000438 7.00004374 7.00004374 7.00004374 Jos
    1 point
  6. Yes it fixed the issue, thanks ! Global Const $hImage = WebP_BitmapCreateGDIp($sFile) ; ok in v0.2.0 (UEZ)
    1 point
  7. I fixed the issue inside the DLL - there was an issue with GdipCreateBitmapFromScan0 referring to the pointer of an array of bytes that contains the pixel data. I updated the DLLs -> download the 7Z archive from post #1 Thanks for testing. You can use also Global Const $hImage = WebP_BitmapCreateGDIp($sFile) to get the GDI+ image which you can save using _GDIPlus_ImageSaveToFile.
    1 point
  8. t0nZ

    _GOLLOG UDF - LOGs made easy

    New version, very light changes, most important the Edit box showing the log (if present) is now "cleaned" when full, and not destroyed and recreated every time (with not so smooth graphics effects in most GUIs..) I use this log system in every project, I often put a small edit control in GUIs as included in the UDF to view in real time the log or in conjunction with another AutoIT script to view the live tail of the log.... So it's so useful to me than I begun to use it as a debugger... 🙄 but this is a problem of mine...😅
    1 point
  9. StringIsDigit, StringIsFloat, StringIsXDigit (link) the behavior of the StringIsFloat function is slightly different EnableExplicit Procedure StringIsDigit(*text) Protected flag = #True, *c.Character = *text If *c = 0 Or *c\c = 0 ProcedureReturn 0 EndIf Repeat If *c\c < '0' Or *c\c > '9' flag = #False Break EndIf *c + SizeOf(Character) Until Not *c\c ProcedureReturn flag EndProcedure Debug StringIsDigit(@"123") Debug StringIsDigit(@"12 3") Debug StringIsDigit(@"") Debug "===" Procedure StringIsFloat(*text) Protected flag = #True, *c.Character = *text, sep = 0, increment = 1 If *c = 0 Or *c\c = 0 ProcedureReturn 0 EndIf Repeat If *c\c >= '0' And *c\c <= '9' ; Debug "-> 0-9" sep = increment ElseIf sep And *c\c = '.' ; Debug "-> ." If sep <= 0 ; Debug "-> Out2" flag = #False Break EndIf sep = 0 increment = -1 Else ; Debug "-> Out" flag = #False Break EndIf *c + SizeOf(Character) Until Not *c\c If sep <> -1 ; Debug "-> Out3" flag = #False EndIf ProcedureReturn flag EndProcedure Debug StringIsFloat(@"1.2") Debug StringIsFloat(@"1..2") Debug StringIsFloat(@"1.2.3") Debug StringIsFloat(@"1") Debug StringIsFloat(@"1.") Debug StringIsFloat(@".1") Debug StringIsFloat(@"qwerty") Debug StringIsFloat(@".") Debug StringIsFloat(@"") Debug "===" Procedure StringIsXDigit(*text) Protected flag = #True, *c.Character = *text If *c = 0 Or *c\c = 0 ProcedureReturn 0 EndIf Repeat If Not ((*c\c >= '0' And *c\c <= '9') Or (*c\c >= 'a' And *c\c <= 'f') Or (*c\c >= 'A' And *c\c <= 'F')) flag = #False Break EndIf *c + SizeOf(Character) Until Not *c\c ProcedureReturn flag EndProcedure Debug StringIsXDigit(@"123") Debug StringIsXDigit(@"FF34FF") Debug StringIsXDigit(@"") Debug StringIsXDigit(@" ")
    1 point
  10. Nine

    Screen scraping

    Added support for Chromium based applications and other that do not support WM_PRINT or WM_PRINTCLIENT messages New version available
    1 point
  11. Nine

    Screen scraping

    @SaeidN Found a way but it will only work on Win 10 (and over I suppose, but I don't have Win 11 to test it). Give me a few min to make the patch available.
    1 point
  12. Have a look at @Melba23 excellent GUIListViewEx UDF GUIListViewEx - New Version 13 Apr 22 - AutoIt Example Scripts - AutoIt Forums (autoitscript.com)
    1 point
  13. Something like this? (I can't really test as I have no Bitlocker encrypted disk) $oShell = ObjCreate("Shell.Application") $sBitLocker = $oShell.Namespace("c:").Self.ExtendedProperty('System.Volume.BitLockerProtection') ConsoleWrite("System.Volume.BitLockerProtection: " & $sBitLocker & @CRLF) Jos
    1 point
  14. I' am not sure if this is a robust test ? Global $hTimer, $bBoolean, $iMax = 5000000 $hTimer = TimerInit() For $i = 1 To $iMax $bBoolean = False Next ConsoleWrite("1. Time = " & TimerDiff($hTimer) & @CRLF) $hTimer = TimerInit() For $i = 1 To $iMax $bBoolean = Not(True) Next ConsoleWrite("2. Time = " & TimerDiff($hTimer) & @CRLF) Variation 2 takes twice as long.
    1 point
  15. You could use functions TimerInit and TimerDiff to check which one is faster: ;A: Global $hTimer $hTimer = TimerInit() while 1 for $item = 0 to ubound($array) - 1 ;do stuff next wend ConsoleWrite("A: " & TimerDiff($hTimer) & @CRLF) ;B: $hTimer = TimerInit() $ubound = ubound($array) - 1 while 1 for $item = 0 to $ubound ;do stuff next wend ConsoleWrite("B: " & TimerDiff($hTimer) & @CRLF)
    1 point
  16. Let me also introduce you my function, I guess it's simple and rather clear. ; Func: _FindLatestLog ; Searches the latest file in specified directory with specified mask ; Example of usage: FindLatestLog (@UserProfileDir & "\AppData\Roaming\Application", "*Waiter*.log") Func _FindLatestLog ($dir, $mask) Local $latestTime = 0, $currentTime = 0 Local $files = _FileListToArray($dir, $mask, 1) If @error = 1 Then ConsoleWrite('Func: FindLog, Error: Path was invalid.' & @CRLF) Return False EndIf If @error = 4 Then ConsoleWrite('Func: FindLog, Error: Log file was not found.' & @CRLF) Return False EndIf For $i = 1 To UBound($files) - 1 $currentFile = $dir & "\" & $files[$i] $currentTime = FileGetTime($currentFile, $FT_MODIFIED, 1) If $currentTime > $latestTime Or $i = 1 Then $latestTime = $currentTime $latestFile = $currentFile EndIf Next ConsoleWrite( "Latest log file: " & $latestFile & ", time modified: " & $latestTime & @CRLF) Return $latestFile EndFunc ;==>_FindLatestLog
    1 point
  17. UEZ

    Simple struct data copying

    You can use memcpy to copy the struct block to another struct: $a = DllStructCreate("struct;byte myData_a[100];endstruct") $b = DllStructCreate("struct;byte myData_b[100];endstruct") $a.myData_a((50)) = 100 $b.myData_b((50)) = 200 ConsoleWrite("Before: " & $b.myData_b((50)) & @CRLF) $aRet = DllCall("MSVCRT.DLL", "ptr:cdecl", "memcpy", "struct*", $b, "struct*", $a, "uint", DllStructGetSize($b)) ConsoleWrite("After: "& $b.myData_b((50)) & @CRLF) ConsoleWrite("Whole struct: " & $b.myData_b & @CRLF)
    1 point
  18. That _NTP_FT function seems not to work behind a proxy. I use this function to get the date which should be accurate. #include <Array.au3> Global $iError = 0, $oErrorChk = ObjEvent("AutoIt.Error", "ObjErrChk") $aResult = GetDateFromINet() If @error Then ConsoleWrite("Error connecting to internet!" & @CRLF) Else _ArrayDisplay($aResult) EndIf Func GetDateFromINet($bProxy = False, $sProxy = "", $sURL = "http://www.google.com/") Local $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") If $iError Then Return SetError(1, 0, 0) If $bProxy Then $oHttp.SetProxy(2, $sProxy) $oHTTP.Open("GET", $sURL, False) $oHTTP.Send() If $iError Then Return SetError(2, 0, 0) Local $sDate = $oHTTP.GetResponseHeader("Date") Local $sYear = StringRegExpReplace($sDate, ".+,\s*\d+\s*\w+\s*(20\d+)\s*.*", "$1") Local $iMonth, $aMonth[13] = [12, "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dez"] $iMonth = _ArraySearch($aMonth, StringRegExpReplace($sDate, ".+,\s*\d+\s*(\w+)\s*20\d+\s*.*", "$1")) Local $iDay, $aDay[8] = [7, "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"] $iDay = StringRegExpReplace($sDate, ".+,\s*(\d+)\s*\w+\s*20\d+\s*.*", "$1") $oHTTP = Null Local $aDate[3] = [$sYear, StringFormat("%02i", $iMonth), StringFormat("%02i", $iDay)] Return $aDate EndFunc Func ObjErrChk() $iError += 1 ConsoleWrite($oErrorChk.scriptline & @CRLF) ConsoleWrite($oErrorChk.windescription & @CRLF) ConsoleWrite($oErrorChk.number & " / " & Hex($oErrorChk.number) & @CRLF) EndFunc
    1 point
  19. #Include <Date.au3> #Include <StructureConstants.au3> #Include <WinAPIMisc.au3> Func _NTP_FT($sServer, $fLocal = True) ;~ http://book.itep.ru/4/44/sntp4416.htm Local $tNTP = DllStructCreate('byte Header[4];byte RootDelay[4];byte RootDispersion[4];byte ReferenceIdentifier[4];byte ReferenceTimestamp[8];byte OriginateTimestamp[8];byte ReceiveTimestamp[8];byte TransmitTimestamp[8];byte KeyIdentifier[4];byte MessageDigest[16]') Local $tPacket = DllStructCreate('byte Packet[68]', DllStructGetPtr($tNTP)) Local $bPacket = 0, $tFT, $tQW, $aSocket, $aResult ;~ 0x1B000000 = 00011011 00000000 00000000 00000000b (LI = 00b VN = 011b Mode = 011b Stratum = 00000000b Poll = 00000000b Precision = 00000000b) $tNTP.Header = Binary('0x1B000000') UDPStartup() If @Error Then Return SetError(1, 0, 0) EndIf $aSocket = UDPOpen(TCPNameToIP($sServer), 123) If @Error Then ; Nothing Else UDPSend($aSocket, $tPacket.Packet) If @Error Then ; Nothing Else While 1 $bPacket = UDPRecv($aSocket, 68, 1) If (@Error) Or ($bPacket) Then ExitLoop EndIf Sleep(100) WEnd EndIf EndIf UDPCloseSocket($aSocket) UDPShutdown() If Not $bPacket Then Return SetError(2, 0, 0) EndIf $tFT = DllStructCreate($tagFILETIME) If $fLocal Then $tQW = DllStructCreate('uint64 Timestamp') Else $tQW = DllStructCreate('uint64 Timestamp', DllStructGetPtr($tFT)) EndIf $tPacket.Packet = $bPacket $tQW.Timestamp = _WinAPI_SwapDWord(DllStructGetData(DllStructCreate('uint', DllStructGetPtr($tNTP, 'TransmitTimestamp')), 1)) * 10000000 + 94354848000000000 If $fLocal Then $aResult = DllCall('kernel32.dll', 'bool', 'FileTimeToLocalFileTime', 'struct*', $tQW, "struct*", $tFT) If (@Error) Or (Not $aResult[0]) Then Return SetError(3, 0, 0) EndIf EndIf Return $tFT EndFunc ;==>_NTP_FT $tFT = _NTP_FT('pool.ntp.org') ConsoleWrite(_Date_Time_FileTimeToStr($tFT) & @CRLF)
    1 point
×
×
  • Create New...