Sign in to follow this  
Followers 0
ijourneaux

Automating a custom built Windows application

28 posts in this topic

I would like to automate navigation of a windows application we have created. The application is controlled vai several drop down selections. Unfortuantely it doenst seem like I can get the application to respond to the test I enter into the field, I actually have to make a selection from the list of choices in the drop down.

Do you think that automating this might be possible with AutoIt.

Share this post


Link to post
Share on other sites



I'm not sure I follow, please humour me.

You cant autoumate your own code! is that correct ?

Sorry if I have this wrong.

If I could, I would make the changes to our code but don't have access to the programming resource to make the changes so I am looking for another way to approximate what I would like to accomplish.

I have attached a screen capture of the application involved. I ahve the AutoIt Window Information for the field I would like to work with. The control has 15-30 potential choices. What I would like to do is print the screens associated with several of the choices. I have tried typing the testinto the field but that doesn't work. The only way the screen advances is if I activate the drop arrow and select and entry in the list.

post-57395-12714555893182_thumb.jpg

Share this post


Link to post
Share on other sites

Ok

Making subtle progress creating a script but having trouble getting the control to accept the text I want to send to it but I am stalled out. Perhaps I am missing something easy

Here is what I have so far.

Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase

if(WinExists("InfoStore Client")) Then

Else

Run("c:\program files\Infostore\Infostore.exe")

EndIf

MsgBox(0, "test", "Test2")

WinActivate("InfoStore Client")

ControlCommand("InfoStore Client", "", "[CLASS:Edit; INSTANCE:1]", "Base Brightness")

This executes wihtout any errors. Unfortunately the control doesn't react to the ControlCommand.

When I use the AutoIt Window Info tool, I can select the either the textbox or the textbox with the drop arrow. The text box comes up wit the info I used in the ControlCommand above.

If I use the textbox with the drop arrow, it the ControlCommand would be

ControlCommand("InfoStore Client", "", "[CLASS:ThunderRT6ComboxBox; INSTANCE:1]", "Base Brightness")

"Base Brightness" is an exact match to one of the drop down choices.

Share this post


Link to post
Share on other sites

Ok. Let me ask the simple question then.

I have a drop down combocbox. The drop down combobox has a list of choices. How do I use AutoIt to change the combobox selection to one of the other combobox choices, in this case "Base Brightness" and have the apllication react to the change.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Try

ControlCommand("InfoStore Client", "", "[CLASS:ThunderRT6ComboxBox; INSTANCE:1]", "SelectString", "Base Brightness")

edited oops put wrong one

Edited by Yoriz

GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF.

Share this post


Link to post
Share on other sites

Try

ControlCommand("InfoStore Client", "", "[CLASS:ThunderRT6ComboxBox; INSTANCE:1]", "SelectString", "Base Brightness")

edited oops put wrong one

Thanks! That worked.

Share this post


Link to post
Share on other sites

Thanks! That worked.

That moved me along the process significantly. Now I need to control a ToolbarWindow32 and a TreeViewWndClass. A search of the help and on Google did not yield much help. There were some indications that it might be difficult to contorl a treeview.

Share this post


Link to post
Share on other sites

Get the Handle to those controls using ControlGetHandle and use those control handles on the commands in user defined functions in GuiToolbar management and GuiTreeView management.


GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF.

Share this post


Link to post
Share on other sites

Yoriz

First I would like to thank you much for offering you assistance to an AutoIt noob. It is much appreciated.

It appears that this might be a bigger project than I expected. I looked at the commands you described and I can see how to build a treeview within AutoIt. The examples are quite good. Unfortuantely I don't see how I can use this to control the treeview (or the toolbar) in my application (see the screen capture).

I made a simple attempt to get the number of items in the treeview

$HandleTreeView= ControlGetHandle("InfoStore Client", "", "[CLASS:TreeViewWndClass; INSTANCE:2]")

if($HandleTreeView <>0) Then

MsgBox(0, "StatusMessage", $HandleTreeView)

EndIf

MsgBox( 0, "Status Message", _GUICtrlTreeView_GetCount($HandleTreeView))

That did nto work as I expected and gave an error code

Are their AutoIt experts would might be interested in consulting on a task like this?

post-57395-12716383653776_thumb.jpg

Share this post


Link to post
Share on other sites

Hey no worries, what was the error ? , did it return the handle ok ?

if the error was

ERROR: _GUICtrlTreeView_GetCount(): undefined function.

the reason is missing include line

#Include <GuiTreeView.au3>

at the start of the script so it knows it needs to use the udf treview functions as your code looks like it should be ok.


GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF.

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Now I am cooking with gas!. Able to navigate up and down the tree, find an item, etc. I suspect a similar process will work for the toolbar.

How do I click on the selected item in the treeview so that it brings up the window associated with the item in the tree view.

Figure it out. Looked up and down the lsit and kept missing it. Click Item must be it.

Edited by ijourneaux

Share this post


Link to post
Share on other sites

Continue to make good progress. A couple of items.

1. Regarding the toolbar. I was able to execut ethe correct button by guessing at the index. Can you find the button index using the tooltip text?

2. I found the handle for th main menu and the Print menu item. How do I execut ethe print menu choice and how do I press the print button on the Print properties dialog box that appears.

Thanks again for your continued help.

Share this post


Link to post
Share on other sites

Well done on your progress so far :idea:

1. The autoit info window should be able to list the toolbar indexes for you.

2. Menu's can be controlled with WinMenuSelectItem , Press buttons with ControlClick.


GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF.

Share this post


Link to post
Share on other sites

Ok I can click on the File | Print Menu choice but it seems that I have two problems (maybe related).

1. When I process the ControlCommand immediately before I try to print, the screen has not finished updating before I click on the Fil | Print Menu choice so things aren' really ready How do you wait for this try of task to complete. There isn't a new window the graphic in the existing window is redrawn.

2. When I click on the File | Print Menu choice there is a significant amount of setup that is done before the Print dialog box appears. I tried using the WinWaitActive command to wait for the Print Dialog box to appear but it still seem like the CommandClick to click on the Print Button is executing before the Print Dialog is ready.

How do you effectively wait in these two situations.

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

Every instance will be differant depending on what feedback you get from the program your working with, not having the program no one else but you can really figure this out to easily.

1. you need to look for something that changes for you to check for, i see theres a status bar in the last pic it says 'done populating list', is this altered when it finished doing the ControlCommand, you could read it with StatusbarGetText or _GUICtrlStatusBar_GetText and not proceed to it has the correct text value, otherwise you'll have to hunt for something else at worst you'll have to use a sleep()

2. Similar to no.1 you need to find something that indicates its ready, you could try checking in a loop if you can get focus on the button before clicking it by using ControlFocus and not proceed till it can, but you might want another exit route incase for some reason it never gets focus. if the button is just shown before its ready this wont help either.

Edited by Yoriz

GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF.

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

Using ControlFocus on a specific control seems to work but I can't seem to get that to work on the print dialog box. In the code sample below, I click on the File | Print button, then I am try to wait until I can get focus on the Print button in the Print Dialog Box. Unfortuantely the call to ControlFocus using the Print Button in the Print Dialog doesn't work

Func PrintDisplay()

WinMenuSelectItem("InfoStore Client", "", "&File", "&Print")

; wait for print dialog to appear

do

until (ControlFocus("Print", "", "[CLASS:Button; INSTANCE:13]") = 1)

ControlClick("Print", "", "[CLASS:Button; INSTANCE:13]")

; Wait until window finishes updating

do

until (ControlFocus("InfoStore Client", "", "[CLASS:ThunderRT6ComboBox; INSTANCE:3]") = 1)

endFunc

Even though the print dialog box seems to be active, I can't seem to get the focus of the button. All I need to do is click on the Print Dialog box anywhere and the script proceeds as expected.

(Modified original post so that it is now a function)

Edited by ijourneaux

Share this post


Link to post
Share on other sites

; Wait until window finishes updating

do

until (ControlFocus("InfoStore Client", "", "[CLASS:ThunderRT6ComboBox; INSTANCE:3]") = 1)

endFunc

Even though the print dialog box seems to be active, I can't seem to get the focus of the button. All I need to do is click on the Print Dialog box anywhere and the script proceeds as expected.

Its a button your having problems with now ? reason i ask is that the control id you are using is to a combobox ?

GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF.

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