MattHiggs Posted July 17, 2016 Share Posted July 17, 2016 Good Morning autoit forum viewers. So I have the following code: expandcollapse popup#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <GuiComboBox.au3> #include <GUIListBox.au3> #include <StaticConstants.au3> #include <File.au3> #include <WindowsConstants.au3> #include <Constants.au3> #Region ### START Koda GUI section ### Form=c:\users\whiggs\onedrive\always script\form\openjv3.kxf $Form1 = GUICreate("H Launcher", 500, 593, 192, 124, BitOR($GUI_SS_DEFAULT_GUI,$DS_SETFOREGROUND), BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE)) $MenuItem1 = GUICtrlCreateMenu("Add") $MenuItem2 = GUICtrlCreateMenuItem("Folder", $MenuItem1) $Label1 = GUICtrlCreateLabel("Pick your poison", 176, 16, 147, 29) GUICtrlSetFont(-1, 15, 400, 0, "MS Sans Serif") $dumm = GUICtrlCreateDummy() $Combo1 = GUICtrlCreateCombo("", 40, 56, 409, 25, BitOR($GUI_SS_DEFAULT_COMBO,$CBS_SIMPLE,$CBS_SORT,$WS_HSCROLL)) GUICtrlSetTip(-1, "Select the path you wish to view....") $List1 = GUICtrlCreateList("", 24, 96, 449, 422, BitOR($LBS_NOTIFY, $LBS_MULTIPLESEL, $LBS_HASSTRINGS, $WS_VSCROLL, $WS_BORDER)) $Button1 = GUICtrlCreateButton("Open", 48, 536, 89, 33, $BS_NOTIFY) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlSetCursor (-1, 0) $Button2 = GUICtrlCreateButton("Exit", 360, 536, 81, 33, $BS_NOTIFY) GUICtrlSetCursor (-1, 0) $Button3 = GUICtrlCreateButton("Common manga", 152, 536, 89, 33, $BS_NOTIFY) GUICtrlSetCursor (-1, 0) $Button4 = GUICtrlCreateButton("Common Movie", 256, 536, 81, 33) GUICtrlSetCursor (-1, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### If Not FileExists ( @ScriptDir & "\settings.ini" ) Then addPath() Else $array2 = IniReadSection ( @ScriptDir & "\settings.ini", "settings" ) Local $store2[$array2[0][0]] $here2 = 0 For $i = 1 To $array2[0][0] Step 1 GUICtrlSetData ( $Combo1, $array2[$i][1] ) ; $here2 += 1 Next ;GUICtrlSetData ( $Combo1, $store2 ) EndIf GUIRegisterMsg($WM_COMMAND, "doubleClick") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $MenuItem2 addPath() Case $Combo1 $use = GUICtrlRead ( $Combo1 ) If Not FileExists ( $use ) Then #Region --- CodeWizard generated code Start --- ;MsgBox features: Title=Yes, Text=Yes, Buttons=OK, Icon=None, Miscellaneous=Top-most attribute MsgBox($MB_OK + 262144,"invalid path","the path you selected does not exist or is inaccessible on local device/using current user.") #EndRegion --- CodeWizard generated code End --- Else GUICtrlSetState ( $Button1, 128 ) GUICtrlSetStyle ($List1, BitOR($LBS_NOTIFY, $LBS_MULTIPLESEL, $LBS_HASSTRINGS, $WS_VSCROLL, $WS_BORDER)) $thelist = _FileListToArrayRec ( $use, "*", Default, Default, $FLTAR_SORT, Default ) For $i = 1 To $thelist[0] Step 1 GUICtrlSetData ( $List1, $thelist[$i] ) Next EndIf Case $List1 $listselect = _GUICtrlListBox_GetSelItemsText ( $List1 ) If $listselect[0] > 0 Then GUICtrlSetState ( $Button1, 64 ) Else GUICtrlSetState ( $Button1, 128 ) EndIf Case $Button1 $listsel = _GUICtrlListBox_GetSelItemsText ( $List1 ) For $f = 1 To $listsel[0] Step 1 If StringRight ( $listsel[$f], 4 ) == ".mp4" Or StringRight ( $listsel[$f], 4 ) == ".flv" Then ShellExecute ( $listsel[$f], "", GUICtrlRead ( $Combo1 ), "open" ) Else $again2 = _FileListToArrayRec ( GUICtrlRead ( $Combo1 ) & "\" & $listsel[$f], "*", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT, Default ) $th2 = "" For $r = 1 To $again2[0] Step 1 $spl2 = StringSplit ( $again2[$r], "\" ) $pic2 = False If StringRight ( $again2[$r], 4 ) == ".jpg" Or StringRight ( $again2[$r], 4 ) == ".png" Then $pic2 = True Else $pic2 = False EndIf If StringCompare ( $spl2[$spl2[0] - 1], $th2 ) <> 0 And $pic2 = True Then $th2 = $spl2[$spl2[0] - 1] $tooo2 = "" For $v = 1 To $spl2[0] - 1 Step 1 $tooo2 = $tooo2 & "\" & $spl2[$v] Next ShellExecute ( $spl2[$spl2[0]], "", GUICtrlRead ( $Combo1 ) & "\" & $listsel[$f] & $tooo2, "open" ) Else ContinueLoop EndIf Next EndIf Next Case $Button2 Exit Case $Button3 $ind = _GUICtrlComboBox_SelectString ( $Combo1, "\\WILLSERVER\bootcd\NeoDownloader" ) GUICtrlSendToDummy ( $Combo1 ) EndSwitch WEnd Func addPath () If Not FileExists ( @ScriptDir & "\settings.ini" ) Then #Region --- CodeWizard generated code Start --- ;MsgBox features: Title=Yes, Text=Yes, Buttons=OK, Icon=Info MsgBox($MB_OK + $MB_ICONASTERISK,"Select paths","You need to select some paths so program knows where to look") #EndRegion --- CodeWizard generated code End --- $hold = 0 Else $hold = IniReadSection ( @ScriptDir & "\settings.ini", "settings" ) EndIf Do $init = FileSelectFolder ( "Select path to add", "" ) If $init <> "" Then If IsArray ( $hold ) Then $hold[0][0] += 1 IniWrite ( @ScriptDir & "\settings.ini", "settings", "path " & $hold[0][0], $init ) Else $hold += 1 IniWrite ( @ScriptDir & "\settings.ini", "settings", "path " & $hold, $init ) EndIf EndIf #Region --- CodeWizard generated code Start --- ;MsgBox features: Title=Yes, Text=Yes, Buttons=Yes and No, Icon=None If Not IsDeclared("continue") Then Local $continue $continue = MsgBox($MB_YESNO,"More?","Are there any more you would like to enter?") Until $continue = $IDNO $array = IniReadSection ( @ScriptDir & "\settings.ini", "settings" ) Local $store[$array[0][0]] $here = 0 For $i = 1 To $array[0][0] Step 1 GUICtrlSetData ( $Combo1, $array[$i][1] ) ;$here += 1 Next ;GUICtrlSetData ( $Combo1, $store ) EndFunc #EndRegion --- CodeWizard generated code End --- Func doubleClick($hWnd, $Msg, $wParam, $lParam) $nNotifyCode = BitShift($wParam, 16) $nID = BitAND($wParam, 0x0000FFFF) $hCtrl = $lParam Select Case $nID = $List1 Switch $nNotifyCode Case $LBN_DBLCLK $one = GUICtrlRead($List1) If StringRight ( $one, 4 ) == ".mp4" Or StringRight ( $one, 4 ) == ".flv" Then ShellExecute ( $one, "", GUICtrlRead ( $Combo1 ), "open" ) Else $again = _FileListToArrayRec ( GUICtrlRead ( $Combo1 ) & "\" & $one, "*", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT, Default ) $th = "" For $o = 1 To $again[0] Step 1 $spl = StringSplit ( $again[$o], "\" ) $pic = False If StringRight ( $again[$o], 4 ) == ".jpg" Or StringRight ( $again[$o], 4 ) == ".png" Then $pic = True Else $pic = False EndIf If StringCompare ( $spl[$spl[0] - 1], $th ) <> 0 And $pic = True Then $th = $spl[$spl[0] - 1] $tooo = "" For $p = 1 To $spl[0] - 1 Step 1 $tooo = $tooo & "\" & $spl[$p] Next ShellExecute ( $spl[$spl[0]], "", GUICtrlRead ( $Combo1 ) & "\" & $one & $tooo, "open" ) Else ContinueLoop EndIf Next EndIf EndSwitch EndSelect EndFunc My issue occurs when GUIGetmsg = $button3. The content of the combobox (supposedly) changes (the values contained in the combobox are paths to folders) using one of the User defined functions, but the actions which are supposed to be performed which GUIGetMessage = $combo1 aren't being performed (I assume because the actual combox has not been clicked). My question is simply this: I was under the impression that there was a way similar to a function call to initiate execution of the script block for a particular control without 1) copying the code and 2) clicking the device (which is pointless even if clicked, since the correct value in the combobox needs to be selected in order for GUIgetmessage to read the value. Thanks in advance. Link to comment Share on other sites More sharing options...
AutoBert Posted July 17, 2016 Share Posted July 17, 2016 (edited) You use GUICtrlSendToDummy with a ComboBoxControl, this couldn't work: Quote GUICtrlSendToDummy Sends a message to a Dummy control. can only be used with a Dummy Control (GUICtrlCreateDummy). But using ContinueCase should work: expandcollapse popup#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <GuiComboBox.au3> #include <GUIListBox.au3> #include <StaticConstants.au3> #include <File.au3> #include <WindowsConstants.au3> #include <Constants.au3> #Region ### START Koda GUI section ### Form=c:\users\whiggs\onedrive\always script\form\openjv3.kxf $Form1 = GUICreate("H Launcher", 500, 593, 192, 124, BitOR($GUI_SS_DEFAULT_GUI, $DS_SETFOREGROUND), BitOR($WS_EX_TOPMOST, $WS_EX_WINDOWEDGE)) $MenuItem1 = GUICtrlCreateMenu("Add") $MenuItem2 = GUICtrlCreateMenuItem("Folder", $MenuItem1) $Label1 = GUICtrlCreateLabel("Pick your poison", 176, 16, 147, 29) GUICtrlSetFont(-1, 15, 400, 0, "MS Sans Serif") $dumm = GUICtrlCreateDummy() $Combo1 = GUICtrlCreateCombo("", 40, 56, 409, 25, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE, $CBS_SORT, $WS_HSCROLL)) GUICtrlSetTip(-1, "Select the path you wish to view....") $List1 = GUICtrlCreateList("", 24, 96, 449, 422, BitOR($LBS_NOTIFY, $LBS_MULTIPLESEL, $LBS_HASSTRINGS, $WS_VSCROLL, $WS_BORDER)) $Button1 = GUICtrlCreateButton("Open", 48, 536, 89, 33, $BS_NOTIFY) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlSetCursor(-1, 0) $Button2 = GUICtrlCreateButton("Exit", 360, 536, 81, 33, $BS_NOTIFY) GUICtrlSetCursor(-1, 0) $Button3 = GUICtrlCreateButton("Common manga", 152, 536, 89, 33, $BS_NOTIFY) GUICtrlSetCursor(-1, 0) $Button4 = GUICtrlCreateButton("Common Movie", 256, 536, 81, 33) GUICtrlSetCursor(-1, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### If Not FileExists(@ScriptDir & "\settings.ini") Then addPath() Else $array2 = IniReadSection(@ScriptDir & "\settings.ini", "settings") Local $store2[$array2[0][0]] $here2 = 0 For $i = 1 To $array2[0][0] Step 1 GUICtrlSetData($Combo1, $array2[$i][1]) ; $here2 += 1 Next ;GUICtrlSetData ( $Combo1, $store2 ) EndIf GUIRegisterMsg($WM_COMMAND, "doubleClick") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $MenuItem2 addPath() Case $Button3 $ind = _GUICtrlComboBox_SelectString($Combo1, "\\WILLSERVER\bootcd\NeoDownloader") ContinueCase Case $Combo1 $use = GUICtrlRead($Combo1) If Not FileExists($use) Then #Region --- CodeWizard generated code Start --- ;MsgBox features: Title=Yes, Text=Yes, Buttons=OK, Icon=None, Miscellaneous=Top-most attribute MsgBox($MB_OK + 262144, "invalid path", "the path you selected does not exist or is inaccessible on local device/using current user.") #EndRegion --- CodeWizard generated code Start --- Else GUICtrlSetState($Button1, 128) GUICtrlSetStyle($List1, BitOR($LBS_NOTIFY, $LBS_MULTIPLESEL, $LBS_HASSTRINGS, $WS_VSCROLL, $WS_BORDER)) $thelist = _FileListToArrayRec($use, "*", Default, Default, $FLTAR_SORT, Default) For $i = 1 To $thelist[0] Step 1 GUICtrlSetData($List1, $thelist[$i]) Next EndIf Case $List1 $listselect = _GUICtrlListBox_GetSelItemsText($List1) If $listselect[0] > 0 Then GUICtrlSetState($Button1, 64) Else GUICtrlSetState($Button1, 128) EndIf Case $Button1 $listsel = _GUICtrlListBox_GetSelItemsText($List1) For $f = 1 To $listsel[0] Step 1 If StringRight($listsel[$f], 4) == ".mp4" Or StringRight($listsel[$f], 4) == ".flv" Then ShellExecute($listsel[$f], "", GUICtrlRead($Combo1), "open") Else $again2 = _FileListToArrayRec(GUICtrlRead($Combo1) & "\" & $listsel[$f], "*", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT, Default) $th2 = "" For $r = 1 To $again2[0] Step 1 $spl2 = StringSplit($again2[$r], "\") $pic2 = False If StringRight($again2[$r], 4) == ".jpg" Or StringRight($again2[$r], 4) == ".png" Then $pic2 = True Else $pic2 = False EndIf If StringCompare($spl2[$spl2[0] - 1], $th2) <> 0 And $pic2 = True Then $th2 = $spl2[$spl2[0] - 1] $tooo2 = "" For $v = 1 To $spl2[0] - 1 Step 1 $tooo2 = $tooo2 & "\" & $spl2[$v] Next ShellExecute($spl2[$spl2[0]], "", GUICtrlRead($Combo1) & "\" & $listsel[$f] & $tooo2, "open") Else ContinueLoop EndIf Next EndIf Next Case $Button2 Exit EndSwitch WEnd Func addPath() If Not FileExists(@ScriptDir & "\settings.ini") Then #Region --- CodeWizard generated code Start --- ;MsgBox features: Title=Yes, Text=Yes, Buttons=OK, Icon=Info MsgBox($MB_OK + $MB_ICONASTERISK, "Select paths", "You need to select some paths so program knows where to look") #EndRegion --- CodeWizard generated code Start --- $hold = 0 Else $hold = IniReadSection(@ScriptDir & "\settings.ini", "settings") EndIf Do $init = FileSelectFolder("Select path to add", "") If $init <> "" Then If IsArray($hold) Then $hold[0][0] += 1 IniWrite(@ScriptDir & "\settings.ini", "settings", "path " & $hold[0][0], $init) Else $hold += 1 IniWrite(@ScriptDir & "\settings.ini", "settings", "path " & $hold, $init) EndIf EndIf #Region --- CodeWizard generated code Start --- ;MsgBox features: Title=Yes, Text=Yes, Buttons=Yes and No, Icon=None If Not IsDeclared("continue") Then Local $continue $continue = MsgBox($MB_YESNO, "More?", "Are there any more you would like to enter?") Until $continue = $IDNO $array = IniReadSection(@ScriptDir & "\settings.ini", "settings") Local $store[$array[0][0]] $here = 0 For $i = 1 To $array[0][0] Step 1 GUICtrlSetData($Combo1, $array[$i][1]) ;$here += 1 Next ;GUICtrlSetData ( $Combo1, $store ) EndFunc ;==>addPath #EndRegion --- CodeWizard generated code Start --- Func doubleClick($hWnd, $Msg, $wParam, $lParam) $nNotifyCode = BitShift($wParam, 16) $nID = BitAND($wParam, 0x0000FFFF) $hCtrl = $lParam Select Case $nID = $List1 Switch $nNotifyCode Case $LBN_DBLCLK $one = GUICtrlRead($List1) If StringRight($one, 4) == ".mp4" Or StringRight($one, 4) == ".flv" Then ShellExecute($one, "", GUICtrlRead($Combo1), "open") Else $again = _FileListToArrayRec(GUICtrlRead($Combo1) & "\" & $one, "*", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT, Default) $th = "" For $o = 1 To $again[0] Step 1 $spl = StringSplit($again[$o], "\") $pic = False If StringRight($again[$o], 4) == ".jpg" Or StringRight($again[$o], 4) == ".png" Then $pic = True Else $pic = False EndIf If StringCompare($spl[$spl[0] - 1], $th) <> 0 And $pic = True Then $th = $spl[$spl[0] - 1] $tooo = "" For $p = 1 To $spl[0] - 1 Step 1 $tooo = $tooo & "\" & $spl[$p] Next ShellExecute($spl[$spl[0]], "", GUICtrlRead($Combo1) & "\" & $one & $tooo, "open") Else ContinueLoop EndIf Next EndIf EndSwitch EndSelect EndFunc ;==>doubleClick Edit: you should also insert more errorchecking, may it runs for you but not for me: "C:\Users\Bert\AutoIt3.My\Temp\test2.au3" (88) : ==> Subscript used on non-accessible variable.: For $r = 1 To $again2[0] Step 1 For $r = 1 To $again2^ ERROR ->18:01:19 AutoIt3.exe ended.rc:1 i used $Button1 on a *.au3 file not on folder so $again2 isn't a array so just check this. May there are more user's didn't know how to use your script and it chrash's. @Melba23: your suggestion is better for script reading than mine. I don't like ContinueCase, but hadn't thougt on easiest solution. Edited July 17, 2016 by AutoBert Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 17, 2016 Moderators Share Posted July 17, 2016 MattHiggs, Create a second dummy control and add that to the $combo1 case. You then need to fire it by using GUICtrlSendToDummy within the $combo1 code - at the moment you are trying to fire the combo directly which does not work. Here is a simplified version of your script showing what I mean: #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> $Form1 = GUICreate("H Launcher", 500, 593, 192, 124) $cNew_Dummy = GUICtrlCreateDummy() ; Create dummy <<<<<<<<<<<<<<<<<<<<<<<< $Combo1 = GUICtrlCreateCombo("", 40, 56, 409, 25) GUICtrlSetData($Combo1, "1|2|3|4") $Button3 = GUICtrlCreateButton("Common manga", 152, 536, 89, 33) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Combo1, $cNew_Dummy ; Add dummy here <<<<<<<<<<<<<<<<<<<<<<<<<<<< MsgBox($MB_SYSTEMMODAL, "Event", "Combo") Case $Button3 MsgBox($MB_SYSTEMMODAL, "Event", "Button") GUICtrlSendToDummy($cNew_Dummy) ; Fire dummy <<<<<<<<<<<<<<<<<<<<<<<< ;GUICtrlSendToDummy ( $Combo1 ) ; not the combo EndSwitch WEnd M23 Skysnake 1 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...
Skysnake Posted July 19, 2016 Share Posted July 19, 2016 @Melba23 thank you. You just solved a problem for me too I have been using this in some places, but the Dummy is a much better solution I have also used _GuiCtrlButton_Click() - which does not seem well documented at all... What is your opinion on this specific function? Rather use the Dummy() controls? Skysnake Why is the snake in the sky? 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