Jump to content

Leaderboard

Popular Content

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

  1. Musashi

    Input background

    Yep , that's what it says in the help, almost impossible to overlook (except by me) .
    2 points
  2. Melba23

    Input background

    Musashi, No so - you can set the $bOnFocus flag to keep the cuebanner visible on focus: #include <GUIConstantsEx.au3> #include <GUIEdit.au3> $hGUI = GUICreate("Test", 500, 500) $cInput1 = GUICtrlCreateInput("", 10, 10, 200, 20) _GUICtrlEdit_SetCueBanner($cInput1, "Visible on focus", True) $cInput2 = GUICtrlCreateInput("", 10, 100, 200, 20) _GUICtrlEdit_SetCueBanner($cInput2, "Vanish on focus") GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd M23
    2 points
  3. TheXman

    Input background

    Like _GUICtrlEdit_SetCueBanner()?
    2 points
  4. JockoDundee

    Input background

    Next time, $bOnFocus
    1 point
  5. mike1950r, This is more elegant, but does rely on "magic numbers": #include <MsgBoxConstants.au3> #include "ExtMsgBox.au3" $sTitle = "Example 1 title" $sMessage = "Example 1 message" $hFlag = BitOR($MB_OKCANCEL, $MB_DEFBUTTON2, $MB_ICONQUESTION) _DialogMessageBox($sTitle, $sMessage, $hFlag) $sTitle = "Example 2 title" $sMessage = "Example 2 message" $hFlag = BitOR($MB_YESNOCANCEL, $MB_DEFBUTTON3, $MB_ICONQUESTION) _DialogMessageBox($sTitle, $sMessage, $hFlag) $sTitle = "Example 3 title" $sMessage = "Example 3 message" $hFlag = BitOR($MB_OK, $MB_DEFBUTTON1, $MB_ICONINFORMATION) _DialogMessageBox($sTitle, $sMessage, $hFlag) $sTitle = "Example 4 title" $sMessage = "Example 4 message" $hFlag = BitOR($MB_OK, $MB_DEFBUTTON1, $MB_ICONWARNING) _DialogMessageBox($sTitle, $sMessage, $hFlag) Func _DialogMessageBox($sTitle, $sMessage, $hFlag) ; Remove all high level flags $hFlag = Mod($hFlag, 4096) ; Determine default button $iDefButton = Floor($hFlag / 256) $hFlag -= 256 * $iDefButton ; Determine icon $iIcon = 16 * Floor($hFlag / 16) $hFlag -= $iIcon ; Determine button text Switch $hFlag Case 0 $sButtonText = "OK" Case 1 $sButtonText = "OK|Cancel" Case 2 $sButtonText = "Abort|Retry|Cancel" Case 3 $sButtonText = "Yes|No|Cancel" Case 4 $sButtonText = "Yes|No" Case 5 $sButtonText = "Retry|Cancel" Case 6 $sButtonText = "Cancel|Try Again|Cancel" EndSwitch ; Add default button flag $iIndex = StringInStr($sButtonText, "|", 2, $iDefButton) If $iIndex Then $sButtonText = StringLeft($sButtonText, $iIndex) & "~" & StringMid($sButtonText, $iIndex + 1) EndIf $iRet = _ExtMsgBox($iIcon, $sButtonText, $sTitle, $sMessage) EndFunc Up to you which you prefer. M23
    1 point
  6. Based on codes in an old AutoIt Forum, I made the following code and it works perfectly. But I have couple of questions on how it works. I have to ask the original writer of this code(@Fzz), but he doesn't seem to be active now. Can someone please let me know the internal workings of this code? I'm especially curious about the meaning of packet sent to the NTP server. I don't know what the 96-byte long hex string with a lot of 0's means. I don't know why the hex string is converted to a decimal character string instead of using the decimal characters to start with. I don't know the benefit of using Call() function over using funtion name followed by (). ;~ Many thanks to @TheXman for his kind guidance. ;~ https://www.autoitscript.com/forum/topic/200643-pulling-time-from-ntp-server/?do=findComment&comment=1439629 #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_AU3Check_Parameters=-w 3 -w 4 -w 5 -w 6 -d #AutoIt3Wrapper_Outfile=NTP_Time_V4.exe #AutoIt3Wrapper_Res_Fileversion=4.0 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #RequireAdmin #include <Constants.au3> #include <Date.au3> Global $hTimeoutTimer = TimerInit() While 1 If Ping("www.google.com") > 0 Then ExitLoop If TimerDiff($hTimeoutTimer) > 120000 Then WriteLog(0, "System has no internet connection") Exit EndIf Sleep(50) WEnd Global $NTP_Server = 'time.google.com', $NTP_Time NTP_GetTime() System_SetTime() Func System_SetTime() ; 2019/10/28 23:09:52.522 ; 12345678901234567890123 Local $m = StringMid($NTP_Time, 6, 2) Local $d = StringMid($NTP_Time, 9, 2) Local $y = StringMid($NTP_Time, 1, 4) Local $h = StringMid($NTP_Time, 12, 2) Local $mi = StringMid($NTP_Time, 15, 2) Local $s = StringMid($NTP_Time, 18, 2) Local $ms = StringMid($NTP_Time, 21, 3) ;~ Sets the new current time to the computer Local $tCurr = _Date_Time_EncodeSystemTime($m, $d, $y, $h, $mi, $s, $ms) Local $tTime = _Date_Time_GetSystemTime() _Date_Time_SetSystemTime(DllStructGetPtr($tCurr)) Local $aTime = _Date_Time_SystemTimeToArray($tTime) WriteLog($aTime, "Update Time: " & $NTP_Time & " UTC") EndFunc ;==>System_SetTime Func NTP_GetTime() Local $tBuffer Local $aSocket Local $xRequest = Binary(""), $xResponse = Binary(""), $hTimeoutTimer, $hEchoTimer, $iDelay Local $iSeconds= 0, $iFractions = 0, $iMsecs = 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) ; Send NTP request UDPStartup() If @error Then WriteLog(0, "UDPStartup failed - @error = " & @error) Exit EndIf OnAutoItExitRegister("udp_shutdown") $aSocket = UDPOpen(TCPNameToIP($NTP_Server), 123) If @error Then WriteLog(0, "UDPOpen failed - @error = " & @error) Exit EndIf Sleep(50) $hTimeoutTimer = TimerInit() While 1 $hEchoTimer = TimerInit() UDPSend($aSocket, $xRequest) If @error Then WriteLog(0, "UDPSend failed - @error = " & @error) Exit EndIf Do $xResponse = UDPRecv($aSocket, DllStructGetSize($tBuffer), $UDP_DATA_BINARY) If @error Then WriteLog(0, "UDPRecv failed - @error = " & @error) Exit EndIf Until $xResponse <> Binary("") $iDelay = Round(TimerDiff($hEchoTimer)/2) If $iDelay < 100 Then ExitLoop EndIf If TimerDiff($hTimeoutTimer) > 120000 Then ; If no response within 2 seconds, then exit WriteLog(0, "UDPRecv timed out") Exit EndIf Sleep(100) WEnd ; Close the socket UDPCloseSocket($aSocket) ; Parse timestamp values ; - Current time is calculated from the xmit timestamp in NTP response header ; - Xmit timestamp seconds is a big-endian, uint32, at binary position 41 ; - Xmit timestamp fraction is a big-endian, uint32, at binary position 45 $iSeconds = Dec(Hex(BinaryMid($xResponse, 41, 4)), $NUMBER_64BIT) ; seconds since 1900-01-01 00:00:00 $iFractions = Dec(Hex(BinaryMid($xResponse, 45, 4)), $NUMBER_64BIT) ; the maximum value is 0xFFFFFFFF, which represents 1 second $iMsecs = Round($iFractions / 2^32 * 1000) + $iDelay ; It normally takes about 50 milsecs to get NTP time If $iMsecs >= 1000 Then $iSeconds += 1 $iMsecs -= 1000 EndIf ; Current NTP time $NTP_Time = _DateAdd("s", $iSeconds, "1900/01/01 00:00:00") & StringFormat(".%03i", $iMsecs) EndFunc ;==>NTP_GetTime Func udp_shutdown() UDPShutdown() EndFunc ;==>udp_shutdown Func WriteLog($pTime, $sMessage) Local $fn, $sTime If $pTime = 0 Then $fn = FileOpen(@ScriptDir & "\TimeSync Failed.log", 2) $sTime = _NowCalc() Else $fn = FileOpen(@ScriptDir & "\TimeSync.log", 2) FileDelete(@ScriptDir & "\TimeSync Failed.log") $sTime = StringFormat("System Time: %04d/%02d/%02d %02d:%02d:%02d.%03d UTC", $pTime[2], $pTime[0], $pTime[1], $pTime[3], $pTime[4], $pTime[5], $pTime[6]) EndIf FileWrite($fn, $sTime & @CRLF & $sMessage) FileClose($fn) EndFunc ;==>WriteLog Edit: The above code is my latest version as of 2019/11/24, reflecting all the suggestions thankfully offered by @TheXman. Edit: The compiled version of this code(NTP_Time_V4.exe) was cleared by Microsoft Windows Defender from false detection as of Definition 1.305.2722.0. - 2019/11/24 NTP_Time_V4.exe.zip
    1 point
  7. I've recently been uncovering the useful commandline tools that can be found natively in Windows, one of which was findstr (there is also a GUI interface available in SciTE4AutoIt3.) After coming across this little gem and implementing in >SciTE Jump, it felt only right that I should share this on the forums as a standalone UDF. Thanks Function: ; #FUNCTION# ==================================================================================================================== ; Name ..........: _FindInFile ; Description ...: Search for a string within files located in a specific directory. ; Syntax ........: _FindInFile($sSearch, $sFilePath[, $sMask = '*'[, $fRecursive = True[, $fLiteral = Default[, ; $fCaseSensitive = Default[, $fDetail = Default]]]]]) ; Parameters ....: $sSearch - The keyword to search for. ; $sFilePath - The folder location of where to search. ; $sMask - [optional] A list of filetype extensions separated with ';' e.g. '*.au3;*.txt'. Default is all files. ; $fRecursive - [optional] Search within subfolders. Default is True. ; $fLiteral - [optional] Use the string as a literal search string. Default is False. ; $fCaseSensitive - [optional] Use Search is case-sensitive searching. Default is False. ; $fDetail - [optional] Show filenames only. Default is False. ; Return values .: Success - Returns a one-dimensional and is made up as follows: ; $aArray[0] = Number of rows ; $aArray[1] = 1st file ; $aArray[n] = nth file ; Failure - Returns an empty array and sets @error to non-zero ; Author ........: guinness ; Remarks .......: For more details: http://ss64.com/nt/findstr.html ; Example .......: Yes ; =============================================================================================================================== Func _FindInFile($sSearch, $sFilePath, $sMask = '*', $fRecursive = True, $fLiteral = Default, $fCaseSensitive = Default, $fDetail = Default) Local $sCaseSensitive = $fCaseSensitive ? '' : '/i', $sDetail = $fDetail ? '/n' : '/m', $sRecursive = ($fRecursive Or $fRecursive = Default) ? '/s' : '' If $fLiteral Then $sSearch = ' /c:' & $sSearch EndIf If $sMask = Default Then $sMask = '*' EndIf $sFilePath = StringRegExpReplace($sFilePath, '[\\/]+$', '') & '\' Local Const $aMask = StringSplit($sMask, ';') Local $iPID = 0, $sOutput = '' For $i = 1 To $aMask[0] $iPID = Run(@ComSpec & ' /c ' & 'findstr ' & $sCaseSensitive & ' ' & $sDetail & ' ' & $sRecursive & ' "' & $sSearch & '" "' & $sFilePath & $aMask[$i] & '"', @SystemDir, @SW_HIDE, $STDOUT_CHILD) ProcessWaitClose($iPID) $sOutput &= StdoutRead($iPID) Next Return StringSplit(StringStripWS(StringStripCR($sOutput), BitOR($STR_STRIPLEADING, $STR_STRIPTRAILING)), @LF) EndFunc ;==>_FindInFileExample use of Function: #include <Array.au3> #include <Constants.au3> Example() Func Example() Local $hTimer = TimerInit() Local $aArray = _FindInFile('findinfile', @ScriptDir, '*.au3;*.txt') ; Search for 'findinfile' within the @ScripDir and only in .au3 & .txt files. ConsoleWrite(Ceiling(TimerDiff($hTimer) / 1000) & ' second(s)' & @CRLF) _ArrayDisplay($aArray) $hTimer = TimerInit() $aArray = _FindInFile('autoit', @ScriptDir, '*.au3') ; Search for 'autoit' within the @ScripDir and only in .au3 files. ConsoleWrite(Ceiling(TimerDiff($hTimer) / 1000) & ' second(s)' & @CRLF) _ArrayDisplay($aArray) EndFunc ;==>Example
    1 point
  8. Hello fellas! The other night night i was converting a Msdn function to autoit and I stumbled across this topic Which inspired me like crazy and I decided to take it a step further and require the user to make almost ZERO effort to export a c++ Msdn function and or a Structure to AutoIt Shoutout to toasterking So after 18-20 effective hours: The GUI is really simple, all you need is a link to a MSDN page and the program does the rest, most of the options is just for user preferences. On the inside I have spent a decent amount of work to make sure the code come out correctly, any particular event during the conversion will get fed-back to the user, so he or she will know if anything noticeable happen. Regular DllCall example http://i.imgur.com/HZLijeu.png Struct example http://i.imgur.com/l3j6wTR.png Expand spoiler for more pictures In the "Msdn Examples" folder you will find some examples of code i have generated, in most of them I only manually added 2-3 lines to make them work. If you dont know where to get these functions you can browse the MSDN Library https://msdn.microsoft.com/en-us/library/ee663300(v=vs.85).aspx and look for any function refrence, or just google "somethingsomething msdn" and the first result will almost always contain the function you are looking for. Here is some functions you can play around with https://msdn.microsoft.com/en-us/library/windows/desktop/ms724390(v=vs.85).aspx https://msdn.microsoft.com/en-us/library/windows/desktop/ms633519(v=vs.85).aspx https://msdn.microsoft.com/en-us/library/windows/desktop/ms645505(v=vs.85).aspx https://msdn.microsoft.com/en-us/library/windows/desktop/ms724408(v=vs.85).aspx I would really appreciate any kind of feedback, improvements or requests If you get any type of error just post the MSDN url + the error message and ID and I will troubleshoot it. Update 0.2 Fixed some minor issues Added highlight for a more pleasent view Fixed minor bugs Made it run faster when working with the same URL (It dosent load the page entierly) No struct search is now done when no POINTER is used in the call Added more options for the user Update 0.3 Removed _IeNavigate and fixed the template for DllCall not including function name Update 0.4 Switched method to InetGet from _Ie* H0tfix3s Update 0.5 Added more options for function-layout Removed old code Added more auto detection Now using @TmpDir instead of @ScriptDir for html files etc. Update 0.6 More Output logic added Added a detection for SAL aswell, since it seems to be inconsistent according to MSDN community and myself. Better feedback on what happend with parse Code cleanup / Removed old code /Tarre DllCall and Struct Generator V 0.6.zip DllCall and Struct Generator V 0.5.zip DllCall and Struct Generator V 0.4.zip
    1 point
×
×
  • Create New...