derickyu Posted December 11, 2012 Share Posted December 11, 2012 Hi, I just started using autoIT and try to automate some basic functions for our UI application that attaches to Visual studio. Here's what I have to see if AutoIT can recognize our controls. ; get check box status $hChkLocalAgents = ControlGetHandle ( "Solution Settings", "", "[Name:chkUseLocalAgents]") MsgBox (1, "Test", $hChkLocalAgents) $sTxt= GUICtrlGetState("[Name:chkUseLocalAgents]") MsgBox (1, "Test", "check box state = " + $sTxt) The first part works fine and gives me the handle correctly but the GUICtrlGetState returns -1 for both check and uncheck chkbox control. Can some one help? thanks FYI, I am using autoit 3.3.8 on Win7. Link to comment Share on other sites More sharing options...
BrewManNH Posted December 11, 2012 Share Posted December 11, 2012 GUICtrlGetState only works with controls you've created in your own apps. It requires a control ID that's returned using GUICtrlCreate..., it won't work with external controls. You should probably look at ControlCommand after getting the control's handle. 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...
derickyu Posted December 11, 2012 Author Share Posted December 11, 2012 Thanks, I tried to use $sTxt = ControlCommand ( "Solution Settings", "", "[Name:chkUseLocalAgents]", "IsChecked", "" ) MsgBox (1, "CM", "radio button state = " + $sTxt) But getting 0. Is my statement correct? Link to comment Share on other sites More sharing options...
Developers Jos Posted December 11, 2012 Developers Share Posted December 11, 2012 You have + $sTxt in stead of & $sTxt. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
derickyu Posted December 11, 2012 Author Share Posted December 11, 2012 ops... modified and still getting 0 for both check and unchecked$sTxt = ControlCommand ( "Solution Settings", "", "[Name:chkUseLocalAgents]", "IsChecked", "" )MsgBox (1, "CM", $sTxt) Link to comment Share on other sites More sharing options...
Developers Jos Posted December 11, 2012 Developers Share Posted December 11, 2012 Check what the value is for @error returned by ControlCommand(). SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
BrewManNH Posted December 11, 2012 Share Posted December 11, 2012 You get the control's handle with ControlGetHandle, why not use that in the ControlCommand? 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...
derickyu Posted December 11, 2012 Author Share Posted December 11, 2012 I tried it using handle as well but still getting 0 and @error returns 0 as well. $hChkLocalAgents = ControlGetHandle ( "Solution Settings", "", "[Name:chkUseLocalAgents]") MsgBox (1, "CM", $hChkLocalAgents) $sTxt = ControlCommand ( "Solution Settings", "", $hChkLocalAgents, "IsChecked", "" ) MsgBox (1, "@error", @error) MsgBox (1, "isChecked", $sTxt) Link to comment Share on other sites More sharing options...
BrewManNH Posted December 11, 2012 Share Posted December 11, 2012 Is the checkbox checked when you tried it? 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...
derickyu Posted December 11, 2012 Author Share Posted December 11, 2012 I ran it twice, once with it check and onc uncheck. Link to comment Share on other sites More sharing options...
Developers Jos Posted December 11, 2012 Developers Share Posted December 11, 2012 Are you sure it is a checkbox? What is au3info telling you about the control you try to get the status from? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 11, 2012 Moderators Share Posted December 11, 2012 _GUICtrlButton_GetCheck() would make things so much simpler. Pass the hwnd of the control ( even if it's in another window ), if it's a non-custom-drawn checkbox, it will return the correct data without confusing anything. If it doesn't return the correct data, than you're assured one of two things: 1. Your hwnd/handle is not a checkbox 2. It's custom-drawn Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
BrewManNH Posted December 11, 2012 Share Posted December 11, 2012 I always forget that _GUICtrlButton works on radio and checkbox buttons as well. 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...
derickyu Posted December 12, 2012 Author Share Posted December 12, 2012 Found the answer from another thread, looks like .Net control is not supported. Thanks for all the replies. 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