Sign in to follow this  
Followers 0
Rishav

Selecting an item from a drop down field

2 posts in this topic

#1 ·  Posted (edited)

Hi folks

Need your help again.

I am currently working on automating a .Net application. This application has a form with drop down menus in it. Something like;

Posted Image

I need to select an item from the menu, say \"Green\" (based on the string and not the item sequence number) and then click OK.

The problem is that i have tried several approaches but i am unable to select an item from the drop down. Nothing seems to happen.

Can anyone help me stamp out the stupidity that i have forced in on my code?

btw, the field is a combobox where typing of text is disabled.

WinActivate(\"AppWindow\")

ControlCommand(\"AppWindow\",\"Name:\",\"[CLASS:WindowsForms10.COMBOBOX.app.0.378734a; INSTANCE:2]\",\"SelectString\",\"Standard\")
ControlSend(\"AppWindow\",\"Name:\",\"[CLASS:WindowsForms10.COMBOBOX.app.0.378734a; INSTANCE:2]\",\"{ENTER}\")
MsgBox(0, \"\", \"Block 1:Continue??!!\")

WinActivate(\"AppWindow\")
ControlListView(\"AppWindow\",\"Name:\",\"[CLASS:WindowsForms10.COMBOBOX.app.0.378734a; INSTANCE:2]\",\"Select\",\"Standard\")
ControlSend(\"AppWindow\",\"Name:\",\"[CLASS:WindowsForms10.COMBOBOX.app.0.378734a; INSTANCE:2]\",\"{ENTER}\")
MsgBox(0, \"\", \"Block 2:Continue??!!\")

WinActivate(\"AppWindow\")

$NameIndex = ControlListView(\"AppWindow\",\"Name:\",\"[CLASS:WindowsForms10.COMBOBOX.app.0.378734a; INSTANCE:2]\",\"FindItem\",\"Standard\")
If $NameIndex <> -1 Then
    ControlListView(\"AppWindow\",\"Name:\",\"[CLASS:WindowsForms10.COMBOBOX.app.0.378734a; INSTANCE:2]\",\"Select\",$NameIndex)
    ControlSend(\"AppWindow\",\"Name:\",\"[CLASS:WindowsForms10.COMBOBOX.app.0.378734a; INSTANCE:2]\",\'{ENTER}\')
Else
    MsgBox(0,\'Not Found\',$NameIndex & \' was not found.\')
EndIf

WinActivate(\"AppWindow\")

#include <GuiListView.au3>
$hwnd = ControlGetHandle(\"AppWindow\",\"Name:\",\"[CLASS:WindowsForms10.COMBOBOX.app.0.378734a; INSTANCE:2]\")
For $i = 0 to _GUICtrlListView_GetItemCount($hwnd)
    _GUICtrlListView_SetItemSelected($hwnd,$i,True)
Next
ControlSend(\"AppWindow\",\"Name:\",\"[CLASS:WindowsForms10.COMBOBOX.app.0.378734a; INSTANCE:2]\",\'{ENTER}\')
Edited by Rishav

Share this post


Link to post
Share on other sites



Automating .Net forms is usually a difficult and sometimes disastrous process. The class names are generated at runtime and usually aren't the same between runs. Try looking at the form with the window tool again and you can see what I mean.

There's a script floating around in the example scripts named "anygui" or something like that. See if that will help you.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0