Jump to content

ControlClick coords on a graphical applet


junkfood
 Share

Recommended Posts

Hi,

I'm trying to send some clicks to a web application written with some fancy java technology (Unity.WebPlayer). My problem is that clicks are way off and I cannot see where it's actually clicking (to backtrack the problem to some offset).

I searched for some way to create visual hints at the position where ControlClick clicks, but with no success. What can I do to find and click the correct position? I already considered the control offset and created a workaround with relative coordinates to the browser window (which kind of works, but isn't really satifying).

snippet:

    Local $webplayerControl = "[CLASS:Unity.WebPlayer; INSTANCE:1]"
    $hc = ControlGetHandle($windowTitle, "", $webplayerControl)
    $k = WinGetPos($hc)
    $pos1 = 50 ; + $k[0]
    $pos2 = 100 ;+ $k[1]
    $r = ControlClick($windowTitle, "", $webplayerControl, "left", 1, $pos1, $pos2)

In the applet is a clickable area at 50,100 which I use to test. The applet control has no ID, printing $hc to console gives a number which might be a pointer address, $r is always 1...

Link to comment
Share on other sites

Switch out to mouseclick (will require some mods to the AutoItSetOption), and set the movement speed to the slowest possible...then you can see.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

yep, that's why you need to make sure you have the proper mouse options...and make sure the window is active prior to sending the click.

The control click coords are relative to the control, btw, not the window (not sure what you are clicking relative).

clicking a control at 0,0 clicks the top left corner of that control.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

yep, that's why you need to make sure you have the proper mouse options...and make sure the window is active prior to sending the click.

 

I'm starting with WinWaitActive and then click the window.

The control click coords are relative to the control, btw, not the window (not sure what you are clicking relative).

 

Exactly my expectation, but something isn't working the way it should and I'm looking forward to find out why.

clicking a control at 0,0 clicks the top left corner of that control.

 

I know - and the button I like to click (for testing) is exactly where I said - 50px from the left, 100px from the top.

I think I found the problem, but I'm missing the reason and a solution. ControlClick clicks at the current position of the cursor. I got that during some tests with offsets - it doesn't matter what I do, I just have to place the cursor at the target with MouseMove (what I used for debugging at the beginning and just kept it because it was entertaining).

So why is that?

Link to comment
Share on other sites

  • Moderators

WinGetPos returns "Screen Coordinates"

Control* functions use "Client Coordinates"

You can use:

_WinAPI_ScreenToClient if you want, but you'd be better off using:

ControlGetPos() ; which will return Client Coords of the SPECIFIC control you want to interact with.

Edit:

FYI, in our Au3Info.exe tool, under options, you can change the Coord Mode to Client Coords, and you may be more enlightened.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Thanks for the hint with ControlGetPos, might be of use in the future. WinGetPos was working because I (unknowingly) needed it for the MouseMove command, but my thought behind it was wrong.

FYI, in our Au3Info.exe tool, under options, you can change the Coord Mode to Client Coords, and you may be more enlightened.

 

Thanks, but I looked at "ControlClick Coords" in the Control tab. I already found that switch, but it's only changing values on the Mouse tab as far as I can see.

But there's still the problem with the control "having no coordinate system". Don't know how to explain better than in my previous posts..

Link to comment
Share on other sites

  • Moderators

Anything past this point is a guess without me downloading the app myself.

You'll have three choices.

1.  Use the tool that I described to see where the x and y coords are as far as client.

2.  Convert the screen coords to client coords

3.  Use an alternative method, maybe >UIAutomation

Good luck all the same.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

It's working fine on the unity3d demo site [1]... I'm confused. Nevertheless, your answers aren't helpful - I already have client coords, it's just not clicking at the right place (as described above) and I think it's an issue with that specific piece of sh...ehm software I'm trying to automate. Maybe even on purpose.

I even had a look at UIAutomation - all it does is MouseClick at the end.

[1] http://unity3d.com/showcase/live-demos#camper

Link to comment
Share on other sites

  • Moderators

And now I'm grateful they weren't helpful.

Read the forum rules on gaming and AutoIt.

Don't start another topic on the matter.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...