"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
Tip: Press CTRL-ALT-F to freeze the display.
-----
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com
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
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)
; switch back to the default
Opt("MouseCoordMode", 1)
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")
Can I write the followings in PoerShell script ?
Opt("MouseCoordMode", 1)
MouseMove(175,517)
MouseDown("left")
Can I write the followings in PoerShell script ?
Opt("MouseCoordMode", 1)
MouseMove(175,517)
MouseDown("left")
By issueing TABs the button does not gets in focus.
I will try the other method,
$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)
The first opt should be 0 (Window) and the second is 1 (default)
I figured it out.
Now it is working.
I will search how to browse down the pull down menu, tree items down.
pjo
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 ?
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
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.
ControlSetText ( "title", "text", controlID, "new text" [, flag] )
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 ?
this requires "title" but the inner window does not have title.
nut nothing happened.
Maybe ControlID is wrong for the inner window.
$autoitx.ControlSetText( "EURISD,H1", "","AfxFrameOrView4245" , "M15+{ENTER}")
$autoitx.ControlClick("","","[CLASNN:AfxFrameOrView425]","LEFT",2)
this returns 0 which is failure.
Sending Alt+1
$autoitx.ControlSetText("","","AfxFrameOrView425","{ALT}+1")
or
$autoitx.ControlSetText("","","AfxFrameOrView425","{ALT}1")
which is correct ?
$autoitx.ControlSend("","","AfxFrameOrView4245","{ALT}+1")
this returns 1
but the result is nothing, I mean nothing was changed in the window.
Is the window your working on is a system window, which I can test, or is
it a custom application window?
Finally I got it working !
$autoitx.ControlSend("","",59648,"!1")
$autoitx.ControlSetText("","","AfxFrameOrView4245","{ALT}+1")
this was not sending ALT+1
# $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
$cript Fanatic
http://scriptolog.blogspot.com
> Hi! I have been working on this script.
It worked !
Your comments are always superb !
pjo
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
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)
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
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?
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
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.
http://CodePlex.com/WASP/ which is specifically for automating windows
in PowerShell
http://CodePlex.com/White/ which is a .net windows automation package