Promethyl Posted January 16, 2006 Share Posted January 16, 2006 ## Question on how to tell if the combo box has the dropdown list displayed I have here below a very basic AutoIT3 script in which I am waiting for a program user to select an option from a dropdown combobox, once they click on thier choice, I want to send {tab} so it will advance to the next selection. I have it very close to working perfectly, however, it will tab before they select their choice. Can anyone help me to do this right? expandcollapse popup#comments-start ######################### ## auto advancing dms? ## ######################### #comments-end Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced $appname = "Internet Explorer"; $comboname = "cmbo"; $winhandle = WinGetHandle ($appname); ## interact with proper window GUISwitch ( $winhandle ); ## get handle to interact with proper window ##ControlGetHandle ( "title", "text", controlID ) ## http://www.autoitscript.com/autoit3/docs/intro/controls.htm ## http://www.autoitscript.com/autoit3/docs/functions/ControlCommand.htm ##REF: ControlCommand ( "title", "text", controlID, "command", "option" ) While 1=1 ## TrayTip("WinActive $appname", WinActive($appname) , 1) If WinActive($appname) Then $controlID = ControlGetFocus ( $appname ); if StringInStr ( $controlID, $comboname )==0 then Continueloop; test for combobox $selection = ControlCommand ( $appname , "", $controlID, "GetCurrentSelection", "" ); $selection2 = ControlGetText ($appname,"", $controlID ); if ($selection == "") then Continueloop; TrayTip($controlID, $selection2, 1); Send("{tab}"); Sleep(500); five hund milliseconds EndIf WEnd Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 16, 2006 Share Posted January 16, 2006 ## Question on how to tell if the combo box has the dropdown list displayedI have here below a very basic AutoIT3 script in which I am waiting for a program user to select an option from a dropdown combobox, once they click on thier choice, I want to send {tab} so it will advance to the next selection.I have it very close to working perfectly, however, it will tab before they select their choice. Can anyone help me to do this right? CODE#comments-start########################### auto advancing dms? ############################comments-endOpt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced$appname = "Internet Explorer";$comboname = "cmbo";$winhandle = WinGetHandle ($appname);## interact with proper windowGUISwitch ( $winhandle );## get handle to interact with proper window##ControlGetHandle ( "title", "text", controlID )## http://www.autoitscript.com/autoit3/docs/intro/controls.htm## http://www.autoitscript.com/autoit3/docs/f...trolCommand.htm##REF: ControlCommand ( "title", "text", controlID, "command", "option" )While 1=1## TrayTip("WinActive $appname", WinActive($appname) , 1)If WinActive($appname) Then $controlID = ControlGetFocus ( $appname ); if StringInStr ( $controlID, $comboname )==0 then Continueloop; test for combobox $selection = ControlCommand ( $appname , "", $controlID, "GetCurrentSelection", "" ); $selection2 = ControlGetText ($appname,"", $controlID ); if ($selection == "") then Continueloop; TrayTip($controlID, $selection2, 1); Send("{tab}"); Sleep(500); five hund millisecondsEndIfWEndWell, first off, I cleaned up your source comments by putting in ';' for all those '#'. AutoIT uses a semicolon to denote comments, and does not require a semicolon at the end of the line, unless you want a comment after the code:CODE; #########################; ## auto advancing dms? ##; #########################opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced$appname = "Internet Explorer"$comboname = "cmbo"$winhandle = WinGetHandle($appname); interact with proper windowGUISwitch($winhandle)While 1 = 1 ; TrayTip("WinActive $appname", WinActive($appname) , 1) If WinActive($appname) Then $controlID = ControlGetFocus($appname) If StringInStr($controlID, $comboname) == 0 Then ContinueLoop ; test for combobox $selection = ControlCommand($appname, "", $controlID, "GetCurrentSelection", "") $selection2 = ControlGetText($appname, "", $controlID) if ($selection == "") Then ContinueLoop TrayTip($controlID, $selection2, 1) Send("{tab}") Sleep(500) ; 500 milliseconds EndIfWEnd With IE open, this just loops and never sends the TAB, at least for me.After that, I insterted a MsgBox() to display the ControlID, and I never saw one that contained "cmbo" no matter what part of IE was in focus. I basicaly got "Internet Explorer_Server1" for everything, and didn't see any combo boxes any way? Opening Tools|Options to get some combo boxes up takes the focus off stops anything from happening any way.What is the combo box control you are looking for the operator to use?Anyway, note the use of MsgBox() pop ups below as break points to see what's happening, and I hope that helps:CODE; #########################; ## auto advancing dms? ##; #########################opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced$appname = "Internet Explorer"$comboname = "cmbo"$winhandle = WinGetHandle($appname); interact with proper windowGUISwitch($winhandle)While 1 = 1 ; TrayTip("WinActive $appname", WinActive($appname) , 1) If WinActive($appname) Then $controlID = ControlGetFocus($appname) MsgBox(0, "Info", "ControlID is: " & $controlID, 5) ; Popup added to show current $ControlID If StringInStr($controlID, $comboname) == 0 Then ContinueLoop ; test for combobox $selection = ControlCommand($appname, "", $controlID, "GetCurrentSelection", "") $selection2 = ControlGetText($appname, "", $controlID) MsgBox(0, "Info2", "Selection is: " & $Selection, 5) ; Popup added to show current $Selection if ($selection == "") Then ContinueLoop TrayTip($controlID, $selection2, 1) Send("{tab}") Sleep(500) ; 500 milliseconds EndIfWEnd Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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