Jump to content

click bot work 4 all screen resolution


epicfail
 Share

Recommended Posts

Maybe this can help you

http://www.autoitscript.com/forum/index.php?showtopic=7112&st=0&p=50203&fromsearch=1&#entry50203

$winsize = WinGetPos("Diablo II")
 $borderwidth = ($winsize[2] - 800) / 2
 $titleheight = $winsize[3] - 600 - (2 * $borderwidth)
 
 msgbox("", "", $borderwidth & " " & $titleheight)

and

_MouseClickPlus( "Diablo II", "left", 525 - $borderwidth, 585 - $TitleHeight )

$borderwidth = ($winsize[2] - Width) / 2
 $titleheight = $winsize[3] - Height - (2 * $borderwidth)

try use:

$borderwidth1 & $titleheight1

$borderwidth2 & $titleheight2

$borderwidth3 & $titleheight3

$borderwidth4 & $titleheight4

For others resolutions and use this below

_MouseClickPlus( "Name of Game Window", "mouse button here", Width - $borderwidthX, Height - $TitleHeightY )

But read the Insolence topic :D

edit: and insert this

;===============================================================================
  ;
  ; Function Name:  _MouseClickPlus()
  ; Version added:  0.1
  ; Description:    Sends a click to window, not entirely accurate, but works 
  ;                 minimized.
  ; Parameter(s):   $Window     =  Title of the window to send click to
  ;                 $Button     =  "left" or "right" mouse button
  ;                 $X          =  X coordinate
  ;                 $Y          =  Y coordinate
  ;                 $Clicks     =  Number of clicks to send
  ; Remarks:        You MUST be in "MouseCoordMode" 0 to use this without bugs.
  ; Author(s):      Insolence <insolence_9@yahoo.com>
  ;
  ;===============================================================================
 Func _MouseClickPlus($Window, $Button = "left", $X = "", $Y = "", $Clicks = 1)
    Local $MK_LBUTTON       =  0x0001
    Local $WM_LBUTTONDOWN   =  0x0201
    Local $WM_LBUTTONUP     =  0x0202
    
    Local $MK_RBUTTON       =  0x0002   
    Local $WM_RBUTTONDOWN   =  0x0204
    Local $WM_RBUTTONUP     =  0x0205
 
    Local $WM_MOUSEMOVE     =  0x0200
    
    Local $i                = 0
    
    Select 
    Case $Button = "left"
       $Button     =  $MK_LBUTTON
       $ButtonDown =  $WM_LBUTTONDOWN
       $ButtonUp   =  $WM_LBUTTONUP
    Case $Button = "right"
       $Button     =  $MK_RBUTTON
       $ButtonDown =  $WM_RBUTTONDOWN
       $ButtonUp   =  $WM_RBUTTONUP
    EndSelect
    
    If $X = "" OR $Y = "" Then
       $MouseCoord = MouseGetPos()
       $X = $MouseCoord[0]
       $Y = $MouseCoord[1]
    EndIf
    
    For $i = 1 to $Clicks
       DllCall("user32.dll", "int", "SendMessage", _
          "hwnd",  WinGetHandle( $Window ), _
          "int",   $WM_MOUSEMOVE, _
          "int",   0, _
          "long",  _MakeLong($X, $Y))
          
       DllCall("user32.dll", "int", "SendMessage", _
          "hwnd",  WinGetHandle( $Window ), _
          "int",   $ButtonDown, _
          "int",   $Button, _
          "long",  _MakeLong($X, $Y))
          
       DllCall("user32.dll", "int", "SendMessage", _
          "hwnd",  WinGetHandle( $Window ), _
          "int",   $ButtonUp, _
          "int",   $Button, _
          "long",  _MakeLong($X, $Y))
    Next
 EndFunc
 
 
 
 
 Func _MakeLong($LoWord,$HiWord)
    Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
 EndFunc

I think this can be include as "#include <MouseClickPlus.au3>" but you must modifity subfolders in program :D

Edited by Sobiech

This world is crazy

Link to comment
Share on other sites

Not sure if it will work, but you could try something like this.

$x = 10
$y = 10
$x /= (1280 / @desktopwidth)
$y /= (1024 / @desktopheight)
mouseclick("left", $x, $y)

Just wrote this off the top of my head, so it may require some editing.

The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

Link to comment
Share on other sites

Here's the math, you can work it out into a script (none of the above are correct):

userX = scripterX / scripterDesktopWidth * userDesktopWidth

userY = scripterY / scripterDesktopHeight * userDesktopHeight

You sure? Just tested mine, and it seemed to work fine. Just replace 1280 and 1024 with whatever your current width/height is.

Edit: Well, you also have to replace the first declarations of $x and $y with wherever you want to click, but I think you could figure that out.

Edited by Hawkwing

The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

Link to comment
Share on other sites

Try searching first, as this has already been answered many times.

Look at the following example and see if it will help you:

#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

Oh, well look at that! It's the same person!

Please don't double post!

The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

Link to comment
Share on other sites

It was an example that was supposed to lead you to discover the code you need. Here is an example that gives you the code to be used as well:

#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

$sizeApp = WinGetPos($app)



$code1 = "Opt('MouseCoordMode', 0)" & @CRLF & '$sizeApp = WinGetPos("' & $app & '")' & @CRLF & _
        'MouseClick( "Left", $sizeApp[2] * ' & $RelativePOSX & ', $sizeApp[3] * ' & $RelativePOSY & ' )'
MsgBox(0, "Example", "Using Opt('MouseCoordMode', 0)" & @CRLF & _
        'Code:' & @CRLF & @CRLF & $code1)
WinActivate($app)
MouseClick("Left", $sizeApp[2] * $RelativePOSX, $sizeApp[3] * $RelativePOSY)



$code2 = "Opt('MouseCoordMode', 1)" & @CRLF & '$sizeApp = WinGetPos("' & $app & '")' & @CRLF & _
        'MouseClick( "Left", $sizeApp[0] + ($sizeApp[2] * ' & $RelativePOSX & '), $sizeApp[1] + ($sizeApp[3] * ' & $RelativePOSY & '))'
MsgBox(0, "Example", "Using Opt('MouseCoordMode', 1)" & @CRLF & _
        'Code:' & @CRLF & @CRLF & $code2)
Opt('MouseCoordMode', 1)
WinActivate($app)
MouseClick("Left", $sizeApp[0] + ($sizeApp[2] * $RelativePOSX), $sizeApp[1] + ($sizeApp[3] * $RelativePOSY))


ClipPut( $code1 & @CRLF & $code2 )
MsgBox(0, "Copied Code", "Example 1 and 2 set to clipboard")
Link to comment
Share on other sites

No, the math that is used for this is perfect. There may be some rounding issues, but that's only a problem if you want precision up to 0.0001 behind the comma.

It's more likely that the window you are trying to automate moves it's controls around in a non uniform way, then you'll have to use controlX functions.

Link to comment
Share on other sites

what u mean? i set my screen resolution to 800x600 and i use the script to record the pos i click on the my computer icon and then i copy the code into a script then run it it works in that resolution but as soon as i change my resolution to higher it clicks heaps of it misses the my computer icon clicks under it.

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...