Jump to content

Trying to retrieve Mouse-Coordinates on to-be-controlled Application Window


Olav
 Share

Recommended Posts

Hi!

I am trying to remote-control another application. For that to work properly I plan to make extensive use of the "PixelChecksum" function. So, I decided to start off programming a small tool that helps me grabbing the right pixel checksums. My plan is to:

1. start the application

2. start my script

3. move the mouse to the top-left corner of the pixel checksum area

4. hit a key

5. move the mouse to the bottom-right corner of the pixel checksum area

6. hit a key and get the checksum via ConsoleWrite

I thought this to be rather easy, however, I failed to register a message for the application window. Here is an excerpt of my script:

CODE
If WinActivate($cfg_window_title) <> 1 Then

Exit(1)

EndIf

$whd = WinGetHandle($cfg_window_title)

if $whd = "" Then

Exit(2)

EndIf

if GUISwitch($whd) = 0 Then

Exit(3)

EndIf

if GUIRegisterMsg(0x0101, "onkeyup") <> 1 Then

Exit(4)

EndIf

$cont = True

While $cont = True

sleep(500)

WEnd

I always get the error code 3, meaning that the script found the target windows, managed to actiavte it, but GUISwitch fails to switch to the given window handle. Any ideas? Any other way to achieve my actual goal of getting a tool for grabbing pixel checksums? Thank you very much!

Link to comment
Share on other sites

Hi!

I am trying to remote-control another application. For that to work properly I plan to make extensive use of the "PixelChecksum" function. So, I decided to start off programming a small tool that helps me grabbing the right pixel checksums. My plan is to:

1. start the application

2. start my script

3. move the mouse to the top-left corner of the pixel checksum area

4. hit a key

5. move the mouse to the bottom-right corner of the pixel checksum area

6. hit a key and get the checksum via ConsoleWrite

I thought this to be rather easy, however, I failed to register a message for the application window. Here is an excerpt of my script:

CODE
If WinActivate($cfg_window_title) <> 1 Then

Exit(1)

EndIf

$whd = WinGetHandle($cfg_window_title)

if $whd = "" Then

Exit(2)

EndIf

if GUISwitch($whd) = 0 Then

Exit(3)

EndIf

if GUIRegisterMsg(0x0101, "onkeyup") <> 1 Then

Exit(4)

EndIf

$cont = True

While $cont = True

sleep(500)

WEnd

I always get the error code 3, meaning that the script found the target windows, managed to actiavte it, but GUISwitch fails to switch to the given window handle. Any ideas? Any other way to achieve my actual goal of getting a tool for grabbing pixel checksums? Thank you very much!

GuiSwitch is used to switch to a gui in your script not a gui in another application.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

GuiSwitch is used to switch to a gui in your script not a gui in another application.

Thanks for the clarification! I tried another approach and it works. I managed to get the mouse coordinates without the appropriate window handle. Thanks again.

Cheers,

Olav

Link to comment
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
 Share

  • Recently Browsing   0 members

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