randrew Posted August 20, 2012 Posted August 20, 2012 (edited) hello, i dont know how to call this.. but i've been searching for a week without a way out of this i want to run a program/file that selected from combobox when I click on start button.. (the combobox list is generated by array) I've been trying on changing the variable for the combobox yet there's no success... I hope there's anyone who'd like to help me out of this because I'm a super noobs in autoit here's my script: expandcollapse popup#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GuiStatusBar.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <file.au3> #include <Array.au3> #Region ### START Koda GUI section ### Form=c:documents and settingsxtranetdesktopgran vpn.kxf $Main = GUICreate("GRAN VPN", 371, 196, 336, 278) GUISetBkColor(0xFFFBF0) $User = GUICtrlCreateLabel("Username", 16, 20, 52, 17) $use = GUICtrlCreateInput("", 72, 20, 105, 21) $Pwd = GUICtrlCreateLabel("Password", 192, 19, 50, 17) $pas = GUICtrlCreateInput("", 248, 17, 105, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD)) $profile = GUICtrlCreateGroup("Profile", 8, 56, 169, 49) $Profil = GUICtrlCreateCombo("<default>", 16, 75, 153, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateGroup("", -99, -99, 1, 1) $server = GUICtrlCreateGroup("Server", 192, 56, 169, 49) $serve = GUICtrlCreateCombo("", 200, 75, 153, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group1 = GUICtrlCreateGroup("Protocol", 8, 107, 169, 41) $ICMP = GUICtrlCreateRadio("ICMP", 16, 123, 49, 17) GUICtrlSetState(-1, $GUI_DISABLE) $UDP = GUICtrlCreateRadio("UDP", 72, 123, 49, 17) GUICtrlSetState(-1, $GUI_DISABLE) $TCP = GUICtrlCreateRadio("TCP", 120, 123, 49, 17) GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlCreateGroup("", -99, -99, 1, 1) $StatusBar1 = _GUICtrlStatusBar_Create($Main) Dim $StatusBar1_PartsWidth[3] = [185, 277, -1] _GUICtrlStatusBar_SetParts($StatusBar1, $StatusBar1_PartsWidth) _GUICtrlStatusBar_SetText($StatusBar1, "Status: Connected", 0) _GUICtrlStatusBar_SetText($StatusBar1, "Up : 0 KB", 1) _GUICtrlStatusBar_SetText($StatusBar1, "Down : 0 KB", 2) $Group2 = GUICtrlCreateGroup("Account Login", 8, 4, 353, 49) $Setting = GUICtrlCreateButton("Advanced Settings", 192, 112, 169, 25) $Log = GUICtrlCreateButton("Log", 192, 144, 51, 25) $Start = GUICtrlCreateButton("Start", 261, 144, 99, 25) $Search = FileFindFirstFile(@DesktopDir & "" & "*.txt") $ProfileArray = _ArrayCreate($Search) While 1 $File = FileFindNextFile($Search) If @error Then ExitLoop _ArrayAdd($ProfileArray, $File) WEnd FileClose($Search) For $r = 1 To UBound($ProfileArray, 1) - 1 GUICtrlSetData($serve, StringTrimRight($ProfileArray[$r], 4)) Next $Current_Profile = GUICtrlRead($serve) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $sMsg = GUIGetMsg() Switch $sMsg Case $Start _FileWriteToLine(@DesktopDir & "tes.txt", 1, GUICtrlRead($use), 1) _FileWriteToLine(@DesktopDir & "tes.txt", 2, GUICtrlRead($pas), 1) $programlocation = GUICtrlRead($profilearray) MsgBox(0, "Error", $programLocation) Run ($ProfileArray) Case $GUI_EVENT_CLOSE _FileWriteToLine(@DesktopDir & "tes.txt", 1, GUICtrlRead($use), 1) _FileWriteToLine(@DesktopDir & "tes.txt", 2, GUICtrlRead($pas), 1) Exit Case $GUI_EVENT_CLOSE Exit Case $Main EndSwitch WEnd notes: i've created some text files on the desktop to show up the combobox list Edited August 20, 2012 by randrew
Raupi Posted August 21, 2012 Posted August 21, 2012 (edited) You try to read the value of an Control from an Array. Try this: expandcollapse popup#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GuiStatusBar.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <file.au3> #include <Array.au3> #region ### START Koda GUI section ### Form=c:documents and settingsxtranetdesktopgran vpn.kxf $Main = GUICreate("GRAN VPN", 371, 196, 336, 278) GUISetBkColor(0xFFFBF0) $User = GUICtrlCreateLabel("Username", 16, 20, 52, 17) $use = GUICtrlCreateInput("", 72, 20, 105, 21) $Pwd = GUICtrlCreateLabel("Password", 192, 19, 50, 17) $pas = GUICtrlCreateInput("", 248, 17, 105, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_PASSWORD)) $profile = GUICtrlCreateGroup("Profile", 8, 56, 169, 49) $Profil = GUICtrlCreateCombo("<default>", 16, 75, 153, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateGroup("", -99, -99, 1, 1) $server = GUICtrlCreateGroup("Server", 192, 56, 169, 49) $serve = GUICtrlCreateCombo("", 200, 75, 153, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group1 = GUICtrlCreateGroup("Protocol", 8, 107, 169, 41) $ICMP = GUICtrlCreateRadio("ICMP", 16, 123, 49, 17) GUICtrlSetState(-1, $GUI_DISABLE) $UDP = GUICtrlCreateRadio("UDP", 72, 123, 49, 17) GUICtrlSetState(-1, $GUI_DISABLE) $TCP = GUICtrlCreateRadio("TCP", 120, 123, 49, 17) GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlCreateGroup("", -99, -99, 1, 1) $StatusBar1 = _GUICtrlStatusBar_Create($Main) Dim $StatusBar1_PartsWidth[3] = [185, 277, -1] _GUICtrlStatusBar_SetParts($StatusBar1, $StatusBar1_PartsWidth) _GUICtrlStatusBar_SetText($StatusBar1, "Status: Connected", 0) _GUICtrlStatusBar_SetText($StatusBar1, "Up : 0 KB", 1) _GUICtrlStatusBar_SetText($StatusBar1, "Down : 0 KB", 2) $Group2 = GUICtrlCreateGroup("Account Login", 8, 4, 353, 49) $Setting = GUICtrlCreateButton("Advanced Settings", 192, 112, 169, 25) $Log = GUICtrlCreateButton("Log", 192, 144, 51, 25) $Start = GUICtrlCreateButton("Start", 261, 144, 99, 25) $Search = FileFindFirstFile(@DesktopDir & "" & "*.*") $ProfileArray = _ArrayCreate($Search) While 1 $File = FileFindNextFile($Search) If @error Then ExitLoop _ArrayAdd($ProfileArray, $File) ConsoleWrite($File & @CRLF) WEnd FileClose($Search) For $r = 1 To UBound($ProfileArray, 1) - 1 GUICtrlSetData($serve, StringTrimRight($ProfileArray[$r], 4)) Next $Current_Profile = GUICtrlRead($serve) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### While 1 $sMsg = GUIGetMsg() Switch $sMsg Case $Start _FileWriteToLine(@DesktopDir & "tes.txt", 1, GUICtrlRead($use), 1) _FileWriteToLine(@DesktopDir & "tes.txt", 2, GUICtrlRead($pas), 1) Local $idx $idx = _ArraySearch($ProfileArray, GUICtrlRead($serve), 0, 0, 0, 1) If Not @error Then MsgBox(0, "Error", $ProfileArray[$idx]) ShellExecute(@DesktopDir & "" & $ProfileArray[$idx]) EndIf Case $GUI_EVENT_CLOSE _FileWriteToLine(@DesktopDir & "tes.txt", 1, GUICtrlRead($use), 1) _FileWriteToLine(@DesktopDir & "tes.txt", 2, GUICtrlRead($pas), 1) Exit Case $GUI_EVENT_CLOSE Exit Case $Main EndSwitch WEnd Edited August 21, 2012 by Raupi
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