Leaderboard
Popular Content
Showing content with the highest reputation on 07/29/2020 in all areas
-
_FileSearch + _FolderSearch
Professor_Bernd reacted to AZJIO for a topic
Function to search for files or folders. FileOperations.7z - version 1.8.4 from 2014.03.18, (pastebin: Ru , Ru-example) _FO_CorrectMask (Help) _FO_FileSearch (Help) _FO_FolderSearch (Help) _FO_SearchEmptyFolders (Help) _FO_FileDirReName (Help) _FO_GetCopyName (Help) _FO_FileBackup (Help) _FO_PathSplit (Help) _FO_IsDir (Help) _FO_ShortFileSize (Help) _FO_IsEmptyFolder (Help) _FO_CreateFile alternative: RecFileListToArray (Melba23) FileListToArrayEx (DXRW4E) FileListToArray (SmOke_N) FileFindFirstFile (NIKZZZZ) old _FileFindFirstFile, _FileFindNextFile (AZJIO) FileDirList (MrCreatoR, amel27), (cmd.exe Dir /b) FileListToArrayRecursive + _Callback (therks) FileSearch (AZJIO), link2 myFileListToArray_AllFiles (akurakkauaaa) Update Accordingly, the updated (26.11.2012) program: >TextReplace, >Create_list_files, >Search_duplicates, >Synchronization Accordingly, the updated (22.11.2011) program: >ReName1 point -
Cannot send email via Sparkpost relay from Autoit Script
argumentum reacted to Jos for a topic
Added a separate option to the original UDF for TLS Jos1 point -
[SOLVED] StdoutRead Help please
seadoggie01 reacted to TheDcoder for a topic
Some clarification: I think @error is only reset after calling another function, not after every command (statement). So the first code example should also work in theory, however I do agree that it is bad style to use @error like that.1 point -
Nested With Statements
seadoggie01 reacted to Musashi for a topic
I assume it's deliberate, see : https://www.autoitscript.com/autoit3/docs/appendix/Exitcodes.htm 0x7FFFF0A8 : Nested "With" statements are not allowed.1 point -
The executable doesn't work if I run it from a script... why???
seadoggie01 reacted to graybags for a topic
I had about 4 test PC's I was running these scripts on. I just went to a meeting and came back to find that someone is putting them out on the shopfloor! I'm going to have to restage another PC from scratch and try that script, but it looks good and I'm excited, thanks1 point -
@error only really works for the command immediately preceding it, so the following isn't going to work well. $_StderrRead = StderrRead ( $job ) If @error Then ExitLoop If Not @error And $_StderrRead <> '' Then How it should be written is as follows. $_StderrRead = StderrRead ( $job ) If @error Then ExitLoop ElseIf $_StderrRead <> '' Then If it is an error then by definition it isn't NOT an error, so will exit the loop and never get to that statement. Haven't run your code, so not sure if that alone fixes things.1 point
-
The problem was the clock here! It was too late for me to think clearly, sorry. 😁 No thank you, forget that. If you remove references to Latin1, your statement is correct. It's precisely because we DON'T convert to Latin1 that the conversion is verbatim. I correct my previous (too-late-to-be true) post! Your uses of AscW and ChrW were correct, my mistake. Yes, but regexes are all linear as well, albeit done in optimized low-level compiled C, faster than interpreted AutoIt.1 point
-
File read
Musashi reacted to argumentum for a topic
..every time I read "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move.", it just makes me laugh1 point -
1 point
-
1 point
-
If you set the styles of a control with GUICtrlSetStyle() and happen to forget the styles you set, then why not try GUICtrlGetStyle() To get the Hex value e.g. 00100000 then use this little conversion >> Local $aArray = GUICtrlGetStyle($iLabel) _GUICtrlGetStyle_Convert($aArray) _ArrayDisplay($aArray, 'The Style = 0101 & the ExStyle = 00100000'))Function: #include-once #include <WinAPI.au3> ; #FUNCTION# ==================================================================================================================== ; Name ..........: GUICtrlGetStyle ; Description ...: Retrieves the Styles/ExStyles value(s) of a control. ; Syntax ........: GUICtrlGetStyle($hWnd) ; Parameters ....: $hWnd - Control ID/Handle to the control ; Return values .: $aArray[2] = [Style, ExStyle] ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func GUICtrlGetStyle($hWnd) If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) EndIf Local $aReturn = [_WinAPI_GetWindowLong($hWnd, $GWL_STYLE), _WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE)] Return $aReturn EndFunc ;==>GUICtrlGetStyleExample use of Function: #include <Array.au3> ; Required only for _ArrayDisplay(), but not the UDF! #include <GUIConstantsEx.au3> #include 'GUICtrlGetStyle.au3' Example() Func Example() Local $hGUI = GUICreate('GUICtrlGetStyle() Example', 280, 90) ; This label is using 'magic numbers' instead of the constant variables. It's advisable to use $SS_CENTER & $GUI_WS_EX_PARENTDRAG ; instead of 0x0101 & 0x00100000, but this has been done for proof of concept only. See the second _Array display for more details. Local $iLabel = GUICtrlCreateLabel('This is a Label with $SS_CENTER & $GUI_WS_EX_PARENTDRAG set as the Styles.', 10, 10, 270, 45, 0x0101, 0x00100000) ; $SS_CENTER, $GUI_WS_EX_PARENTDRAG Local $iButton = GUICtrlCreateButton('GetStyle Array', 95, 55, 85, 25) GUISetState(@SW_SHOW, $hGUI) Local $aArray = 0 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $iButton $aArray = GUICtrlGetStyle($iLabel) _ArrayDisplay($aArray) GUICtrlDelete($iLabel) GUICtrlCreateLabel('This is a NEW Label with $SS_CENTER & $GUI_WS_EX_PARENTDRAG set as the Styles/ExStyles.', 10, 10, 270, 50, $aArray[0], $aArray[1]) ; This is the reason why 'magic numbers' were used, so as to see they match the same values in GUICtrlCreateLabel. $aArray = GUICtrlGetStyle($iLabel) _GUICtrlGetStyle_Convert($aArray) _ArrayDisplay($aArray, 'The Style = 0x0101 & the ExStyle = 0x00100000') EndSwitch WEnd GUIDelete($hGUI) EndFunc ;==>Example Func _GUICtrlGetStyle_Convert(ByRef $aArray) If UBound($aArray) = 2 Then $aArray[0] = '0x' & Hex($aArray[0], 4) $aArray[1] = '0x' & Hex($aArray[1], 8) EndIf EndFunc ;==>_GUICtrlGetStyle_Convert1 point
-
GUIRegisterMsg replacement for GUICtrlSetOnEvent and GUIGetMsg
Professor_Bernd reacted to BrewManNH for a topic
Here's a little snippet that I wrote up that demonstrates a way to eliminate the message loop and onevent modes of detecting control and GUI events. I was inspired to attempt this by this feature request and the answer that Valik gave when he rejected it. I wasn't sure how to write the wrapper that he said could be done to do this, so I dug into windows messages to see what I could come up with. This snippet uses 3 different windows messages for various controls and for the GUI events. I have also included code that shows that you can use this in conjunction with GUIGetMsg, it should work just as well alongside OnEvent mode as well. You will probably have to play around with it to get it to work with every different type of control that AutoIt can make. I originally had a combo box in the GUI, but they work strangely because an event is fired every time the GUI gets focus and the combo is the last control actioned. I hope this is informative to some and if there's a way of doing this easier, I'd love to know. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MenuConstants.au3> GUIRegisterMsg($WM_COMMAND, "_WM_EXTRACTOR") GUIRegisterMsg($WM_SYSCOMMAND, "_WM_EXTRACTOR") GUIRegisterMsg($WM_HSCROLL, "_WM_EXTRACTOR") $GUI = GUICreate("Test GUI", 200, 200, -1, -1, BitOR($WS_THICKFRAME, $gui_ss_default_gui)) $Button = GUICtrlCreateButton("Test", 20, 20) $Button2 = GUICtrlCreateButton(" Another Test ", 20, 100) $Slider = GUICtrlCreateSlider(20, 60, 150) $hSlider = GUICtrlGetHandle($Slider) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $Button MsgBox(0, "", "You pressed the button marked TEST") Case $Button2 MsgBox(0, "", "You pressed the button marked 'Another Test'") EndSwitch WEnd Func _WM_EXTRACTOR($hWnd, $iMsg, $wParam, $lParam) Local $nNotifyCode = BitShift($wParam, 16) Local $nID = BitAND($wParam, 0x0000FFFF) Local $hCtrl = $lParam #forceref $hWnd, $iMsg, $wParam, $lParam Switch $iMsg Case $WM_HSCROLL Switch $lParam Case $hSlider ConsoleWrite("+Slider moved to: " & GUICtrlRead($Slider) & @LF) EndSwitch Case $WM_VSCROLL Case $WM_COMMAND Switch $nID Case $Button ConsoleWrite(">Button Test pressed" & @LF) Case $Button2 ConsoleWrite(">Button Another Test pressed" & @LF) Case Else MsgBox(0, "MY_WM_COMMAND", "GUIHWnd" & @TAB & ":" & $hWnd & @LF & _ "MsgID" & @TAB & ":" & $msg & @LF & _ "wParam" & @TAB & ":" & $wParam & @LF & _ "lParam" & @TAB & ":" & $lParam & @LF & @LF & _ "WM_COMMAND - Infos:" & @LF & _ "-----------------------------" & @LF & _ "Code" & @TAB & ":" & $nNotifyCode & @LF & _ "CtrlID" & @TAB & ":" & $nID & @LF & _ "CtrlHWnd" & @TAB & ":" & $hCtrl) EndSwitch Case $WM_SYSCOMMAND Switch $wParam Case $SC_CLOSE ConsoleWrite("!Exit pressed" & @LF) Exit Case $SC_RESTORE ConsoleWrite("!Restore window" & @LF) Case $SC_MINIMIZE ConsoleWrite("!Minimize Window" & @LF) Case $SC_MOUSEMENU + 3 ConsoleWrite("!System menu pressed" & @LF) Case $SC_MOVE ConsoleWrite("!System menu Move Option pressed" & @LF) Return 0 Case $SC_SIZE ConsoleWrite("!System menu Size Option pressed" & @LF) Return 0 Case $SC_MOUSEMENU + 2 ; This and the following case statements are only valid when the GUI is resizable ConsoleWrite("!Right side of GUI clicked" & @LF) Return 0 Case $SC_MOUSEMENU + 1 ConsoleWrite("!Left side of GUI clicked" & @LF) Return 0 Case $SC_MOUSEMENU + 8 ConsoleWrite("!Lower Right corner of GUI clicked" & @LF) Return 0 Case $SC_MOUSEMENU + 7 ConsoleWrite("!Lower Left corner of GUI clicked" & @LF) Return 0 Case $SC_MOUSEMENU + 6 ConsoleWrite("!Bottom side of GUI clicked" & @LF) Return 0 Case Else MsgBox(0, "MY_WM_COMMAND", "GUIHWnd" & @TAB & ":" & $hWnd & @LF & _ "MsgID" & @TAB & ":" & $msg & @LF & _ "wParam" & @TAB & ":" & $wParam & @LF & _ "lParam" & @TAB & ":" & $lParam & @LF & @LF & _ "WM_COMMAND - Infos:" & @LF & _ "-----------------------------" & @LF & _ "Code" & @TAB & ":" & $nNotifyCode & @LF & _ "CtrlID" & @TAB & ":" & $nID & @LF & _ "CtrlHWnd" & @TAB & ":" & $hCtrl) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>_WM_EXTRACTOR1 point -
GUIRegisterMsg replacement for GUICtrlSetOnEvent and GUIGetMsg
Professor_Bernd reacted to BrewManNH for a topic
Here's an updated version of the same code as above, but using a single function to handle all 3 types of Windows messages. I'm sure there's a Windows constant for the 2 numbers I used in the Switch statement for $iMsg, but I wasn't able to find out what it was. The 273 is used to activate the button control function, which also works on combobox controls, the 274 is the GUI messages for things like the sysmenu and the close button. If anyone knows the variables for those 2 numbers, please let me know. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> GUIRegisterMsg($WM_COMMAND, "_WM_EXTRACTOR") GUIRegisterMsg($WM_SYSCOMMAND, "_WM_EXTRACTOR") GUIRegisterMsg($WM_HSCROLL, "_WM_EXTRACTOR") $GUI = GUICreate("Test GUI", 200, 200, -1, -1, BitOR($WS_THICKFRAME, $gui_ss_default_gui)) $Button = GUICtrlCreateButton("Test", 20, 20) $Button2 = GUICtrlCreateButton(" Another Test ", 20, 100) $Slider = GUICtrlCreateSlider(20, 60, 150) $hSlider = GUICtrlGetHandle($Slider) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $Button MsgBox(0, "", "You pressed the button marked TEST") Case $Button2 MsgBox(0, "", "You pressed the button marked 'Another Test'") EndSwitch WEnd Func _WM_EXTRACTOR($hWnd, $iMsg, $wParam, $lParam) Local $nNotifyCode = BitShift($wParam, 16) Local $nID = BitAND($wParam, 0x0000FFFF) Local $hCtrl = $lParam #forceref $hWnd, $iMsg, $wParam, $lParam Switch $iMsg Case $WM_HSCROLL Switch $lParam Case $hSlider ConsoleWrite("+Slider moved to: " & GUICtrlRead($Slider) & @LF) EndSwitch Case $WM_VSCROLL Case 273 Switch $nID Case $Button ConsoleWrite(">Button Test pressed" & @LF) Case $Button2 ConsoleWrite(">Button Another Test pressed" & @LF) Case Else MsgBox(0, "MY_WM_COMMAND", "GUIHWnd" & @TAB & ":" & $hWnd & @LF & _ "MsgID" & @TAB & ":" & $msg & @LF & _ "wParam" & @TAB & ":" & $wParam & @LF & _ "lParam" & @TAB & ":" & $lParam & @LF & @LF & _ "WM_COMMAND - Infos:" & @LF & _ "-----------------------------" & @LF & _ "Code" & @TAB & ":" & $nNotifyCode & @LF & _ "CtrlID" & @TAB & ":" & $nID & @LF & _ "CtrlHWnd" & @TAB & ":" & $hCtrl) EndSwitch Case 274 Switch $wParam Case 0xf060 ConsoleWrite("!Exit pressed" & @LF) Exit Case 0xF120 ConsoleWrite("!Restore window" & @LF) Case 0xF020 ConsoleWrite("!Minimize Window" & @LF) Case 0xF093 ConsoleWrite("!System menu pressed" & @LF) Case 0xF010 ConsoleWrite("!System menu Move Option pressed" & @LF) Return 0 Case 0xF000 ConsoleWrite("!System menu Size Option pressed" & @LF) Return 0 Case 0xF002 ; This and the following case statements are only valid when the GUI is resizable ConsoleWrite("!Right side of GUI clicked" & @LF) Return 0 Case 0xf001 ConsoleWrite("!Left side of GUI clicked" & @LF) Return 0 Case 0xF008 ConsoleWrite("!Lower Right corner of GUI clicked" & @LF) Return 0 Case 0xF007 ConsoleWrite("!Lower Left corner of GUI clicked" & @LF) Return 0 Case 0xF006 ConsoleWrite("!Bottom side of GUI clicked" & @LF) Return 0 Case Else MsgBox(0, "MY_WM_COMMAND", "GUIHWnd" & @TAB & ":" & $hWnd & @LF & _ "MsgID" & @TAB & ":" & $msg & @LF & _ "wParam" & @TAB & ":" & $wParam & @LF & _ "lParam" & @TAB & ":" & $lParam & @LF & @LF & _ "WM_COMMAND - Infos:" & @LF & _ "-----------------------------" & @LF & _ "Code" & @TAB & ":" & $nNotifyCode & @LF & _ "CtrlID" & @TAB & ":" & $nID & @LF & _ "CtrlHWnd" & @TAB & ":" & $hCtrl) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>_WM_EXTRACTOR1 point