Jump to content

mouse click all Screen Resolution


epicfail
 Share

Recommended Posts

Maybe just convert it to a percentage across the screen?

Like this:

#Include <Misc.au3>

ToolTip( "Waiting for you to click the mouse to set initial position", @DesktopWidth / 2, 50, "Awaiting input.", 1, 2 )
;Set mouse click position
While 1
    If _IsPressed( 01 ) Then
        $MP = MouseGetPos()
        $RelativePOSX = $MP[0] / @DesktopWidth
        $RelativePOSY = $MP[1] / @DesktopHeight
        ToolTip("")
        ExitLoop
    EndIf
    Sleep(10)
WEnd
MsgBox( 0, "TEST Relative mouse click", $RelativePOSX * 100 & "% of desktop width." & @CRLF & $RelativePOSY * 100 & "% of desktop Height." )
Link to comment
Share on other sites

It would be almost the same thing.

You would want to change the mouse coordinate mode to the active window though, and take the app windows height and width for comparison instead of the desktop.

like this:

#Include <Misc.au3>
Opt( 'MouseCoordMode', 0 )
ToolTip( "Waiting for you to click the mouse to set initial position", @DesktopWidth / 2, 50, "Awaiting input.", 1, 2 )
;Set mouse click position
While 1
    If _IsPressed( 01 ) Then
        $MP = MouseGetPos()
        $size = WinGetPos("[active]")
        $app = WinGetTitle("[active]")
        $RelativePOSX = $MP[0] / $size[2]
        $RelativePOSY = $MP[1] / $size[3]
        ToolTip("")
        ExitLoop
    EndIf
    Sleep(10)
WEnd
MsgBox( 0, "TEST Relative mouse click", $RelativePOSX * 100 & "% of " & $app & " width." & @CRLF & $RelativePOSY * 100 & "% of " & $app & " Height." )
Link to comment
Share on other sites

In an effort to give a better example, I have included the code used to click the mouse on the saved relative coordinates:

#include <Misc.au3>
Opt('MouseCoordMode', 0)
ToolTip("Waiting for you to click the mouse to set initial position", @DesktopWidth / 2, 50, "Awaiting input.", 1, 2)
;Set mouse click position
While 1
    If _IsPressed(01) Then
        $MP = MouseGetPos()
        $size = WinGetPos("[active]")
        $app = WinGetTitle("[active]")
        $RelativePOSX = $MP[0] / $size[2]
        $RelativePOSY = $MP[1] / $size[3]
        ToolTip("")
        ExitLoop
    EndIf
    Sleep(10)
WEnd
MsgBox(0, "TEST Relative mouse click", $RelativePOSX * 100 & "% of " & $app & " width." & @CRLF & $RelativePOSY * 100 & "% of " & $app & " Height." )

$sizeApp = WinGetPos($app)

MsgBox(0, "Example", "Using Opt('MouseCoordMode', 0) still" )
WinActivate( $app )
MouseClick( "Left", $sizeApp[2] * $RelativePOSX, $sizeApp[3] * $RelativePOSY)

MsgBox(0, "Example", "Using Opt('MouseCoordMode', 1)" )
Opt( 'MouseCoordMode', 1)
WinActivate($app)
MouseClick( "Left", $sizeApp[0] + ($sizeApp[2] * $RelativePOSX), $sizeApp[1] + ($sizeApp[3] * $RelativePOSY) )
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...