-
Posts
557 -
Joined
-
Last visited
Everything posted by abberration
-
Hi, everyone! I have been trying to get #AutoIt3Wrapper_Res_Icon_Add to work for over an hour and so far unsuccessfully. I tried the example script from the docs section of this website. The example script does not work for me, either. The icons are in the correct location on my computer. Does the script below work for you guys/gals? ; Add icons to the file resource table ; As no resource names are specified, they will be set automatically to 201+ #AutoIt3Wrapper_Res_Icon_Add=C:\Program Files (x86)\AutoIt3\Icons\au3.ico #AutoIt3Wrapper_Res_Icon_Add=C:\Program Files (x86)\AutoIt3\Icons\au3script_v10.ico #AutoIt3Wrapper_Res_Icon_Add=C:\Program Files (x86)\AutoIt3\Icons\au3script_v9.ico #AutoIt3Wrapper_Res_Icon_Add=C:\Program Files (x86)\AutoIt3\Icons\filetype-blank.ico #include <ButtonConstants.au3> ; Create the GUI $hGUI = GUICreate("Demo icon resources") $cButton = GUICtrlCreateButton("", 10, 10, 40, 40, $BS_ICON) $cLabel = GUICtrlCreateLabel("", 70, 25, 200, 20) GUISetState(@SW_SHOW, $hGUI) ; Now run through the added icons in the resource table For $x = 201 To 204 ; Change the tray icon $rc1 = TraySetIcon(@ScriptFullPath, $x) ; Change the icon in the button $rc2 = GUICtrlSetImage($cButton, @ScriptFullPath, $x) GUICtrlSetData($cLabel, "Icon Name: " & $x) TrayTip("Added icon: " & $x, "TraySetIcon rc: " & $rc1 & @CRLF & "GUICtrlSetImage rc: " & $rc2, 3) ; Allow time for icon to be seen Sleep(5000) Next ; Delete the GUI GUIDelete($hGUI) On my test project (not the above code), I used reshacker and saw the icon I want to use is icon group 201. Setting the image to 201 did not work. Then, I set the name to exit.ico with the wrapper and now it does not have 201 in reshacker, now it uses the name EXIT.ICO instead. So, I used the following, which also did not work: GUICtrlSetImage($MenuItemExit, @ScriptFullPath, "EXIT.ICO") By the way, this is for a menu item. Perhaps I need to use something other than GuiCtrlSetImage? Thanks for any advice! Simplified version of my script: #AutoIt3Wrapper_Res_Icon_Add=Y:\Exit.ico, exit.ico #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 379, 202) $MenuItem1 = GUICtrlCreateMenu("File") $MenuItemExit = GUICtrlCreateMenuItem("Exit", $MenuItem1) GUICtrlSetImage($MenuItemExit, @ScriptFullPath, "EXIT.ICO") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd
-
Hi, everyone After playing with GuiRegisterMsg and WM_COMMAND for about an hour trying to solve a problem, I learned something and it brings up a new question. The script I'm working on has a search function and a list of files. I want to be able to double-click a file on the list and open the folder containing the file. To do this, I used GuiRegisterMsg for $LBN_DBLCLK and referenced a dummy file that I put at the very beginning of the script. This caused the Case for $idDummy to infinitely pop up the messagebox before touching the WM_COMMAND. I finally figured out I needed to declare the dummy in the child form, and all is working well and I'm able to go to the next step. Here's my question: to make this happen, on the child GUI, I have to declare dummy (and list box) globally. I have read it is best to declare all variables as local. I cannot think of any way of making this script work without declaring them globally. Is there something I am missing or is it sometimes absolutely necessary to declare them globally? Thanks in advance for any advice! Here is some condensed code: #include <GUIConstants.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> $Form1 = GUICreate("Main Form", 355, 169, 0, 0) $Button1 = GUICtrlCreateButton("Click To Open List", 80, 64, 195, 25, $WS_GROUP) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 _OpenForm2() EndSwitch WEnd Func _OpenForm2() $Form2 = GUICreate("Child Form", 355, 169, 370, 0) Global $idDummy = GUICtrlCreateDummy() ; $idDummy and $List1 must be Global variables. Is there a way to make them Local? Global $List1 = GUICtrlCreateList("Double-Click Me", 16, 8, 321, 123) GUICtrlSetData($List1, "Or... Double-Click Me...") GUISetState(@SW_SHOW) GUIRegisterMsg($WM_COMMAND, "MyFunc") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete($Form2) ExitLoop Case $idDummy MsgBox(0, "", GUICtrlRead($idDummy)) EndSwitch WEnd EndFunc Func MyFunc($hWnd, $iMsg, $wParam, $lParam) Local $hWndFrom, $iIDFrom, $iCode, $hWndEdit $hWndFrom = $lParam $iIDFrom = _WinAPI_LoWord($wParam) $iCode = _WinAPI_HiWord($wParam) If $iCode = $LBN_DBLCLK AND $iIDFrom = $List1 Then $sClicked = GUICtrlRead($List1) GUICtrlSendToDummy($idDummy, $sClicked) EndIf EndFunc
-
The only reference to array3381.au3 I could find was concerning an AI bot path finding script called "A Star" (on the French AutoIt forum - I had to use Google Translate). Is this what you are working with? The A Star script was updated in 2015 to not need a modified version of array.au3. If I am completely wrong, let us know what functions you need (is it _ArrayCreate?). You can add in individual functions to your script without adding the whole array3381.au3. Try removing "#include <array3381.au3>" and let us know what errors you receive.
-
If you do not want to complicate your code, why not make a second executable that will act as a splash screen that can read something hidden on your main gui? Example: On your main program, make a label that is only 1 pixel by 1 pixel like this: #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form2 = GUICreate("Form1", 405, 294) $Label1 = GUICtrlCreateLabel("", 1, 1, 1, 1) GUISetState(@SW_SHOW) $textToBeRead = "Monkey is a common name that may refer to groups or species of mammals, " & _ "in part, the simians of infraorder Simiiformes. The term is applied descriptively to groups " & _ "of primates, such as families of New World monkeys and Old World monkeysand Hominoidea " & _ "emerged within the catarrhine monkeys some 25 million years ago. Extinct basal simians " & _ "such as Aegyptopithecus or Parapithecus [35-32 million years ago], eosimiidea and sometimes " & _ "even the Catarrhini group are also considered monkeys by primatologists." GUICtrlSetData($Label1, $textToBeRead) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Then make a second executable that reads the text from the first: #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> $Form2 = GUICreate("Form2", 622, 204, 302, 218) $Label1 = GUICtrlCreateLabel("", 8, 8, 604, 185) GUISetState(@SW_SHOW) $textread = ControlGetText("Form1", "", "[CLASS:Static;INSTANCE:1]") GUICtrlSetData($Label1, $textread) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd It's not pretty at the moment, but it works. You can play with the code to make the splash screen look better. And being a totally separate .exe, it won't interfere with your existing code at all.
-
@mikell That's what I love about AutoIt - there are so many ways to accomplish a task. I need to study your regex expressions a bit more to fully understand them, but your method is an interesting solution. Also, I didn't know about @extended - I learned something new today.
-
This is far from perfect (mostly, you need to work on getting rid of excess spaces), but it may give you some ideas: #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <array.au3> #include <string.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 625, 376) $Edit1 = GUICtrlCreateEdit("", 8, 24, 409, 289, BitOR($ES_AUTOVSCROLL,$ES_WANTRETURN,$WS_VSCROLL)) GUICtrlSetData(-1, "Geology is an Earth science concerned with the solid Earth, the rocks of which it is composed, and the processes by which they change over time. ") $List1 = GUICtrlCreateList("", 440, 24, 161, 279) $Button1 = GUICtrlCreateButton("Go", 480, 336, 75, 25, $WS_GROUP) $Label1 = GUICtrlCreateLabel("Input Text", 8, 0, 52, 17) $Label2 = GUICtrlCreateLabel("Word Frequency", 440, 0, 83, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $sTextRead = GUICtrlRead($Edit1) _Frequency($sTextRead) EndSwitch WEnd Func _Frequency($sTextRead) $aStringToArray = StringSplit($sTextRead, " ") $aUniqueWords = _ArrayUnique($aStringToArray, 0, 1) For $i = 1 To $aUniqueWords[0] $aNumResults = _ArrayFindAll($aStringToArray, $aUniqueWords[$i]) $aUniqueWords[$i] &= " - " & UBound($aNumResults) GUICtrlSetData($List1, $aUniqueWords[$i]) Next EndFunc
-
Hi, seadoggie01, You make a great point about ReDim. I will look at the code soon and try to rework it to only ReDim once. _ArrayFindAll is what I used to model my function. It uses _ArraySearch for it's results, so using _ArrayFindAll should not be any faster. You are correct, I should have done more error checking. Before I put in the one @error, when I passed bad info, it only returned an empty array. When I put in the one @error, it seemed to return the correct error handle. But I do need to do more testing in this area. I got it working and was very tired, so I just posted it. I will continue working on it. I think it could be a very useful addition when it's perfected. I have already determined that declaring the default value of $iRanges is useless as it is. I need to work on that. Thank you for your suggestions. I will use them to improve the script.
-
I found myself needing to search different parts of a large array and did not need all the results from _ArrayFindAll, so I wrote a similar function, which I call _ArrayFindRanges. Instead of $iStart and $iEnd, you use ranges separated by semi-colons (ex: "2-5;8-12;18-30;42-50"). I tested various aspects and I am not finding any flaws yet. If anyone has suggestions to make it better or more efficient, I would love to hear from you. Hope you guys like it! 🤠 Update! (10-6-2020) I took seadoggie01's suggestion to only ReDim once (Thx, seadoggie01!). Also, while integrating this function into a script, I discovered I was forcing the $iForward parameter to be forward searching only in the _ArraySearch call. I fixed that as well. I changed where Default is passed to $iRanges will search the entire array (this makes it act like _ArrayFindAll). Lastly, I discovered if you entered nothing or incorrect data for $iRanges, it will crash your program. I included a check that will return an error code instead of going through the loops, letting you know you have no matches because you passed improper data for $iRanges. I just realized I need to put in more checks to make sure only numbers are passed and possible error codes - I will work on this. The syntax should be the same except for not receiving errors for having the correct number of parameters. _ArraySearch uses 9 parameters and my function uses 8 parameters (the $iStart and $iEnd are replaced with $iRanges). It's working efficiently and perfectly in my script. I will work on more error checking and update when I have completed it. Updated code: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 #include <array.au3> ; Examples Local $aValues[20] = ["", "", "you", "you", "you", "me", "me", "", "", "you", "me", "", "", "me", "you", "me", "", "", ""] ; 1D array Local $aValues2[2][4] = [["peter", "paul", "mary", "paul"], ["peter", "mary", "mary", "peter"]] ; 2D array Local $test, $testErrorNotArray = "wow" $test = _ArrayFindRanges($aValues, "Me", "2-7;12-18", 0, 0, 0, False) ; test 1D array If @error Then MsgBox(0, "", @error) _ArrayDisplay($test) $test = _ArrayFindRanges($aValues2, "mary", "1-4", 0, 0, 1, True) ; test 2D array choosing to search columns instead of rows If @error Then MsgBox(0, "", @error) _ArrayDisplay($test) $test = _ArrayFindRanges($aValues2, "joe", "1-4", 0, 0, 1, True) ; test 2D array, testing @error result If @error Then MsgBox(0, "", @error) _ArrayDisplay($test) $test = _ArrayFindRanges($testErrorNotArray, "joe", "1-4", 0, 0, 1, True) ; test 2D array, testing a different @error result If @error Then MsgBox(0, "", @error) _ArrayDisplay($test) #cs Syntax: _ArrayFindRanges ( Const ByRef $aArray, $iRanges ("num1-num2;num3-num4;num5-num6"), [, $iCase = 0 [, $iCompare = 0 [, $iSubItem = 0 [, $bRow = False]]]]]] ) Note: $iRanges must enclose all the number ranges in quotes and separate the various ranges by semi-colons. Success: An array of all index numbers in array containing $vValue. Failure: Sets the @error flag to non-zero (see _ArraySearch() description for @error). Remarks The values of $iCompare can not be combined together. #ce ; #FUNCTION# ==================================================================================================================== ; Title .........: ArrayFindRanges ; AutoIt Version : 3.3.14.2 ; Description ...: Search ranges of an array (similar to _ArrayFindAll) ; Author ........: abberration ; Thanks ........: seadoggie01 for improvement suggestions ; =============================================================================================================================== Func _ArrayFindRanges(Const ByRef $aArray, $vValue, $iRanges, $iCase = 0, $iCompare = 0, $iForward = 1, $iSubItem = 0, $bRow = False) Local $iIndex = 1, $avResult[UBound($aArray)], $aRangeSplit, $aValuesSplit, $iResult If $iRanges = Default Then $iRanges = "1-" & UBound($aArray) If $iCompare = Default Then $iCompare = 0 If $iSubItem = Default Then $iSubItem = 0 If $bRow = Default Then $bRow = False $aRangeSplit = StringSplit($iRanges, ";") If $aRangeSplit[1] = "" Then Return SetError(@error, 0, -1) Else For $i = 1 To $aRangeSplit[0] $aValuesSplit = StringSplit($aRangeSplit[$i], "-", 2) For $j = $aValuesSplit[0] To $aValuesSplit[1] $iResult = _ArraySearch($aArray, $vValue, $j, $aValuesSplit[1], $iCase, $iCompare, $iForward, $iSubItem, $bRow) $j = $iResult If $iResult = -1 Then ExitLoop $avResult[$iIndex - 1] = $iResult $iIndex += 1 Next Next EndIf If $iIndex = 1 Then Return SetError(@error, 0, -1) ReDim $avResult[$iIndex - 1] Return $avResult EndFunc ;==>_ArrayFindRanges
-
You have been extremely helpful. I finished the script and my code is extremely similar to yours. Exactly what it does is organizes TV episodes into folders and sub-folders (the way I prefer them). The show must have something like S01E14 in it (or 1x14, which I added code to convert it). It will create a folder for that show if it doen't exist and create a sub-folder like S01. Finally, it moves the file to that folder. If anyone is interested in the final code, here it is (hey, maybe someone else might be able to use it): #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=Custom-Icon-Design-Pretty-Office-5-Folder-Add.ico #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <WinAPI.au3> #include <WinAPIConstants.au3> #include <WinAPISys.au3> #include <GuiButton.au3> #include <File.au3> #include <String.au3> $strSupportedFormats = "*.avi;*.mpg;*.mpeg;*.mp4;*.mkv;*.wmv" $guiForm1 = GUICreate("Create Folders And Organize", 305, 356) GUISetState(@SW_SHOW) $guiDummy = GUICtrlCreateDummy() $arrWinList = _GetListOfOpenExplorerWindows(1, 3) ; creates an array of windows that are open _ArraySort($arrWinList, 0, 1) If IsArray($arrWinList) Then ; List the open If $arrWinList[0][0] > 12 Then WinMove($guiForm1, "", @DesktopWidth/2 - 305, Default, 610, 378) EndIf For $i = 1 To $arrWinList[0][0] If $i < 13 Then $y = (($i - 1) * 28) + 8 Assign("guiButton" & $i, GUICtrlCreateButton($arrWinList[$i][0], 8, $y , 283, 25, $WS_GROUP)) ElseIf $i > 12 Then $y = (($i - 13) * 28) + 8 Assign("guiButton" & $i, GUICtrlCreateButton($arrWinList[$i][0], 305, $y, 283, 25, $WS_GROUP)) If $i = 24 Then ExitLoop EndIf EndIf Next EndIf GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $guiDummy $strText = GUICtrlRead($guiDummy) GUICtrlSendToDummy($strText) $arrPos = _ArraySearch($arrWinList, $strText) _OrganizeFolder($arrWinList[$arrPos][1]) EndSwitch WEnd Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) ; if button is clicked, give popup confirming it. Local $hWndFrom, $iIDFrom, $iCode, $hWndEdit $hWndFrom = $ilParam $iIDFrom = _WinAPI_LoWord($iwParam) $iCode = _WinAPI_HiWord($iwParam) If $iCode = $BN_CLICKED Then $text = _GUICtrlButton_GetText ($hWndFrom) GUICtrlSendToDummy($guiDummy, $text) EndIf EndFunc Func _GetListOfOpenExplorerWindows($vIncludeArrayCount = 0, $vColumnReturn = 3) ; (0 = No, 1 = Yes), (1 = Short Names Only, 2 = Long Addresses, 3 or 1 + 2 = Return Both) Local $aWinList, $sGetText, $aWinText, $varStrLen, $sFormat, $i, $j, $k, $vRowsToDel $aWinList = WinList() Local $aOutput[0][2] $k = 0 For $i = 1 To $aWinList[0][0] $sGetText = WinGetText($aWinList[$i][0]) $aWinText = StringSplit($sGetText, @LF) For $j = 1 To $aWinText[0] If StringInStr($aWinText[$j], "Address:") Then $sFormat = StringReplace($aWinText[$j], "Address: ", "") If DirGetSize($sFormat) > -1 Then ReDim $aOutput[UBound($aOutput) + 1][2] $aOutput[$k][0] = $aWinList[$i][0] $aOutput[$k][1] = $sFormat $k += 1 EndIf EndIf Next Next For $i = 1 To UBound($aOutput) $varStrLen = StringLen($aOutput[$i - 1][0]) If $varStrLen = 0 Then $vRowsToDel = $vRowsToDel & $i - 1 & ";" EndIf Next $vRowsToDel = StringTrimRight($vRowsToDel, 1) _ArrayDelete($aOutput, $vRowsToDel) If $vIncludeArrayCount = 1 Then _ArrayInsert($aOutput, 0, UBound($aOutput)) EndIf If $vColumnReturn = 1 Then _ArrayColDelete($aOutput, 1) ElseIf $vColumnReturn = 2 Then If $vIncludeArrayCount = 1 Then If UBound($aOutput) > 0 Then $aOutput[0][1] = UBound($aOutput) EndIf EndIf _ArrayColDelete($aOutput, 0) EndIf If UBound($aOutput) = 0 Then Return -1 Else Return $aOutput EndIf EndFunc Func _OrganizeFolder($strFolderName) ; code to organize the content of the folder $arrFileList = _FileListToArrayRec($strFolderName & "\", $strSupportedFormats, 1, 0) For $i = 1 To $arrFileList[0] $strFileName = $arrFileList[$i] $arrSeason = StringRegExp($strFileName, "[S|s]\d\d[E|e]\d\d", 1) $arrSeasonx = StringRegExp($strFileName, "\d{1,2}[x|X]\d{1,2}", 1) ; If the show is formatted as 1x13 then convert to S01E14 If IsArray($arrSeasonx) Then Dim $arrSeason[1] $arrSeason[0] = StringRegExpReplace($arrSeasonx[0], "\d{1,2}[x|X]\d{1,2}", _ConvertXToS($arrSeasonx[0])) $strFileNameOrig = $strFileName $strFileName = StringRegExpReplace($strFileName, "\d{1,2}[x|X]\d{1,2}", $arrSeason[0]) ; going back to the original file name, substitute 1x13 for S01E14. FileMove($strFolderName & "\" & $strFileNameOrig, $strFolderName & "\" & $strFileName) EndIf If IsArray($arrSeason) Then $arrShowName = StringRegExp($strFileName, ".+?(?=.[S]\d\d[E]\d\d)", 1) $strShowName = StringRegExpReplace($arrShowName[0], "\.", " ") $strFullPath = $strFolderName & "\" & _StringProper($strShowName) & "\" & _StringProper(StringLeft($arrSeason[0], 3)) If FileExists($strFullPath) = 0 Then DirCreate($strFullPath) EndIf FileMove($strFolderName & "\" & $strFileName, $strFullPath & "\" & $strFileName) Endif Next Exit EndFunc Func _ConvertXToS($varExp) $varExp = StringLower($varExp) ; Force the x to be lowercase becasue stringsplit is case sensitive $arrStrBreakdown = StringSplit($varExp, "x", 2) $varStrReconstructed = "S" & StringFormat("%02d", $arrStrBreakdown[0]) & "E" & StringFormat("%02d", $arrStrBreakdown[1]) Return $varStrReconstructed EndFunc I didn't put any safeguards because I only wrote it for myself and if a file doesn't match the season/episode specific expression, it ignores files. I didn't un-register the WM_Command because for this specific program, I will only ever run it one time and automatically quit. In the future (and for older programs that I keep running), I will make that change. Thanks for your help once again!
-
Hi, pixelsearch. Those are some really great suggestions. I will indeed use some of them. I really like the idea of unregistering the WM_Command and re-registering it. I never understood the purpose of a dummy until now. I played with sending a dummy the text of the button that was clicked in the WM_Command and in the Case, I sent it nothing and then called my function. That seems to work. I'm not an expert on dummies, but I think I understand them better now. Thanks again for all the great advice!
-
Hi, everyone. I am writing a script to help organize files in folders. I have hit a snag using _Arr ayDisplay. It works fine until I press a button that triggers a WM_Command. After a button is clicked, _ArrayDisplay locks up and crashes the script. I could continue without seeing a list, but it would be a lot easier if _ArrayDisplay worked. Also, I just would like to know why it's crashing. Any thoughts? #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <WinAPI.au3> #include <WinAPIConstants.au3> #include <WinAPISys.au3> #include <GuiButton.au3> #include <File.au3> $guiForm1 = GUICreate("Form1", 305, 356) GUISetState(@SW_SHOW) $arrWinList = _GetListOfOpenExplorerWindows(1, 3) ; creates an array of windows that are open _ArraySort($arrWinList, 0, 1) If IsArray($arrWinList) Then ; List the open If $arrWinList[0][0] > 12 Then WinMove($guiForm1, "", @DesktopWidth/2 - 305, Default, 610, 378) EndIf For $i = 1 To $arrWinList[0][0] If $i < 13 Then $y = (($i - 1) * 28) + 8 Assign("guiButton" & $i, GUICtrlCreateButton($arrWinList[$i][0], 8, $y , 283, 25, $WS_GROUP)) ElseIf $i > 12 Then $y = (($i - 13) * 28) + 8 Assign("guiButton" & $i, GUICtrlCreateButton($arrWinList[$i][0], 305, $y, 283, 25, $WS_GROUP)) If $i = 24 Then ExitLoop EndIf EndIf Next EndIf GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") ; _ArrayDisplay($arrWinList) ; _arraydisplay works before a window is selected While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) ; if button is clicked, give popup confirming it. ;_ArrayDisplay($arrWinList) ; once a button is pressed, _arraydisplay locks up Local $hWndFrom, $iIDFrom, $iCode, $hWndEdit $hWndFrom = $ilParam $iIDFrom = _WinAPI_LoWord($iwParam) $iCode = _WinAPI_HiWord($iwParam) If $iCode = $BN_CLICKED Then $text = _GUICtrlButton_GetText ( $hWndFrom ) $arrPos = _ArraySearch($arrWinList, $text) _OrganizeFolder($arrWinList[$arrPos][1]) EndIf EndFunc Func _GetListOfOpenExplorerWindows($vIncludeArrayCount = 0, $vColumnReturn = 3) ; (0 = No, 1 = Yes), (1 = Short Names Only, 2 = Long Addresses, 3 or 1 + 2 = Return Both) Local $aWinList, $sGetText, $aWinText, $varStrLen, $sFormat, $i, $j, $k, $vRowsToDel $aWinList = WinList() Local $aOutput[0][2] $k = 0 For $i = 1 To $aWinList[0][0] $sGetText = WinGetText($aWinList[$i][0]) $aWinText = StringSplit($sGetText, @LF) For $j = 1 To $aWinText[0] If StringInStr($aWinText[$j], "Address:") Then $sFormat = StringReplace($aWinText[$j], "Address: ", "") If DirGetSize($sFormat) > -1 Then ReDim $aOutput[UBound($aOutput) + 1][2] $aOutput[$k][0] = $aWinList[$i][0] $aOutput[$k][1] = $sFormat $k += 1 EndIf EndIf Next Next For $i = 1 To UBound($aOutput) $varStrLen = StringLen($aOutput[$i - 1][0]) If $varStrLen = 0 Then $vRowsToDel = $vRowsToDel & $i - 1 & ";" EndIf Next $vRowsToDel = StringTrimRight($vRowsToDel, 1) _ArrayDelete($aOutput, $vRowsToDel) If $vIncludeArrayCount = 1 Then _ArrayInsert($aOutput, 0, UBound($aOutput)) EndIf If $vColumnReturn = 1 Then _ArrayColDelete($aOutput, 1) ElseIf $vColumnReturn = 2 Then If $vIncludeArrayCount = 1 Then If UBound($aOutput) > 0 Then $aOutput[0][1] = UBound($aOutput) EndIf EndIf _ArrayColDelete($aOutput, 0) EndIf If UBound($aOutput) = 0 Then Return -1 Else Return $aOutput EndIf EndFunc Func _OrganizeFolder($strFolderName) ; code to organize the content of the folder $arrFileList = _FileListToArrayRec($strFolderName & "\", "*", 1, 0) _ArrayDisplay($arrFileList) EndFunc
-
Or.. MsgBox(0, "", @Compiled)
-
Hi, AutoIt is a very powerful language. It can manage many of the tasks you described. In the Example Scripts section of this forum, there are UDFs (user defined functions) that make it easier to work with MS Word/Excel, VLC, PDFs, FF/Chrome (some UDFs won't work perfectly with newer browser versions, but AutoIt can work with Selenium, which does) and a lot more. AutoIt can interact with a lot of APIs and DLLs. Drivers? What do you want to do with them? Install them, then most likely, yes. AutoIt can work with databases, there are UDFs for that and native support for SQL Lite. I am not sure about working with dual or triple monitors. I saw someone ask a question about that yesterday, but I didn't even read it because I know absolutely nothing about the subject. It is possible to trigger events from one computer to another. However, AutoIt is Windows-based only, so it cannot be used on a cell phone (as far as I understand). It might be possible to write a phone app to interact with AutoIt, but I cannot say for sure. Perhaps one of the smarter forum users can better inform you. In any case, if AutoIt cannot fill all your needs, it could certainly be very useful to you. It is probably the easiest language to learn. And the support here is great. Good luck and we will help if we can!
-
This code is to detect all open Window Explorer windows. It returns a 1 or 2 dimension array, depending on the parameters you send. It returns the short name (basically, the folder name) and/or the full path to the folder. If no windows are open, it returns -1. To avoid errors, you should use IsArray to see if anything has been returned or check if the return value is -1. This function only returns data if there is a full address available (therefore, My Computer, Control Panel, My Documents, etc. will not be included). I can work on including these if anyone is interested. The code has some added code to delete repeat entries in the array because when I ran the original script with the script directory window open, it returned about 60 instances of that window. I don't know why that happened. When the script directory was not open, it returned the correct number of windows. The extra code is the only return unique instances in the array, with no duplicates, whether the script directory is open or not. If anyone wants to weigh in on why that happened, I'd love to hear about it. Enjoy! #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 #include <array.au3> Global $aList, $sWinList ; Example 1 $aList = _GetListOfOpenExplorerWindows(1, 3) If IsArray($aList) Then For $i = 1 To $aList[0][0] $sWinList = $sWinList & $aList[$i][0] & " | " & $aList[$i][1] & @CRLF Next ConsoleWrite($sWinList) _ArrayDisplay($aList) ElseIf $aList = -1 Then MsgBox(0, "", "No windows open.") EndIf ; End Example 1 ; Example 2 $aList = _GetListOfOpenExplorerWindows(1, 1) If IsArray($aList) Then _ArrayDisplay($aList) ElseIf $aList = -1 Then MsgBox(0, "", "No windows open.") EndIf $aList = _GetListOfOpenExplorerWindows(1, 2) If IsArray($aList) Then _ArrayDisplay($aList) ElseIf $aList = -1 Then MsgBox(0, "", "No windows open.") EndIf ; End Example 2 ; #FUNCTION# ========================================================================================================================================== ; Description ...: Retrieves a list of all open Windows Explorer windows ; Syntax ........: _GetListOfOpenExplorerWindows() ; Parameters ....: $vIncludeArrayCount: [optional] Include array count at array[0] or array[0][0] | [0 = No, 1 = Yes (Default)] ; $vColumnReturn: [optional] Array Column Return | [1 = Short Names Only, 2 = Full Addresses, 3 or 1 + 2 = Return Both (Default)] ; 1 and 2 are 1D arrays; 3 is a 2D array. ; Return values .: Success: An array (1D or 2D, depending on sent parameters). No open windows returns -1. Only works for windows that have ; a full address (ex: does not work with My Computer, Control Panel, My Documents, etc.). ; Failure: Returns -1 (No windows with full directory addresses are open). ; Author ........: abberration ; Example .......: Yes ; ===================================================================================================================================================== Func _GetListOfOpenExplorerWindows($vIncludeArrayCount = 1, $vColumnReturn = 3) Local $aWinList, $sGetText, $aWinText, $vStrLen, $sFormat, $i, $j, $k, $vRowsToDel $aWinList = WinList() Local $aOutput[0][2] $k = 0 For $i = 1 To $aWinList[0][0] $sGetText = WinGetText($aWinList[$i][0]) $aWinText = StringSplit($sGetText, @LF) For $j = 1 To $aWinText[0] If StringInStr($aWinText[$j], "Address: ") Then $sFormat = StringReplace($aWinText[$j], "Address: ", "") If DirGetSize($sFormat) > -1 Then ReDim $aOutput[UBound($aOutput) + 1][2] $aOutput[$k][0] = $aWinList[$i][0] $aOutput[$k][1] = $sFormat $k += 1 EndIf EndIf Next Next For $i = 1 To UBound($aOutput) $vStrLen = StringLen($aOutput[$i - 1][0]) If $vStrLen = 0 Then $vRowsToDel = $vRowsToDel & $i - 1 & ";" EndIf Next $vRowsToDel = StringTrimRight($vRowsToDel, 1) _ArrayDelete($aOutput, $vRowsToDel) If $vIncludeArrayCount = 1 Then _ArrayInsert($aOutput, 0, UBound($aOutput)) EndIf If $vColumnReturn = 1 Then _ArrayColDelete($aOutput, 1) ElseIf $vColumnReturn = 2 Then If $vIncludeArrayCount = 1 Then If UBound($aOutput) > 0 Then $aOutput[0][1] = UBound($aOutput) - 1 EndIf EndIf _ArrayColDelete($aOutput, 0) EndIf If UBound($aOutput) = 0 Then Return -1 Else Return $aOutput EndIf EndFunc
-
[Solved] Wingettext - extract address
abberration replied to abberration's topic in AutoIt General Help and Support
Ok, I just figured it out. It uses @LF, not @CR. It works now. Thanks! -
Hi, I'm starting to work on a small script where it will display all open Explorer windows so you can select the window you want. Using Wingettext, it appears to use @CR instead of @CRLF. I'm trying to extract the address. A messagebox shows this: However, writing it to a text file appears like this: I have tried some code like this: $s = WinGetText("[ACTIVE]") $a2 = StringSplit($s, @CR) _ArrayDisplay($a2) $s = StringReplace($s, @CR, @CRLF) FileWrite("test.txt", $s & @CRLF) I have also thought about using stringregex to extract the address, but I cannot think of any way to make that happen. How can I detect where the address ends and/or eliminate the text that comes afterwards? Thanks!
-
I read this post this morning and I never tried to override the value sent to a function before. I was puzzled why your attempt to override the sent value didn't work. Well, tonight I was working on a project totally separate from yours and discovered why what you are attempting did not work (just coincidence). Maybe my newfound knowledge can help. Check out this piece of code: $data1 = _FuncTest() $data2 = _FuncTest("#2", "This Is Something Different") Func _FuncTest($value1 = "#1", $value2 = "The Default Thing") MsgBox(0, "", $value1 & " " & $value2) Endfunc For $data1, nothing is sent, therefore the function assigns default values because nothing has been sent. For $data2, data has been sent, so that is what should be used. In creating AutoIt, I assume the creators had to make a choice, always use the values sent by calling the function or always override incoming data for what the user specifies when the function is actually called. If you don't have default values for incoming data and the number of parameters don't match (some or all parameters were not sent), the function crashes and burns. I hope this helps to understand the concept. BTW, IMO AutoIt is the easiest programming language to understand I have ever seen. Others should be taking notes. Cheers!
-
Hello, all! Today I present to you an updated version of Easy Mp3. After releasing version 1.0, I found several bugs that I fixed and added a few new features. Details can be found in the Changelog (check the Help menu). What makes Easy Mp3 special? Ease of use. I started this project because I love FLAC, but my car stereo does not and the transcoding programs out there are tedious to work with, have confusing settings, you cannot drop multiple folders into it and get a good result and finally, the nagging to buy it or check for updates. When you drag & drop a folder full of music, this program adds every supported file into the list of things to encode. All you have to do is select an output folder (personally, I have one folder called Mp3s). By default, it will create the same folder structure of the one that you dropped into it and it will place all of the encoded files in the respective folders. You also have the option to create folders from the metadata contained in the media. Here's what will convince you that this is the best Mp3 transcoder: download an entire discography by your favorite band and drop it into the program, select your output folder and click Encode. It's so simple, you will be amazed. By default, it uses the highest quality settings possible. It makes use of FFMpeg's built-in LAME codec. The download links are at the bottom of the screen. This package includes 32 & 64 bit executables, a user guide, a changelog and source code. I use this program all the time and I hope you love it as much as I had fun scripting it! Enjoy! Download from MEGA: Full package (includes FFMpeg): https://mega.nz/file/SXwUBK7L#aAN_6rDKi1tauQ0ngA4L0pUtD7S7rg66a9IUsl1say0 Lite Package (no FFMpeg): https://mega.nz/file/WLhynA5I#jEg-hnXCTEiWwM21vID9jUgZjaIKihl4pwEe4eQ2FV8 Download from FileFactory: Full package: http://www.filefactory.com/file/5gen99g7hsr6/Easy_Mp3_v1.1_Full.zip Lite package: http://www.filefactory.com/file/74xq8b69gso/Easy_Mp3_v1.1_Lite.zip
- 1 reply
-
- mp3 encoder
- mp3
-
(and 3 more)
Tagged with:
-
Hello, everyone! I haven't played with GDI+ functionality very much, but I have managed to insert some graphics into a script I'm writing. I noticed that when I move the Gui where the graphic is off screen or minimize and restore it, the image disappears (_GDIPlus_GraphicsDrawImage). The help file example for that function does the same thing, so I don't think I'm doing anything wrong. I have tried some workarounds such as starting a timer in the Case and every 2 seconds, redraw the image. However, _Timer_Diff runs continuously and the image gets redrawn way too much. I thought about detecting a minimize and restore and only redrawing it then, but I can't think of a way of detecting if someone moves the graphic off screen (well, I can but it would be lengthy). This isn't crucial for the program to work, so if it is a difficult solution, I just won't worry about it. Just wondering if anyone has any quick fixes. Thanks for any advice!
-
Look for AutoIt on Youtube. There are lots of videos that show you how to get started. Here is a playlist with 20 of them in the order you need:
-
Hi, everybody! I am writing an mp3 encoding program. During the encoding process, I want to have a cancel button but it seems that using case to detect the button has been pressed or using GUICtrlSetOnEvent do not work because (I think) RunWait(ffmpeg.exe.....) is stopping the script during the encode process and the button click is not recognized. HotKeySet detects a key press at any time and I have that working. I would rather have a button than ask the user to press ESC. Just wanted to see if there are any "simple" answers. I am not so advanced to understand pointers and memory reads. I can write up some example code if anyone wants, but to test you will need ffmpeg.exe (or maybe I can write a second exe that just takes up 5 seconds or so). It's curious, I searched DDG and only saw a couple questions on this topic. I have been working on this for a whole day and I would think more people would have this problem. Maybe it's just me... Thanks!