Barfly Posted May 13, 2005 Share Posted May 13, 2005 (edited) :"> I am fairly new at Autoit, so please forgive me. I would like to send a MouseClick comand to a button that does not have a corresponding shortcut. I am using the following script to assertain the location of the button (as it will move for each user) and then to click on it. The probelm is that each time the program that contains the button opens it changes the ControlID and ClassNameNN . $pos = ControlGetPos("Glossary", "", 3671004) $x = Number($pos[0]+ 40) $y = Number($pos[1]+ 30) MouseClick("left", $x, $y, 650, 1) I am willing to try anything at this stage. If you could help it would be great. Edited May 13, 2005 by Katy Link to comment Share on other sites More sharing options...
MHz Posted May 13, 2005 Share Posted May 13, 2005 (edited) Does the text change on the control ? For your code, look at Opt(MouseCoordMode, 0) ; or 2 for client area. This is mouse for window setting, rather then mouse for whole screen. If you have not already. Edited May 13, 2005 by MHz Link to comment Share on other sites More sharing options...
Barfly Posted May 13, 2005 Author Share Posted May 13, 2005 Does the text change on the control ?For your code, look at Opt(MouseCoordMode, 0) ; or 2 for client area. This is mouse for window setting, rather then mouse for whole screen. If you have not already. <{POST_SNAPBACK}>Thanks, I have tried the MouseCoordMode Option and it seems to be working a little better. Does this have an effect on the ControlID? Why does the ControlID and ClassNameNN change? The button is an Edit button but there is no Text specified in the AutoIt Window Info. Can I use the word 'Edit' anyway? Link to comment Share on other sites More sharing options...
TuMbLeWeEd Posted May 13, 2005 Share Posted May 13, 2005 :"> I am fairly new at Autoit, so please forgive me. I would like to send a MouseClick comand to a button that does not have a corresponding shortcut. I am using the following script to assertain the location of the button (as it will move for each user) and then to click on it. The probelm is that each time the program that contains the button opens it changes the ControlID and ClassNameNN .$pos = ControlGetPos("Glossary", "", 3671004)$x = Number($pos[0]+ 40)$y = Number($pos[1]+ 30)MouseClick("left", $x, $y, 650, 1)I am willing to try anything at this stage. If you could help it would be great.<{POST_SNAPBACK}>Can you retrieve the buttons text with ControlGetText ( "title", "text", controlID ) if you have the id, if so try this (very dirty try, did not test it so dont know if this works):expandcollapse popup$buttontext = "&Next";replace this with the buttons text $Handle = WinGetHandle ( "Glossary" ); i prefer handles, titles do change sometimes $ButtonClassNameNN = Get_button_classNameNN($Handle,$buttontext,Misc_funcs_number_Classlist($Handle)) $clicked = ControlClick ($Handle, $buttontext, $ButtonClassNameNN , "left") ; :-) If $clicked then msgbox(0,"INFO","Damn, am i awesome") Else msgbox(0,"ERROR","@#&GRR, this is not working (Readdy for a the nutthouse)") Endif ;gets the CalssNameNN based on a button text search (i hope) Func Get_button_classNameNN($title,$buttontext,$numbered_classlist_array) Local $i For $i = 1 to Ubound($numbered_classlist_array)-1 If ControlGetText ( $title, "", $numbered_classlist_array[$i] ) = $buttontext Then Return $numbered_classlist_array[$i] Next Next SetError(1) Return "" Endif ;returns a numbered ClassNameNN array like Button1,Button2 Func Misc_funcs_number_Classlist($Handle) Local $Classlist, $ClassArray, $i, $count, $oldItem $Classlist = StringSplit(Misc_funcs_sort(WinGetClassList($Handle)),@CRLF,1) Dim $ClassArray[Ubound($Classlist)-1] $count = 1 $oldItem = "" $ClassArray[0] = $Classlist[0]-1 For $i = 1 To Ubound($Classlist)-2 If $Classlist[$i] = $oldItem Then $count = $count + 1 Else $count = 1 EndIf $ClassArray[$i] = $Classlist[$i] & $count $oldItem = $Classlist[$i] ConsoleWrite("ClassNameNN: " & $ClassArray[$i] & @LF) Next $LASTCLASSLIST = WinGetClassList($Handle) Return $ClassArray EndFuncLet me know if this works My AutoIt stuffChatBichProjectSelectorWindow control grabberUsefull LinksPort forwarding with routers Link to comment Share on other sites More sharing options...
MHz Posted May 13, 2005 Share Posted May 13, 2005 Thanks, I have tried the MouseCoordMode Option and it seems to be working a little better. Does this have an effect on the ControlID? Why does the ControlID and ClassNameNN change? The button is an Edit button but there is no Text specified in the AutoIt Window Info. Can I use the word 'Edit' anyway?<{POST_SNAPBACK}>MouseCoordMode allows your mouse to work within the window.'Edit' , yes. 4 different ways to recognize a control. Text is one. Autoit info tool will display this. Link to comment Share on other sites More sharing options...
Barfly Posted May 13, 2005 Author Share Posted May 13, 2005 (edited) Can you retrieve the buttons text with ControlGetText ( "title", "text", controlID ) if you have the id, if so try this (very dirty try, did not test it so dont know if this works):CODE$buttontext = "&Next";replace this with the buttons text$Handle = WinGetHandle ( "Glossary" ); i prefer handles, titles do change sometimes$ButtonClassNameNN = Get_button_classNameNN($Handle,$buttontext,Misc_funcs_number_Classlist($Handle))$clicked = ControlClick ($Handle, $buttontext, $ButtonClassNameNN , "left"); :-)If $clicked then msgbox(0,"INFO","Damn, am i awesome")Else msgbox(0,"ERROR","@#&GRR, this is not working (Readdy for a the nutthouse)")Endif;gets the CalssNameNN based on a button text search (i hope)Func Get_button_classNameNN($title,$buttontext,$numbered_classlist_array) Local $i For $i = 1 to Ubound($numbered_classlist_array)-1 If ControlGetText ( $title, "", $numbered_classlist_array[$i]) = $buttontext Then Return $numbered_classlist_array[$i] Next Next SetError(1) Return ""Endif***FUNCTIONS - See Original Post***Let me know if this works WOW...This seems seriously complicated :-) May take me a while to get back to you on this one. Thanks. Edited May 13, 2005 by Katy Link to comment Share on other sites More sharing options...
Quasar Jarosz Posted August 24, 2006 Share Posted August 24, 2006 I am having the same issue with a .NET app. I have verified that ControlIDs are not static in .NET 1.1 or .NET 2.0. I'll try the large block of code provided above and see if i can make it do anything.. Quasar Link to comment Share on other sites More sharing options...
Quasar Jarosz Posted August 24, 2006 Share Posted August 24, 2006 I am having the same issue with a .NET app.I have verified that ControlIDs are not static in .NET 1.1 or .NET 2.0. I'll try the large block of code provided above and see if i can make it do anything..QuasarTurns out the ClassName does not seem to change on .NET controls, so i was able to use it instead of the ControlID and it seems to work great.Quasar 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