Jump to content
Sign in to follow this  
Moonlit

Using Mouseclick on several resolutions

Recommended Posts

Hi All,

I have read several topics on this matter but somehow I can't figure out whats the exact thing I need to do to fix my script.

WIth some help of here I made a marvelous running script that manages the stock on our (ancient) application.
I also found out that pixelsearch and mouseclick are better not used so I changed to control click whenever I could.

However there is one part of this app that loads a screen in a screen which I cannot control with controlclick.
So I made it that pixelsearch detects that i'm in that particular screen (the top the bar changes color) and then it checks a radio button and clicks next ("Volgende" in the screen attached)

So far so good and all works great. But on PC's with different resolutions it doesn't work. Which makes sense since the X and Y are different then on my PC.
Now was I thinking of making a IF THEN ELSE for all resolutions but a quick search in our hardware list showed me thats one hell of a job :)

So before I do that is there a better way to make a mouseclick on a certain place (the window is always in the middle of the "main" window and cannot be moved or resized) based on resolution?

I tested it with 1920x1080 and 1024x768 and such so I can make it work if that's the best/only way to do it but I was hoping for a more stable way. (if someone changes screen to 23 inch for example I need to add that to the script as well).

Most of the information I find is 1) from long ago and 2) to hard for me to understand.

I did find a piece of code which looks like this:

; CONFIG ----------------------
;Display Resolution:
$screenX = 1440
$screenY = 900
; CONFIG ----------------------




$technischX = $screenX/2.01
$technischY = $screenY/1.06

$volgendeX = $screenX/12.5
$volgendeY = $screenY/1.065

So i was thinking of adding a form where people would need to input their resolution BUT i dont know how they figured out the numbers like 2.01 and 12.5

What I understand from other topics is that you need to do some math but it's not clear what I need to calculate...

In a post from 2007 someone states that: " you can check it by @DesktopWidth and @DesktopHeight macros " But I couldn't find a working one or how to make it.

I also found this piece of code:

$flashXa = 512, $flashYa = 256 ; Your intended coordinates on the original 800x600 desktop
_ConvertXY($flashXa, $flashYa) ; Convert proportionally to the actual desktop size
MouseClick("left", $flashXa, $flashYa) ; Use the new values to click

$flashXb = 300, $flashYb = 400
_ConvertXY($flashXb, $flashYb)
MouseClick("left", $flashXb, $flashYb)

; Fuction to convert screen coordinates
Func _ConvertXY(ByRef $Xin, ByRef $Yin)
     $Xin = Round( ($Xin / 800) * @DesktopWidth )
     $Yin = Round( ($Yin / 600) * @DesktopHeight )
EndFunc

But don't know what it is that I do with it? LIke put in my resolution and correct mouseclick and just add it in the loop as a function? So FlashXa is my resolution and flashXB is the place where to click? I tried that but it didn't do anything (as far as I could tell)

Sorry if it ain't clear but the subject is a bit confusing for me :)

Thanks in advance for anyone to clear this up for me!

voorraad.png

Share this post


Link to post
Share on other sites

2 questions. Can you verify the existence of the window with WinExists () based on its title ?  If screen resolution changes, does this window also change in size ?

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...