ShrutiW Posted March 5, 2019 Posted March 5, 2019 Hello People, I am new to autoIt and I am asked to automate one of our project which is a windows application. I have tried , explored and worked on a scenario. I have problem with selecting a ComboBox and once clicked on 'ok' button, it should go to the next stage. Initially the same code was working fine, but now it's not.I am not getting what exactly the problem is. It would be a great great help if anyone of you could help me resolve this issue please. Attaching the code here:- #include<IE.au3> #Include <GuiTreeView.au3> Global Const $CB_SETCURSEL = 0x14E WinActivate ( "Customer Care Portal Phase-2 - Internet Explorer","") Sleep(2000) ;CSR Team Information Combo box WinActivate("CSR Team Information","") ;ControlClick("CSR Team Information", "", "[CLASS:ThunderRT6ComboBox ; INSTANCE:1]") Sleep ( 3000 ) $h_combobox = ControlGetHandle("CSR Team Information", "", "[CLASS:ThunderRT6ComboBox ; INSTANCE:1]") $i_index = 2 DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_combobox, "int", $CB_SETCURSEL, "int", $i_index, "int",0) ControlClick("CSR Team Information","","[CLASS:ThunderRT6CommandButton; INSTANCE:1]") ;Clicks on Ok button Sleep(1000) ;New Contact Window WinActivate ("New Contact","") ControlClick("Customer Care Portal Phase-2 - Internet Explorer", "","[CLASS:ThunderRT6CommandButton ; INSTANCE:16]") ;Clicks on New contact button Sleep(3000) ControlSetText ( "New Contact", "", "[CLASS:ThunderRT6TextBox; INSTANCE:6]", "H30098556") ;Enters value in textBox for for Inquired About Sleep(2000) ControlSetText ( "New Contact", "", "[CLASS:ThunderRT6TextBox; INSTANCE:5]", "H30098556") ;Enters value in textBox for for Inquired For Sleep ( 2000) ;Contact Type Combo box $h_combobox = ControlGetHandle("New Contact", "", "[CLASS:ThunderRT6ComboBox; INSTANCE:9]") $i_index = 3 ; Correspondance DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_combobox, "int", $CB_SETCURSEL, "int", $i_index, "int", 0) Sleep ( 2000 ) ;Inquiry Type Combo box $h_combobox = ControlGetHandle("New Contact", "","[CLASS:ThunderRT6ComboBox; INSTANCE:1]") $i_index = 4 ; CUSTOMER INQUIRY DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_combobox, "int", $CB_SETCURSEL, "int", $i_index, "int", 0) Sleep ( 2000 ) ControlClick("New Contact","", "[CLASS:ThunderRT6CommandButton; INSTANCE:5]") ; Clicks on View Button ;ControlClick("New Contact","", "[CLASS:ThunderRT6CommandButton; INSTANCE:4]") ;Clicks on Create Inquiry WinClose("New Contact", "")
FrancescoDiMuro Posted March 5, 2019 Posted March 5, 2019 @ShrutiW Where is the issue? Can't you select the item in the Combo Box? Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
ShrutiW Posted March 5, 2019 Author Posted March 5, 2019 (edited) No Francesco. Once the Combo Box is opened, it directly clicks on "Ok" , item in the Combo Box is not selected. I guess problem is with below section of code. CSR Team Information Combo box WinActivate("CSR Team Information","") ;ControlClick("CSR Team Information", "", "[CLASS:ThunderRT6ComboBox ; INSTANCE:1]") Sleep ( 3000 ) $h_combobox = ControlGetHandle("CSR Team Information", "", "[CLASS:ThunderRT6ComboBox ; INSTANCE:1]") $i_index = 2 DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_combobox, "int", $CB_SETCURSEL, "int", $i_index, "int",0) ControlClick("CSR Team Information","","[CLASS:ThunderRT6CommandButton; INSTANCE:1]") ;Clicks on Ok button Edited March 5, 2019 by ShrutiW
FrancescoDiMuro Posted March 5, 2019 Posted March 5, 2019 @ShrutiW Debug a little bit your code. Try to do this with each of the function you use (so you can see where your script stops to work): If WinActivate() Then ConsoleWrite("WinActivate OK!" & @CRLF) ; Other instructions Else ConsoleWrite("WinActivate ERR: " & @error & @CRLF) ; If @error is set by the function EndIf And, this line of code 16 minutes ago, ShrutiW said: DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_combobox, "int", $CB_SETCURSEL, "int", $i_index, "int",0) Could be easily replaced with the function _GUICtrlComboBox_GetCurSel() Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
ShrutiW Posted March 5, 2019 Author Posted March 5, 2019 (edited) Hey @FrancescoDiMuro, I tried replacing DlCall function with _GUICtrlComboBox_GetCurSel() , But how Can I get the index of the exact element , i.e. Suppose if I want to select an item in the 2nd index, where should I mention it in that function? I have seen the syntax but I can't see any place to put Index of the item in Combo Box. Edited March 5, 2019 by ShrutiW
FrancescoDiMuro Posted March 5, 2019 Posted March 5, 2019 @ShrutiW I'm sorry. The function I was meaning is _GUICtrlComboBox_SetCurSel() Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
ShrutiW Posted March 5, 2019 Author Posted March 5, 2019 @FrancescoDiMuro I have made changes as per your recommendations, still it is not running. ;CSR Team Information Combo box WinActivate("CSR Team Information","") Sleep ( 3000 ) _GUICtrlComboBox_SetCurSel("[CLASS:ThunderRT6ComboBox ; INSTANCE:1]", 3) ControlClick("CSR Team Information","","[CLASS:ThunderRT6CommandButton; INSTANCE:1]") ;Clicks on Ok button Could you please suggest What changes should I make in the above script?😞
FrancescoDiMuro Posted March 5, 2019 Posted March 5, 2019 @ShrutiW Is the Window activated? If so, check the return value of _GUICtrlComboBox_SetCurSel() Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
ShrutiW Posted March 6, 2019 Author Posted March 6, 2019 Hey @FrancescoDiMuro , yes the window gets activated but it does not select the value in the combo Box. I'm not getting where exactly i'm going wrong. Please help. 😥
FrancescoDiMuro Posted March 6, 2019 Posted March 6, 2019 (edited) @ShrutiW Ok, so, of the window is activated, you can debug the next lines of your script. In this case, you can do something like: #include <GuiComboBox.au3> #include <MsgBoxConstants.au3> Global $hdlComboBox = ControlGetHandle(AddWindowTitle, "", AddWindowControlInformation) ; Change title and control information here If IsHWnd($hdlComboBox) Then If _GUICtrlComboBox_SetCurSel($hdlComboBox, 3) <> -1 Then MsgBox($MB_ICONINFORMATION, "", "The ComboBox item #3 has been selected.") Else MsgBox($MB_ICONERROR, "", "Error during the selection of the ComboBox item.") EndIf Else MsgBox($MB_ICONERROR, "", "Cannot obtain the handle of the ComboBox control." & @CRLF & "Error: " & @error) EndIf Meanwhile, could you please post the AutoItWindowInfoTool summary? Edited March 6, 2019 by FrancescoDiMuro Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
FrancescoDiMuro Posted March 6, 2019 Posted March 6, 2019 (edited) @ShrutiW Did you try the code above? Edited March 6, 2019 by FrancescoDiMuro Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
ShrutiW Posted March 6, 2019 Author Posted March 6, 2019 Yes . I tried. And it is showing the msgBox that "The ComboBox item #3 has been selected.". Then It clicks on "OK" button, and same thing is happening again. 😥 What does that indicate? I'm I missing something in code? This is how it shows:
FrancescoDiMuro Posted March 6, 2019 Posted March 6, 2019 (edited) @ShrutiW You could also try: ControlCommand("CSR Team Information", "", "SelectString", 'ComboBox item string') Edited March 6, 2019 by FrancescoDiMuro Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
ShrutiW Posted March 6, 2019 Author Posted March 6, 2019 Hi @FrancescoDiMuro Can you Please have a look on this code and suggest me required changes ? I tried it but no success yet. expandcollapse popup#include<IE.au3> #Include <GuiTreeView.au3> #include <GuiComboBox.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> ;#AutoIt3Wrapper_Run_Debug=y ;Global Const $CB_SETCURSEL = 0x14E ;_GUICtrlComboBox_SetCurSel ( "[CLASS:ThunderRT6ComboBox ; INSTANCE:1]", -1) WinActivate ( "Customer Care Portal Phase-2 - Internet Explorer","") Sleep(2000) ;CSR Team Information Combo box WinActivate("CSR Team Information","") Sleep ( 3000 ) ;GUICtrlComboBox_SetCurSel("[CLASS:ThunderRT6ComboBox ; INSTANCE:1]", 3) ControlCommand("CSR Team Information", "", "SelectString", 'Open Work Items: 000000061 | Green Bay/CCP IT/CCP IT Support Team') Global $hdlComboBox = ControlGetHandle("CSR Team Information", "", "[CLASS:ThunderRT6CommandButton; INSTANCE:1]") If IsHWnd($hdlComboBox) Then If _GUICtrlComboBox_SetCurSel($hdlComboBox, 3)<> -1 Then MsgBox($MB_ICONINFORMATION, "", "The ComboBox item #3 has been selected.") Else MsgBox($MB_ICONERROR, "", "Error during the selection of the ComboBox item.") EndIf Else MsgBox($MB_ICONERROR, "", "Cannot obtain the handle of the ComboBox control." & @CRLF & "Error: " & @error) EndIf ControlClick("CSR Team Information","","[CLASS:ThunderRT6CommandButton; INSTANCE:1]") ;Clicks on Ok button Sleep(1000) ;New Contact Window WinActivate ("New Contact","") ControlClick("Customer Care Portal Phase-2 - Internet Explorer", "","[CLASS:ThunderRT6CommandButton ; INSTANCE:16]") ;Clicks on New contact button Sleep(3000) ControlSetText ( "New Contact", "", "[CLASS:ThunderRT6TextBox; INSTANCE:6]", "H30098556") ;Enters value in textBox for for Inquired About Sleep(2000) ControlSetText ( "New Contact", "", "[CLASS:ThunderRT6TextBox; INSTANCE:5]", "H30098556") ;Enters value in textBox for for Inquired For Sleep ( 2000) ;Contact Type Combo box $h_combobox = ControlGetHandle("New Contact", "", "[CLASS:ThunderRT6ComboBox; INSTANCE:9]") $i_index = 3 ; Correspondance DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_combobox, "int", $CB_SETCURSEL, "int", $i_index, "int", 0) Sleep ( 2000 ) ;Inquiry Type Combo box $h_combobox = ControlGetHandle("New Contact", "","[CLASS:ThunderRT6ComboBox; INSTANCE:1]") $i_index = 4 ; CUSTOMER INQUIRY DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_combobox, "int", $CB_SETCURSEL, "int", $i_index, "int", 0) Sleep ( 2000 ) ControlClick("New Contact","", "[CLASS:ThunderRT6CommandButton; INSTANCE:5]") ; Clicks on View Button LoginCCP1.au3
FrancescoDiMuro Posted March 6, 2019 Posted March 6, 2019 (edited) @ShrutiW Try again with this one Spoiler expandcollapse popup#include<IE.au3> #Include <GuiTreeView.au3> #include <GuiComboBox.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> ;#AutoIt3Wrapper_Run_Debug=y ;Global Const $CB_SETCURSEL = 0x14E ;_GUICtrlComboBox_SetCurSel ( "[CLASS:ThunderRT6ComboBox ; INSTANCE:1]", -1) WinActivate ( "Customer Care Portal Phase-2 - Internet Explorer","") Sleep(2000) ;CSR Team Information Combo box WinActivate("CSR Team Information","") Sleep ( 3000 ) ;GUICtrlComboBox_SetCurSel("[CLASS:ThunderRT6ComboBox ; INSTANCE:1]", 3) Global $hdlComboBox = ControlGetHandle("CSR Team Information", "", "[CLASS:ThunderRT6CommandButton; INSTANCE:1]") If IsHWnd($hdlComboBox) Then If ControlCommand("CSR Team ?Information", "", $hdlComboBox, "SelectString", 'Open Work Items: 000000061 | Green Bay/CCP IT/CCP IT Support Team') Then MsgBox($MB_ICONINFORMATION, "", "The ComboBox item has been set.") Else MsgBox($MB_ICONERROR, "", "Error during the setting of the ComboBox item.") EndIf Else MsgBox($MB_ICONERROR, "", "Cannot obtain the handle of the ComboBox control." & @CRLF & "Error: " & @error) EndIf ControlClick("CSR Team Information","","[CLASS:ThunderRT6CommandButton; INSTANCE:1]") ;Clicks on Ok button Sleep(1000) ;New Contact Window WinActivate ("New Contact","") ControlClick("Customer Care Portal Phase-2 - Internet Explorer", "","[CLASS:ThunderRT6CommandButton ; INSTANCE:16]") ;Clicks on New contact button Sleep(3000) ControlSetText ( "New Contact", "", "[CLASS:ThunderRT6TextBox; INSTANCE:6]", "H30098556") ;Enters value in textBox for for Inquired About Sleep(2000) ControlSetText ( "New Contact", "", "[CLASS:ThunderRT6TextBox; INSTANCE:5]", "H30098556") ;Enters value in textBox for for Inquired For Sleep ( 2000) ControlClick("New Contact","", "[CLASS:ThunderRT6CommandButton; INSTANCE:5]") ; Clicks on View Button By the way, since the Portal is running on IE, couldn't you use IE UDF to automate that? Do you have access to the source code of the Webpage? Edited March 6, 2019 by FrancescoDiMuro Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
ShrutiW Posted March 6, 2019 Author Posted March 6, 2019 (edited) @FrancescoDiMuro I tried running the script, got a msgbox saying " "Error during the setting of the ComboBox item."" Sorry to ask so many silly questions, but How can I use IE UDF to automate it because this is a windows application ? IE UDFs can be used when its a webpage right? Edited March 6, 2019 by ShrutiW
ShrutiW Posted March 6, 2019 Author Posted March 6, 2019 @FrancescoDiMuro I have tried in all the possible ways I can. But not getting an expected result. Could you please guide me?
FrancescoDiMuro Posted March 6, 2019 Posted March 6, 2019 @ShrutiW 3 hours ago, FrancescoDiMuro said: By the way, since the Portal is running on IE, couldn't you use IE UDF to automate that? Do you have access to the source code of the Webpage? Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
ShrutiW Posted March 6, 2019 Author Posted March 6, 2019 @FrancescoDiMuro I don't have access to the source code .
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