Google Grupper støtter ikke lenger nye Usenet-innlegg eller -abonnementer. Historisk innhold er fortsatt synlig.

RE: using AutoItX COM interface

Sett 305 ganger
Hopp til første uleste melding

pjo

ulest,
22. feb. 2008, 06:52:0222.02.2008
til

"pjo" wrote:

> Hi! I am trying to control a window application by PowerShell vis AutoItX
> COM interface.
>
> Is there any way to find a button in a Window application in AutoItX com
> interface?
> This button does not have a short cut key as in Firefox bookmark Alt+B.
> So I need to move the mouse to the button and left click. Then select a
> particular item then left click and so on.
>
> pjo
>

I found ControlClick.
ControlClick ( "title", "text", controlID [, button] [, clicks]] )
This will do.
But ControlID for the button must be known.
I tried Au3Info.exe but when the mouse is moved to the button, no
information is displayed.
Does this mean that there is no ControlID for this button ?
Or
Is there any way to find the ControlID ?

pjo

Shay Levi

ulest,
22. feb. 2008, 07:39:3922.02.2008
til

In your AutoIT directory you'll find a file "Au3Info.exe". Launch it and
hover around your window (button)
You'll see all the information you need.

Tip: Press CTRL-ALT-F to freeze the display.

-----
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com

pjo

ulest,
22. feb. 2008, 17:45:3922.02.2008
til
Thanks Shay,

But as I described in my previous post,

> I tried Au3Info.exe but when the mouse is moved to the button, no
> information is displayed.
> Does this mean that there is no ControlID for this button ?
> Or
> Is there any way to find the ControlID

Au3Info.exe is runnong here and it showed no information when the mouse is
moved to the button even with freeze enabled.

Is there any other way to click this button. Maybe by making the app window
to max and do mouse move command ?

pjo

Shay Levi

ulest,
22. feb. 2008, 18:26:3422.02.2008
til

Two options:

1. Launch a fresh copy of the window and hit TAB repeatedly until the button
gets in focus, count the hopes. Then you can use use the Send() method
to SendKeys to the window:

Send ("{TAB 3}{ENTER}")
# this performs 3 times TAB and then ENTER.

2. Search the help for "MouseCoordMode". It's a global AutoIT option. It
sets the way coords are used in the mouse functions, either absolute coords
or coords relative to the current active window:
0 = relative coords to the active window
1 = absolute screen coordinates (default)
2 = relative coords to the client area of the active window

The "Window" option is safer to use because computer can be set to different
resolution.
Now, in Au3info.exe menu, goto Options > coord mode > and Activate "Window",
hover your mouse over the button and locate this section:

>>>>>>>>>>> Mouse Details <<<<<<<<<<<
Window: X: 175 Y: 517
Cursor ID: 5

It tells you the button coordinates with respect to the active window. To
*click* that button:

Opt("MouseCoordMode", 0)
MouseMove(175,517)
MouseDown("left")

; switch back to the default
Opt("MouseCoordMode", 0)

Shay Levi

ulest,
22. feb. 2008, 18:31:5022.02.2008
til

Had a typo :(

; switch back to the default

Opt("MouseCoordMode", 1)

pjo

ulest,
22. feb. 2008, 18:44:0122.02.2008
til
Thanks Shay again.

I will try this and report here about results.

Can I write the followings in PoerShell script ?

Opt("MouseCoordMode", 0)
MouseMove(175,517)
MouseDown("left")

pjo

ulest,
22. feb. 2008, 18:51:0122.02.2008
til
Thanks Shay,

Can I write the followings in PoerShell script ?

Opt("MouseCoordMode", 1)
MouseMove(175,517)
MouseDown("left")

pjo

ulest,
22. feb. 2008, 18:53:0022.02.2008
til
Thanks Shay,

Can I write the followings in PoerShell script ?

Opt("MouseCoordMode", 1)
MouseMove(175,517)
MouseDown("left")

Shay Levi

ulest,
22. feb. 2008, 18:44:2922.02.2008
til
This commands are for .AU3 script. I'll try to find how they can be written
with the automation dll.

pjo

ulest,
22. feb. 2008, 18:57:0222.02.2008
til
> 1. Launch a fresh copy of the window and hit TAB repeatedly until the button
> gets in focus, count the hopes. Then you can use use the Send() method
> to SendKeys to the window

By issueing TABs the button does not gets in focus.

I will try the other method,

Shay Levi

ulest,
22. feb. 2008, 19:35:2222.02.2008
til

Here's the PowerShell version:

$autoIt = new-object -com AutoItX3.Control
$autoIt.Opt("MouseCoordMode", 1)
$autoIt.MouseMove(175,517)
$autoIt.MouseDown("left")

# switch back to screen coordinates (default)
$autoIt.Opt("MouseCoordMode", 0)

Shay Levi

ulest,
22. feb. 2008, 19:46:0222.02.2008
til
Ops... I did it again, it's already 03:00 AM, time to start-sleep :)

The first opt should be 0 (Window) and the second is 1 (default)

pjo

ulest,
22. feb. 2008, 20:09:0022.02.2008
til
Thanks Shay,

I figured it out.

Now it is working.

I will search how to browse down the pull down menu, tree items down.

pjo

pjo

ulest,
23. feb. 2008, 19:22:0023.02.2008
til
Hi! I am stuck again.

The application is maximized by Alt+ Space + X
because if the app window is not maximized the coordinates for the menu item
is different each time when it is activated.
A window within the appliation is opened.
I want to maximize this inner window but his app does not have a hotkey to
do this.
The inner window has the standard icon to minimize, maximize, exit at the
upper right corner.
I am trying to click maximize button but again the location when this inner
window is opened is different a little bit each time so the mousemove command
does not work most of the time.

Please advise some hint to solve this problem.
Is there any way to maximize the inner window with AutoIt command or at
least move to the upper left edge ?

pjo

ulest,
23. feb. 2008, 21:15:0023.02.2008
til
The inner windows information in Au3Info.exe:

Basic Control Info AfxFrameOrView42
instance 45
ClassnameNN AfxFrameOrView4245
ID 59648
Text
Position 810, 54
Size 211,473
ControlClick Coords 203,96
Style 0x50000000
ExStyle 0x00000200
Handle 0x00031618

pjo

ulest,
23. feb. 2008, 21:38:0023.02.2008
til
The other point:
A tiny dialogue box to input characters is opened in the lower left corner
of the inner window by issuing Ctrl + SPACE.
At this point the cursor is blinking and the mouse pointer is somewhere else.
How can the mouse pointer move to the character cursor to input characters?

In manual mode there is no need to move mouse pointer to the cursor to input
character at this cursor. Just type in then charcters are input to this
dialogue.

Shay Levi

ulest,
24. feb. 2008, 02:44:0524.02.2008
til

You can use the "WinSetState()" method to maximize the window.

Shay Levi

ulest,
24. feb. 2008, 02:51:4324.02.2008
til

You can ignore the mouse location and *write* yur text directly to the textbox.
It doesn't matter if the control/dialog box is in focus or not:

ControlSetText ( "title", "text", controlID, "new text" [, flag] )

pjo

ulest,
24. feb. 2008, 03:38:0124.02.2008
til
Thanks Shay,


Can I issue

ControlSetText ( "title", "text", controlID, "new text" [, flag] )

to the inner window which does not have controlID ?

Or is it in the au35nfo window ?

pjo

ulest,
24. feb. 2008, 03:39:0024.02.2008
til
WinSetState ( "title", "text", flag )

this requires "title" but the inner window does not have title.

pjo

ulest,
24. feb. 2008, 06:07:0024.02.2008
til
I tried:
$autoitx.ControlSetText( "EURISD,H1", "",59648 , "M15+{ENTER}")

nut nothing happened.
Maybe ControlID is wrong for the inner window.

Shay Levi

ulest,
24. feb. 2008, 06:14:2924.02.2008
til
try to set the ClassnameNN "AfxFrameOrView4245" as the ID:

$autoitx.ControlSetText( "EURISD,H1", "","AfxFrameOrView4245" , "M15+{ENTER}")

pjo

ulest,
24. feb. 2008, 10:22:0024.02.2008
til
I also tried to double click the top bar which has focus:

$autoitx.ControlClick("","","[CLASNN:AfxFrameOrView425]","LEFT",2)

this returns 0 which is failure.

pjo

ulest,
24. feb. 2008, 10:27:0424.02.2008
til
$autoitx.ControlClick("","","AfxFrameOrView425","LEFT",2)
this works sometime.

Sending Alt+1
$autoitx.ControlSetText("","","AfxFrameOrView425","{ALT}+1")
or
$autoitx.ControlSetText("","","AfxFrameOrView425","{ALT}1")
which is correct ?

pjo

ulest,
24. feb. 2008, 10:48:0124.02.2008
til
There is a typo

$autoitx.ControlSend("","","AfxFrameOrView4245","{ALT}+1")
this returns 1
but the result is nothing, I mean nothing was changed in the window.

Shay Levi

ulest,
24. feb. 2008, 11:01:4724.02.2008
til

Is the window your working on is a system window, which I can test, or is
it a custom application window?

pjo

ulest,
24. feb. 2008, 17:21:0124.02.2008
til
The app I am working on was developed by MetaQuote, and the name is Meta
Trader 4.

pjo

ulest,
24. feb. 2008, 18:08:0024.02.2008
til
BTW MT4 is free but requires registration.

pjo

ulest,
24. feb. 2008, 21:19:0024.02.2008
til
Hello !

Finally I got it working !
$autoitx.ControlSend("","",59648,"!1")

$autoitx.ControlSetText("","","AfxFrameOrView4245","{ALT}+1")
this was not sending ALT+1

pjo

ulest,
10. mars 2008, 12:21:0110.03.2008
til
Hi! I have been working on this script.

# $autoitx.Send("!1") Alt + 1 is asssigned to SterEA....


$autoitx.ControlSend("", "",59648,"!1")

# uncheck Confirm
$autoitx.ControlClick("", "",1064,"LEFT")

# Click OK
$autoitx.ControlClick("", "",1,"LEFT")

The ControlClick works sometime, not always.
I am wondering why.

By using Au3Info.exe the window Control ID is taken in the Control tab of
the Au3Info.
What would be the cause of this phenomena ?

pjo

Shay Levi

ulest,
10. mars 2008, 12:33:1910.03.2008
til
Try to sleep between clicks.

-----
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com

> Hi! I have been working on this script.

pjo

ulest,
10. mars 2008, 20:15:0010.03.2008
til
Thanks Shay,

It worked !
Your comments are always superb !

pjo

pjo

ulest,
11. mars 2008, 07:32:0011.03.2008
til
Using Windows standard key stroke to minimize a window,
Alt+-+n works fine if inputed using keyboard.

But

Start-Sleep 2
$autoitx.ControlSend("","",59648,"!-")
# Start-Sleep -Milliseconds 500
$autoitx.ControlSend("","",59648,"n")

This does not work for the same window.

Please advise how to do this ?
----------------------------------
The other question is:
After opening a window is there any way to get the control ID of that window
in AutoitX ?

pjo

Shay Levi

ulest,
11. mars 2008, 07:42:5411.03.2008
til

Hi

You can also use the AutoIT's sleep function:

$autoitx.Sleep(x) #milliseconds

To minimize a window (blank notepad window):
$autoitx.WinSetState("Untitled -", "", $autoitx.SW_MINIMIZE)

pjo

ulest,
11. mars 2008, 09:14:0011.03.2008
til
Thanks Shay,

Since the window is a window within that application window,
I am trying to access it as CLASS,

$autoitx.WinSetState("[CLASS:AfxFrameOrView42]", "", $autoitx.SW_MINIMIZE)

But this does not work.

Any idea ?

pjo

Shay Levi

ulest,
11. mars 2008, 09:20:2911.03.2008
til

The first parameter is for the window title so I don't think it will work
the way you suggested:

WinSetState "title", "text", flag

Can you think of an equivalent system window (XP) that has MDI windows I
can test?
Can you minimize it by mouse clicks?

pjo

ulest,
11. mars 2008, 09:52:0211.03.2008
til
Yes.

Window within a windows app is this one I am working on, which is
MetaTrader 4 from MetaQuote, this is free, registration is required.

The url is
http://www.alpari-idc.com/

No money payment is required for a demo account.
As a default setting you will see four window in MT4, I think.

Yes I can minimize it with mouse click.
But again it will be difficult to move mouse to minimize button.

pjo

Shay Levi

ulest,
12. mars 2008, 05:25:4312.03.2008
til

Try to set coord mode to "Window", use Au3Info.exe to pick the mouse coordinates
and then
send a mouse click. It shouldn't be that hard to implement.

Joel (Jaykul) Bennett

ulest,
14. mars 2008, 23:25:2614.03.2008
til
You guys might want to check out:

http://CodePlex.com/WASP/ which is specifically for automating windows
in PowerShell
http://CodePlex.com/White/ which is a .net windows automation package

0 nye meldinger