ReconX Posted November 25, 2020 Share Posted November 25, 2020 I am writing a little program to help me inventory my Blu-ray collection in Plex. What it does is, when I type in a name and year, it creates a dummy .mkv file for Plex to pick up. I've created a ComboBox to help me determine which directory to store the files in that is pre-determined in the Settings tab. When I select DVD from the ComboBox on the main tab, it is supposed to read the File Directory chosen by the user in the settings tab. I've set a test Label in the Test tab, but cannot get it to update. I hope I am explaining this to where someone will understand what I am trying to accomplish. Let me know if further information is needed. Thanks! expandcollapse popup#include <GUIConstantsEx.au3> #include <GUIConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPI.au3> ; Here is the array Global $aArray[4] = ["DVD", "Blu-ray", "4K", "3D"] Global $fileDIR = "C:\" $hTitle = "Add Movie to Inventory" ; And here we get the elements into a list $sList = "" For $i = 0 To UBound($aArray) - 1 $sList &= "|" & $aArray[$i] Next Example() Func Example() $hGUI = GUICreate($hTitle, 460) ; will create a dialog box that when displayed is centered $hTab = GUICtrlCreateTab(10, 10, 441, 380) GUICtrlCreateTabItem("Inventory Movie") GUICtrlCreateGroup("This tool creates dummy .mkv files, and puts them in the same directory as this script.", 20, 40, 420, 98) ;Start Group Opt("GUICoordMode", 0) $inputText1 = GUICtrlCreateLabel("Movie Name:", 10, 25, 75, 20) $inputName = GUICtrlCreateInput("", 90, -2, 289, 20) $tmdbSearch = GUICtrlCreateButton("+", 292, 0, 20, 20) $inputText2 = GUICtrlCreateLabel("Movie Year:", -382, 26, 75, 20) $inputYear = GUICtrlCreateInput("", 90, -2, 311, 20) $submit = GUICtrlCreateButton("Create", 90, 24, 221, 20) $hCombo = GUICtrlCreateCombo("", -90, -1, 80, 20, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL)) GUICtrlSetData($hCombo, $sList, "DVD") Opt("GUICoordMode", 1) ; GUI coords GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group GUICtrlCreateTabItem("Settings") GUICtrlCreateGroup("Directories", 20, 40, 420, 135) ;Start Group Opt("GUICoordMode", 0) GUIStartGroup() $inputText1 = GUICtrlCreateLabel("DVD:", 10, 25, 75, 20) $inputText2 = GUICtrlCreateLabel("Blu-ray:", -1, 26, 75, 20) $inputText3 = GUICtrlCreateLabel("4K:", -1, 26, 75, 20) $inputText4 = GUICtrlCreateLabel("3D:", -1, 26, 75, 20) GUIStartGroup() $hDVD = GUICtrlCreateInput("1234", 50, -80, 350, 20) $hBLU = GUICtrlCreateInput("", -1, 26, 350, 20) $h4K = GUICtrlCreateInput("", -1, 26, 350, 20) $h3D = GUICtrlCreateInput("", -1, 26, 350, 20) GUIStartGroup() $bDVD = GUICtrlCreateButton("...", 331, -77, 18, 18) $bBLU = GUICtrlCreateButton("...", -1, 26, 18, 18) $b4K = GUICtrlCreateButton("...", -1, 26, 18, 18) $b3D = GUICtrlCreateButton("...", -1, 26, 18, 18) Opt("GUICoordMode", 1) ; GUI coords GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group GUICtrlSetState($hDVD, $GUI_DISABLE) GUICtrlSetState($hBLU, $GUI_DISABLE) GUICtrlSetState($h4K, $GUI_DISABLE) GUICtrlSetState($h3D, $GUI_DISABLE) GUICtrlCreateTabItem("TEST") GUICtrlCreateLabel($fileDIR , 30, 80, 50, 20) $TESTING = GUICtrlRead($hDVD) GUICtrlCreateLabel($TESTING, 30, 200, 50, 20) GUICtrlCreateTabItem("") ; end tabitem definition GUISetState(@SW_SHOW) $guiRead = GUICtrlRead($hCombo) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $submit $movieName = GUICtrlRead($inputName) $movieYear = GUICtrlRead($inputYear) If FileExists($movieName & " (" & $movieYear & ").mkv") Then MsgBox($MB_SYSTEMMODAL, "Movie Exists!!!!", "This Movie Already Exists!!!!", 10) GUICtrlSetData($inputName, "") GUICtrlSetData($inputYear, "") _WinAPI_SetFocus(ControlGetHandle("", "", $inputName)) Else FileWrite($movieName & " (" & $movieYear & ").mkv", "PLACEHOLDER") GUICtrlSetData($inputName, "") GUICtrlSetData($inputYear, "") _WinAPI_SetFocus(ControlGetHandle("", "", $inputName)) EndIf Case $tmdbSearch $movieName = GUICtrlRead($inputName) ShellExecute("https://www.themoviedb.org/search?query=" & $movieName) WinActivate($hGUI) _WinAPI_SetFocus(ControlGetHandle("", "", $inputYear)) ;~ Case $test ;~ ; Create a constant variable in Local scope of the message to display in FileSelectFolder. ;~ Local $sMessage = "Select a folder" ;~ ; Display an open dialog to select a file. ;~ Local $sFileSelectFolder = FileSelectFolder($sMessage, "") ;~ If @error Then ;~ ; Display the error message. ;~ MsgBox($MB_SYSTEMMODAL, "", "No folder was selected.") ;~ Else ;~ ; Display the selected folder. ;~ MsgBox($MB_SYSTEMMODAL, "", "You chose the following folder:" & @CRLF & $sFileSelectFolder) ;~ EndIf ;~ GUICtrlSetData($hDVD, $sFileSelectFolder) Case $bDVD Local $sDVDFolder = FileSelectFolder("Select a folder...", "%CSIDL_DRIVES%") If @error Then MsgBox($MB_SYSTEMMODAL, "", "No folder was selected.") Else GUICtrlSetData($hDVD, $sDVDFolder) EndIf Case $hCombo If $guiRead = $aArray[0] Then GUICtrlSetData($fileDIR, $guiRead) ;~ $fileDIR = GUICtrlRead($hDVD) Else ExitLoop EndIf EndSwitch WEnd EndFunc ;==>Example Link to comment Share on other sites More sharing options...
cgmiapapi Posted November 25, 2020 Share Posted November 25, 2020 To clarify "if" you select DVD in the ComboBox, you want it to read the corresponding input box labeled DVD? "If" that is the case you can move this $guiRead = GUICtrlRead($hCombo) into your Case $hCombo and use some "If" statements If $guiRead == "DVD" then GuiCtrlread($hDVD) endif Link to comment Share on other sites More sharing options...
ReconX Posted November 25, 2020 Author Share Posted November 25, 2020 (edited) Yes, so if I select DVD in the ComboBox, I want it to read the input box labeled DVD and set it to $fileDIR. The same will go for Blu-ray if I were to select it in the ComboBox, it would read the Input Box labeled Blu-ray and set that to $fileDIR. I've set a variable of $fileDIR which will be the directory selected through the ComboBox. So, if the directory listed in the input box labeled DVD is, "C:\DVD", and the ComboBox has DVD selected, I would want; FileWrite($fileDIR & "\" & $movieName & " (" & $movieYear & ").mkv", "PLACEHOLDER") to read, "C:\DVD\Moviename (2020).mkv". I'm quite new to AutoIt, so please excuse my coding and explanations. Edited November 25, 2020 by ReconX Link to comment Share on other sites More sharing options...
boom221 Posted November 26, 2020 Share Posted November 26, 2020 I think that's how you would detect an update on a combo box expandcollapse popup#include <GUIConstantsEx.au3> #include <GUIConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> AutoItSetOption("MustDeclareVars", 1) Local $GUIHandle = GUICreate("Test", 200, 100) ; will create a dialog box that when displayed is centered Local $comboBox = GUICtrlCreateCombo("", 5, 5, 80, 20) GUICtrlSetData($comboBox, "Luke|use|the|force", "use") Local $label = GUICtrlCreateLabel("", 5, 30, 150, 20) GUIRegisterMsg($WM_COMMAND, "My_WM_COMMAND") GUISetState(@SW_SHOW, $GUIHandle) Local $comboBoxChangedFlag = True Local $close = False While Not $close Local $event = GUIGetMsg($GUI_EVENT_SINGLE) Switch $event Case $GUI_EVENT_CLOSE $close = True Case Else ; Do nothing EndSwitch If $comboBoxChangedFlag Then GUICtrlSetData($label, GUICtrlRead($comboBox)) $comboBoxChangedFlag = False EndIf WEnd Func My_WM_COMMAND($hWnd, $imsg, $iwParam, $ilParam) Local $windowHandle = $ilParam Local $controlId = _WinAPI_LoWord($iwParam) Local $eventId = _WinAPI_HiWord($iwParam) If $windowHandle <> 0 Then Switch $controlId Case $comboBox Switch $eventId Case $CBN_SELCHANGE $comboBoxChangedFlag = True Case Else ; Do nothing. Endswitch Case Else ; Do nothing. Endswitch EndIf Return $GUI_RUNDEFMSG EndFunc Found it in a post from @Melba23 at this https://www.autoitscript.com/forum/topic/104923-wm_command/ Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 26, 2020 Moderators Share Posted November 26, 2020 boom221 & ReconX, You only need a WM_COMMAND handler when dealing with edit controls which do not fire a GUIGetMsg-detectable event when the content is changed - which is why one was needed in the thread to which you linked. When dealing with a combo you can simply use the GUIGetMsg loop to detect changes: #include <GUIConstantsEx.au3> AutoItSetOption("MustDeclareVars", 1) Local $GUIHandle = GUICreate("Test", 200, 100) ; will create a dialog box that when displayed is centered Local $comboBox = GUICtrlCreateCombo("", 5, 5, 80, 20) GUICtrlSetData($comboBox, "Luke|use|the|force", "use") Local $label = GUICtrlCreateLabel("", 5, 30, 150, 20) GUISetState(@SW_SHOW, $GUIHandle) Local $close = False While Not $close Local $event = GUIGetMsg() Switch $event Case $GUI_EVENT_CLOSE $close = True Case $comboBox GUICtrlSetData($label, GUICtrlRead($comboBox)) EndSwitch WEnd Rather simpler and definitely more elegant! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now