markitus90 Posted June 21, 2012 Share Posted June 21, 2012 Hi to all the peopleI have a combobox with n items.I like an action to be taked when a specific item is selected. I have used case _GUICtrlComboBox_GetCurSel($Type) = 5where 5 is the position of this item and $type the name of the combobox.It only works when a button is presed below a case.Anyone can help me?Thanks for all Link to comment Share on other sites More sharing options...
BrewManNH Posted June 21, 2012 Share Posted June 21, 2012 Please post your code or at least a small reproducer script that demonstrates your issue. There's not nearly enough information in your post to give any kind of rational answer. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
markitus90 Posted June 21, 2012 Author Share Posted June 21, 2012 (edited) Ok i will post part of the program......I like to do when wait is selected in combobox, Y:coordinate been disabled. and reactivated when other item is selected.Thanks expandcollapse popup#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <GUIListview.au3> #include <WindowsConstants.au3> #include <guicombobox.au3> #include <EditConstants.au3> #Include <GuiEdit.au3> #include"File.au3" #include <Array.au3> #Region ### START Koda GUI section ### Form=c:usersmarco aureliodesktopkodaformsxy coordenate 2.kxf $Form1_1 = GUICreate("Macromatizator", 347, 338, 276, 78) $X = GUICtrlCreateInput("X:Coordenate", 224, 24, 89, 21) $Y = GUICtrlCreateInput("Y:Coordenate", 224, 48, 89, 21) $Type = GUICtrlCreateCombo("Type", 224, 80, 89, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "Move|Click|Double Click|Right Click|Wait") $Add = GUICtrlCreateButton("Add", 16, 304, 49, 25) $Remove = GUICtrlCreateButton("Remove", 72, 304, 49, 25) $Replace = GUICtrlCreateButton("Replace", 128, 304, 49, 25) $Start = GUICtrlCreateButton("Start", 208, 272, 129, 57) GUICtrlSetFont(-1, 17, 800, 4, "MS Sans Serif") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### GUISetState() gui() LOCAL $X, $Y, $list func GUI() IF _GUICtrlComboBox_GetCurSel($Type) = 5 Then GUIctrlSetState($Y, $GUI_DISABLE) EndIf While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $Add local $Added if _GUICtrlComboBox_GetCurSel($Type) = 5 then ;Wait $Wait = "Wait" GUIctrlSetState($Y, $GUI_DISABLE) $X1 = GUICtrlRead($X, 1) $Added = GUICtrlCreateListViewItem($Wait & "|" & $X1, $List) EndIf if _GUICtrlComboBox_GetCurSel($Type) <> 5 Then ;Activar Y GUIctrlSetState($Y, $GUI_ENABLE) EndIf Case $Start Local $colX = 1, $colY = 2 ;;;MAL start() case $Remove _GUICtrlListView_DeleteItemsSelected($list) EndSwitch WEnd EndFunc Func start() for $line = 0 to _GUICtrlListView_GetItemCount($list)-1 Next EndFunc Func WAIT2() $Wait = "Wait" GUIctrlSetState($Y, $GUI_DISABLE) $X1 = GUICtrlRead($X, 1) EndFunc Edited June 21, 2012 by markitus90 Link to comment Share on other sites More sharing options...
BrewManNH Posted June 21, 2012 Share Posted June 21, 2012 Well, first off I can see that you don't declare the variable $list until after you've jumped to the gui() function, so it's being seen as undeclared. Second, you're redeclaring the $X and $Y variables with the same Local declaration as the $list variable. Not that it makes a difference to the values in those variables, but what were you trying to accomplish by doing that? Also, use Global for variables that are global in scope, and not Local, they're going to be Global variables anyways because of where you declared them, it will help in trouble-shooting later if you declare your variables in the proper scope. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
markitus90 Posted June 21, 2012 Author Share Posted June 21, 2012 I have just posted the most important code of the program. I need help with the item Wait. i like Ycoordinate to be disabled when it is selected and enabled when other item is enabled. Thanks Link to comment Share on other sites More sharing options...
BrewManNH Posted June 21, 2012 Share Posted June 21, 2012 Move the declaration of $list to before the jump to the gui() function, and it will work. No more error messages that way. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Kidney Posted June 21, 2012 Share Posted June 21, 2012 I can see that you populated the combobox with 5 items. The reason why it isn't working is because your index is wrong. A zero-based index starts with zero as the first item and then increases by one for every item after that. Make sure you look at the help files to check what index is returned for each function you call. Link to comment Share on other sites More sharing options...
markitus90 Posted June 21, 2012 Author Share Posted June 21, 2012 Kidney can you give me a example please? Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted June 21, 2012 Moderators Share Posted June 21, 2012 Hi, Markitus90. Are you looking to have the user choose one of the items in the combobox and then begin a function when they press Start? If so, you could use GUICtrlRead: Func start() Select Case GUICtrlRead($Type) = "Move" ..take action Case GUICtrlRead($Type) = "Click" ..take action EndSelect EndFunc "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
markitus90 Posted June 21, 2012 Author Share Posted June 21, 2012 Hi sir JLOGAN,,, that's true but itsnt the problem right now. My problem is that i like the textbox YCoordinate been desactivated when i select wait on the combobox without pressing start button.. I cant obtain this efect Also it would be activated when other item is selected. Thanks Link to comment Share on other sites More sharing options...
Kidney Posted June 21, 2012 Share Posted June 21, 2012 _GUICtrlComboBox_GetCurSel($Type) = -1 ;There is none selected _GUICtrlComboBox_GetCurSel($Type) = 0 ;"Move" is selected _GUICtrlComboBox_GetCurSel($Type) = 1 ;"Click" is selected _GUICtrlComboBox_GetCurSel($Type) = 2 ;"Double Click" is selected _GUICtrlComboBox_GetCurSel($Type) = 3 ;"Right Click" is selected _GUICtrlComboBox_GetCurSel($Type) = 4 ;"Wait" is selected 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