Sign in to follow this  
Followers 0
Fabre

from macromaker to Autoit

45 posts in this topic

Before I get to my questions a bit of background.

I played a bit with autoit 2 a while back, I made simple script to launch pegasus, hotmail popers and spampal, then close all when I closed pegasus, nothing fancy.

Also toyed a bit with ezmacro and macromaker.

Now in my job I have quite a few repetitive task to do daily.

In short I am a coordinator for a testing department in a software company.

One of the task that I automated with macromaker is bug reports,

These are roughly the steps of an export:

1 - Launch the ap, type password, select project

2 - select bug type, open-closed and All users, that's 6 cliscs in drop down menus

3 - then file/export select the file I want to export to, unselect an option clic next a couple of time, wait for the export to complete, can take anywhere from 15 to 30 sec, then clic Ok. (from clicking file that's about 12 clics)

4 - Open the txt export in notepad, select all, copy, close note pad

5 - open an excel sheet, select a specific tab, select row 2 col 1 paste, save, close.

and I am done.

So right now my macromaker script is basically, Left click coord x y for each required clic, with a delay of 30 sec on the clic launching the export.

Like I said the export time vary depending on the server load, so sometime the 30 sec delay is not enough and it's messing up the end of the script and sometime it went fast and I have to wait couple of sec for the script to go on.

So I am looking into doing this with autoit, the winwait function will solve that 30 sec issue since it will wait for the completion popup.

Like with macromaker I could go the move and clic at coor x y way.

But I was wondering if aside from the window title, there is a way of doing a text recognition in dropdown menu/content of windows/excel tabs, insuring the screen will function at any resolution or window size.

my other question is if I go the clic at coor x y way is there a way of importing a macromaker script in Autoit?

Also if you know of existing script/pieces of script that could help me, feel free to share.

Cheers

Share this post


Link to post
Share on other sites



Ok I have been playing with autoit for the past few hours read a bit of the help files and reffered to quite a few thread over here.

Regarding the combobox what's the alternative to controlsend, I have to select a specific user in a list that's often updated.

So something like

ControlSend("app", "", "ComboBox1", "F")

Will work to select user fabre if he is the first name with F, but if a fabio was added it would select the wrong user.

I believe with the beta there is a getselected function but I couldn't figure how to use it.

Share this post


Link to post
Share on other sites

Ok I have been playing with autoit for the past few hours read a bit of the help files and reffered to quite a few thread over here.

Regarding the combobox what's the alternative to controlsend, I have to select a specific user in a list that's often updated.

So something like

ControlSend("app", "", "ComboBox1", "F")

Will work to select user fabre if he is the first name with F, but if a fabio was added it would select the wrong user.

I believe with the beta there is a getselected function but I couldn't figure how to use it.

<{POST_SNAPBACK}>

You might want to look at the ControlCommand and FindString command for the ControlCommand

example:

ControlCommand("app","","ComboBox1","FindString",$string)

Gary


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

insuring the screen will function at any resolution or window size.

In my (limited) experience, the screen resolution is not critical to doing a mouse click at a given x,y. That's because, for the dialog boxes I've run into (about 100 in various Windows apps) the dialog box overall pixel dimensions do not change, even though varying screen resolutions make them look smaller or larger. In addition, I base my mouseclick calculation on the following:

$size = WinGetPos("Computer Management"); put dialog box location into array
$targX = $size[0] + 267 ; add the x mouseclick spot to the window's x coordinate
$targY = $size[1] + 80   ; add the y mouseclick spot to the window's y coordinate
MouseClick("right",$targX,$targY) ; send the mouseclick to the target x,y spot

Where 267 and 80 are the measured locations of the mouseclick target spot from the upper left corner of the dialog box. You can use AutoIT Window Info to give you these coordinates.


...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format

Share this post


Link to post
Share on other sites

As much as I got the controlsend to work I am struggling with control command

Let's say I want to select user Fabre

I tried

ControlCommand("app","","ComboBox1","FindString",'Fabre')

and

ControlCommand("app","","ComboBox1","FindString","Fabre")

could it be a ComboLBox like mentionned in the help file and what's the difference between a regular comboxbox and ComboLBox?

Jefhal my problem is that the app is divided in 2 panes, a list at the top an the details at the bottom, so depending on what I do often have to resize one or the other. and in the middle I have a few tab, so the placment of these tab for examples will always vary.

Share this post


Link to post
Share on other sites

You may be right it might be a ComboLBox.

Here's something else you might try, 2 examples find and find exact, just pick which one and give it try, good luck:

Global Const $CB_ERR = -1

Global Const $CB_FINDSTRING = 0x14C
Global Const $CB_FINDSTRINGEXACT = 0x158
Global Const $CB_SETCURSEL = 0x14E

Dim $s_text, $ret, $h_combobox, $s_search

$h_combobox = ControlGetHandle("app", "", "ComboBox1")
$s_search = "Fabre"

; partial match, returns the index of item found
$ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_combobox, "int", $CB_FINDSTRING, "int", -1, "str", $s_search)
If $ret[0] == $CB_ERR Then
    MsgBox(0, "Error", "Error find")
    Exit
EndIf

; or exact match, returns the index of item found
$ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_combobox, "int", $CB_FINDSTRINGEXACT, "int", -1, "str", $s_search)
If $ret[0] == $CB_ERR Then
    MsgBox(0, "Error", "Error find exact")
    Exit
EndIf

$ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_combobox, "int", $CB_SETCURSEL, "int", $ret[0], "int", 0)
If $ret[0] == $CB_ERR Then
    MsgBox(0, "Error", "Error Set Cur Sel")
    Exit
EndIf

Gary


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Thanks a million Gary. it's going to take a me a fair bit of head scratching to actually understand this code, but it's working nicely, thanks again.

Ok so now I have my points 1 and 2 working (theorically haven't tried in devtrack yet)

4 is easy

Run("C:\export.txt")

WinWaitActive("Export")

send("^a")

send("^c")

WinClose("Export")

for step 3

Hopefully a WinMenuSelectItem will work to do File/export in devtrack

WinMenuSelectItem("Devtrack", "", "&File", "&Export" )

Then I need point to the file I want to save to.

First clic the button with ...

;25 is the button control ID

ControlSend ( "Export", "Export", 25, "{ENTER}")

Then I have to select the right file, would Gary's code work as well even if it's a syslistview and not a combobox?

Couldn't find anything on syslistview in the help files

Share this post


Link to post
Share on other sites

Try ControlListView for SysListView controls, if that doesn't work we can work up some calls that should.

Gary


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Ok I tried this in notepad but it desn't seems to work

WinWaitActive("Untitled")

WinMenuSelectItem("Untitled", "", "&File", "&Save")

ControlListView ( "Untitled", "", 1, "FindItem", "text.txt" )

by default devtrack use the last used folder so i don't need to check the path.

Share this post


Link to post
Share on other sites

Ok I tried this in notepad but it desn't seems to work

WinWaitActive("Untitled")

WinMenuSelectItem("Untitled", "", "&File", "&Save")

ControlListView ( "Untitled", "", 1, "FindItem", "text.txt" )

by default devtrack use the last used folder so i don't need to check the path.

<{POST_SNAPBACK}>

Ummm, use AutoIt Window Info, you'll see that in notepad that is an "Edit1" not a SysListView control.

Gary


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

That's actually what I did Edit1 is for the main window I am in the the save as window

>>>>>>>>>>>> Window Details <<<<<<<<<<<<<

Title: Save As

Class: #32770

Size: X: 162 Y: 112 W: 563 H: 448

>>>>>>>>>>> Mouse Details <<<<<<<<<<<

Screen: X: 476 Y: 370

Cursor ID: 2

>>>>>>>>>>> Pixel Color Under Mouse <<<<<<<<<<<

RGB: Hex: 0xFFFFFF Dec: 16777215

>>>>>>>>>>> Control Under Mouse <<<<<<<<<<<

Size: X: 99 Y: 36 W: 450 H: 283

Control ID: 1

ClassNameNN: SysListView321

Text: FolderView

Style: 0x5600024C

ExStyle: 0x00000200

>>>>>>>>>>> Status Bar Text <<<<<<<<<<<

>>>>>>>>>>> Visible Window Text <<<<<<<<<<<

Save &in:

My Documents

FolderView

File &name:

*.txt

*.txt

Save as &type:

Text Documents (*.txt)

&Save

Cancel

&Encoding:

ANSI

>>>>>>>>>>> Hidden Window Text <<<<<<<<<<<

Open as &read-only

&Help

Edited by Fabre

Share this post


Link to post
Share on other sites

ok, use My Documents for the select, change it to what you want to test.

WinActivate("Save As","FolderView")
$ret = ControlListView("Save As","FolderView","SysListView321","FindItem","My Documents")
ControlListView("Save As","FolderView","SysListView321","Select", $ret)

Gary


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

ok, use My Documents for the select, change it to what you want to test.

WinActivate("Save As","FolderView")
$ret = ControlListView("Save As","FolderView","SysListView321","FindItem","My Documents")
ControlListView("Save As","FolderView","SysListView321","Select", $ret)

Gary

<{POST_SNAPBACK}>

It works but there is something I don't understand, I thought the syntax was

ControlListView ( "title", "text", controlID, "command" [, option1 [, option2]] )

but you are actually using the ClassNameNN, why is that?

I am also staring to understand how to use $ret but what does ret stand for?

Share this post


Link to post
Share on other sites

It works but there is something I don't understand, I thought the syntax was

ControlListView ( "title", "text", controlID, "command" [, option1 [, option2]] )

but you are actually using the ClassNameNN, why is that?

I am also staring to understand how to use $ret but what does ret stand for?

<{POST_SNAPBACK}>

1st: from the help file for you info

Using the AutoIt Window Info Tool you can move your mouse around the window you are interested in and you will be given information of the control that is currently under your mouse.  Information on controls is given in a number of ways, these are:

Control ID

ClassNameNN

Text

Control Handle (HWND) (Not available in AutoIt Window Info Tool - see below)

Whenever you see a Control...() command expecting a ControlID parameter (most of them) you can use any one of these methods. The method you choose will vary by personal preference and the information you are able to retrieve from the AutoIt Window Info Tool. In general, the best method to use is the Control ID, with the other methods being used when a Control ID is not available or is not unique (usually with static text each piece of text actually has the same Control ID so you will need to use one of the other methods to work with those controls).

2nd: been a programmer for almost 16 yrs (like code short when I can), and $ret is just short for value returned

Gary


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

Thanks Gary just saw that in the help file

so for this part it looks like this now.

WinWaitActive("Untitled")

WinMenuSelectItem("Untitled", "", "&File", "&Save")

WinActivate("Save As","FolderView")

$ret = ControlListView("Save As","FolderView","SysListView321","FindItem","test.txt")

ControlListView("Save As","FolderView","SysListView321","Select", $ret)

ControlSend ( "Save As", "FolderView", "&Save", "{ENTER}")

WinWaitActive("Save As")

ControlSend ( "Save As", "C:\Documents", "Button1", "{ENTER}")

But I have 2 issues first last controlsend should send a Yes but actually send no

And for some reason if I launch the script before I launch notepad it stops

after the WinMenuSelectItem

Wow 16 yrs of prog that's a lot of lines of code.

Edited by Fabre

Share this post


Link to post
Share on other sites

give this a try:

WinWaitActive("Untitled")
WinMenuSelectItem("Untitled", "", "&File", "&Save")
WinWaitActive("Save As","FolderView")
$ret = ControlListView("Save As","FolderView","SysListView321","FindItem","test.txt")
ControlListView("Save As","FolderView","SysListView321","Select", $ret)
ControlSend ( "Save As", "FolderView", "&Save", "{ENTER}")
WinWaitActive("Save As","&Yes")
ControlClick("Save As", "&Yes", "Button1")
;~ ControlSend ( "Save As", "C:\Documents", "Button1", "{ENTER}")

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Yes work fine

But I don't understand why use ControlClick here and not ControlSend like for the previous step.

Obvioulsy because it works but how am I suppose to know when to use one or the other?

Share this post


Link to post
Share on other sites

Realized the ControlSend ( "Save As", "FolderView", "&Save", "{ENTER}") was also not working properly

So I following your change I tried

ControlClick("Save As", "Save", "Button4")

But it's not working...

>>>>>>>>>>>> Window Details <<<<<<<<<<<<<

Title: Save As

Class: #32770

Size: X: 192 Y: 339 W: 563 H: 448

>>>>>>>>>>> Mouse Details <<<<<<<<<<<

Screen: X: 702 Y: 730

Cursor ID: 2

>>>>>>>>>>> Pixel Color Under Mouse <<<<<<<<<<<

RGB: Hex: 0x003A7A Dec: 14970

>>>>>>>>>>> Control Under Mouse <<<<<<<<<<<

Size: X: 474 Y: 354 W: 75 H: 23

Control ID: 1038

ClassNameNN: Button4

Text: &Help

Style: 0x48030000

ExStyle: 0x00000004

(Control is disabled)

(Control is hidden)

>>>>>>>>>>> Status Bar Text <<<<<<<<<<<

>>>>>>>>>>> Visible Window Text <<<<<<<<<<<

Save &in:

My Documents

FolderView

File &name:

test.txt

test.txt

Save as &type:

Text Documents (*.txt)

&Save

Cancel

&Encoding:

ANSI

>>>>>>>>>>> Hidden Window Text <<<<<<<<<<<

Open as &read-only

&Help

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