samonlinesuper Posted September 6, 2011 Share Posted September 6, 2011 Dear all, I created below GUI and wants to have the select items to RUN while the "RUN" button is pressed. I already tried a lots of ways but failed, could anyone help me, thank you. #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> #include <Array.au3> Global $aItem[6][2] = [[5,""],["Upgrade/Downloadgrade,0],["Item2",0],["Item3",0],["Item4",0],["Item5",0]] $DualListDlg = GUICreate("Choices Dialog", 751, 514, 247, 156) GUISetIcon("", -1) $ListBox1 = GUICtrlCreateList("", 8, 8, 305, 227, BitOR($GUI_SS_DEFAULT_LIST,$LBS_MULTIPLESEL)) $Button1 = GUICtrlCreateButton(">", 332, 15, 31, 25) $Button2 = GUICtrlCreateButton(">>", 332, 48, 31, 25) $Button3 = GUICtrlCreateButton("<", 332, 81, 31, 25) ;GUICtrlSetState(-1, $GUI_DISABLE) $Button4 = GUICtrlCreateButton("<<", 332, 114, 31, 25) $ListBox2 = GUICtrlCreateList("", 384, 8, 331, 227, $LBS_MULTIPLESEL) $Button5 = GUICtrlCreateButton("&RUN", 112, 273, 75, 25) $Button6 = GUICtrlCreateButton("&CLOSE", 192, 273, 75, 25) ; $Button7 = GUICtrlCreateButton("&Help", 272, 273, 75, 25) GUISetState(@SW_SHOW) Update_Listviews() While 1 $msg = GUIGetMsg() Switch $msg Case $Button1 Shift($ListBox1, 1) Update_Listviews() Case $Button3 Shift($ListBox2, 0) Update_Listviews() Case $Button6, $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func Update_Listviews() ; scan array and reload listboxes accordingly Local $str1, $str2 For $x = 1 to $aItem[0][0] ; loop through array If $aItem[$x][1] Then ; if 1, add to right listbox string $str2 &= $aItem[$x][0] & "|" Else ; if 0, add to left listbox string $str1 &= $aItem[$x][0] & "|" EndIf Next GUICtrlSetData($ListBox1, "") GUICtrlSetData($ListBox1, StringTrimRight($str1, 1)) ; strip trailing "|" and load to left listbox GUICtrlSetData($ListBox2, "") GUICtrlSetData($ListBox2, StringTrimRight($str2, 1)) ; strip trailing "|" and load to right listbox EndFunc Func Shift($control, $dest) Local $row = 0 For $x = 1 to $aItem[0][0] ; loop through array If $aItem[$x][1] <> $dest Then ; is array element not already in dest listbox? If _GUICtrlListBox_GetSel($control, $row) Then $aItem[$x][1] = $dest ; if row selected , move array element $row += 1 EndIf Next EndFunc Link to comment Share on other sites More sharing options...
monoscout999 Posted September 6, 2011 Share Posted September 6, 2011 I don`t know what you mean with "RUN" the list items. Please use the Code or AutoIt forum tags to post code it much nicer. [AUTOIT][/AUTOIT] --------> ] Here the code [ Link to comment Share on other sites More sharing options...
samonlinesuper Posted September 6, 2011 Author Share Posted September 6, 2011 Dears, Sorry, I am new in this forum and AutoIT. I don't know what you mean about to past the code but anyway, the code is like below: #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> #include <Array.au3> Global $aItem[6][2] = [[5,""],["Upgrade/Downloadgrade,0],["Item2",0],["Item3",0],["Item4",0],["Item5",0]] $DualListDlg = GUICreate("Choices Dialog", 751, 514, 247, 156) GUISetIcon("", -1) $ListBox1 = GUICtrlCreateList("", 8, 8, 305, 227, BitOR($GUI_SS_DEFAULT_LIST,$LBS_MULTIPLESEL)) $Button1 = GUICtrlCreateButton(">", 332, 15, 31, 25) $Button2 = GUICtrlCreateButton(">>", 332, 48, 31, 25) $Button3 = GUICtrlCreateButton("<", 332, 81, 31, 25) ;GUICtrlSetState(-1, $GUI_DISABLE) $Button4 = GUICtrlCreateButton("<<", 332, 114, 31, 25) $ListBox2 = GUICtrlCreateList("", 384, 8, 331, 227, $LBS_MULTIPLESEL) $Button5 = GUICtrlCreateButton("&RUN", 112, 273, 75, 25) $Button6 = GUICtrlCreateButton("&CLOSE", 192, 273, 75, 25) ; $Button7 = GUICtrlCreateButton("&Help", 272, 273, 75, 25) GUISetState(@SW_SHOW) Update_Listviews() While 1 $msg = GUIGetMsg() Switch $msg Case $Button1 Shift($ListBox1, 1) Update_Listviews() Case $Button3 Shift($ListBox2, 0) Update_Listviews() Case $Button6, $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func Update_Listviews() ; scan array and reload listboxes accordingly Local $str1, $str2 For $x = 1 to $aItem[0][0] ; loop through array If $aItem[$x][1] Then ; if 1, add to right listbox string $str2 &= $aItem[$x][0] & "|" Else ; if 0, add to left listbox string $str1 &= $aItem[$x][0] & "|" EndIf Next GUICtrlSetData($ListBox1, "") GUICtrlSetData($ListBox1, StringTrimRight($str1, 1)) ; strip trailing "|" and load to left listbox GUICtrlSetData($ListBox2, "") GUICtrlSetData($ListBox2, StringTrimRight($str2, 1)) ; strip trailing "|" and load to right listbox EndFunc Func Shift($control, $dest) Local $row = 0 For $x = 1 to $aItem[0][0] ; loop through array If $aItem[$x][1] <> $dest Then ; is array element not already in dest listbox? If _GUICtrlListBox_GetSel($control, $row) Then $aItem[$x][1] = $dest ; if row selected , move array element $row += 1 EndIf Next EndFunc The "RUN" means to "Execute". What I did now is to create Menu list and have the items select from left then press ">" button to right listbox. After that, I can press "RUN" to "execute" those items in the Right listbox. Thank you for helping. Link to comment Share on other sites More sharing options...
ajag Posted September 6, 2011 Share Posted September 6, 2011 (edited) Put [AUT0IT] in top of your code, and [/AUT0IT] below your code here in forum posts. Then your code looks much better: expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> #include <Array.au3> Global $aItem[6][2] = [[5,""],["Upgrade/Downloadgrade,0],["Item2",0],["Item3",0],["Item4",0],["Item5",0]] $DualListDlg = GUICreate("Choices Dialog", 751, 514, 247, 156) GUISetIcon("", -1) $ListBox1 = GUICtrlCreateList("", 8, 8, 305, 227, BitOR($GUI_SS_DEFAULT_LIST,$LBS_MULTIPLESEL)) $Button1 = GUICtrlCreateButton(">", 332, 15, 31, 25) $Button2 = GUICtrlCreateButton(">>", 332, 48, 31, 25) $Button3 = GUICtrlCreateButton("<", 332, 81, 31, 25) ;GUICtrlSetState(-1, $GUI_DISABLE) $Button4 = GUICtrlCreateButton("<<", 332, 114, 31, 25) $ListBox2 = GUICtrlCreateList("", 384, 8, 331, 227, $LBS_MULTIPLESEL) $Button5 = GUICtrlCreateButton("&RUN", 112, 273, 75, 25) $Button6 = GUICtrlCreateButton("&CLOSE", 192, 273, 75, 25) ; $Button7 = GUICtrlCreateButton("&Help", 272, 273, 75, 25) GUISetState(@SW_SHOW) Update_Listviews() While 1 $msg = GUIGetMsg() Switch $msg Case $Button1 Shift($ListBox1, 1) Update_Listviews() Case $Button3 Shift($ListBox2, 0) Update_Listviews() Case $Button6, $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func Update_Listviews() ; scan array and reload listboxes accordingly Local $str1, $str2 For $x = 1 to $aItem[0][0] ; loop through array If $aItem[$x][1] Then ; if 1, add to right listbox string $str2 &= $aItem[$x][0] & "|" Else ; if 0, add to left listbox string $str1 &= $aItem[$x][0] & "|" EndIf Next GUICtrlSetData($ListBox1, "") GUICtrlSetData($ListBox1, StringTrimRight($str1, 1)) ; strip trailing "|" and load to left listbox GUICtrlSetData($ListBox2, "") GUICtrlSetData($ListBox2, StringTrimRight($str2, 1)) ; strip trailing "|" and load to right listbox EndFunc Func Shift($control, $dest) Local $row = 0 For $x = 1 to $aItem[0][0] ; loop through array If $aItem[$x][1] <> $dest Then ; is array element not already in dest listbox? If _GUICtrlListBox_GetSel($control, $row) Then $aItem[$x][1] = $dest ; if row selected , move array element $row += 1 EndIf Next EndFunc Execute the Items? What shall happen when executing "Upgrade/Downloadgrade"? A-Jay Edited September 6, 2011 by ajag Rule #1: Always do a backup        Rule #2: Always do a backup (backup of rule #1) Link to comment Share on other sites More sharing options...
samonlinesuper Posted September 6, 2011 Author Share Posted September 6, 2011 When pressed then "Upgrade/Downgrade" item will start to do the upgrade process (By the way, this upgrade/download is for the "smart device" not for windows itself), thank you. Link to comment Share on other sites More sharing options...
monoscout999 Posted September 7, 2011 Share Posted September 7, 2011 What upgrade process? please explain it in details. Link to comment Share on other sites More sharing options...
edena Posted September 7, 2011 Share Posted September 7, 2011 Thanks, Me too I just learned this - [Autoit] And please can anyone help me with the post I made @ General Help and Support Thank You. Link to comment Share on other sites More sharing options...
samonlinesuper Posted September 7, 2011 Author Share Posted September 7, 2011 Upgrade process means that if smart device (such as Cisco switch so on) has loaded firmware with version 1.1xxx, and I want to use the script to change the loaded or upgrade to version 1.2xxx. That is what the Upgrade process means, thank you. 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