epicfail Posted September 13, 2009 Share Posted September 13, 2009 hello guys i want to make a click bot to click on the screen but how do i make it to click the same spot of the screen no matter what the screen resolution is set as and to work on any computer can that be done? Link to comment Share on other sites More sharing options...
Sobiech Posted September 13, 2009 Share Posted September 13, 2009 (edited) 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 edit: and insert this expandcollapse popup;=============================================================================== ; ; 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 Edited September 13, 2009 by Sobiech This world is crazy Link to comment Share on other sites More sharing options...
epicfail Posted September 13, 2009 Author Share Posted September 13, 2009 i cant seem to get that working Link to comment Share on other sites More sharing options...
eastmus Posted September 13, 2009 Share Posted September 13, 2009 (edited) $x = @DesktopWidth $y = @DesktopHeight Edited September 13, 2009 by eastmus Link to comment Share on other sites More sharing options...
Hawkwing Posted September 13, 2009 Share Posted September 13, 2009 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 More sharing options...
jvanegmond Posted September 13, 2009 Share Posted September 13, 2009 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 github.com/jvanegmond Link to comment Share on other sites More sharing options...
Hawkwing Posted September 13, 2009 Share Posted September 13, 2009 (edited) Here's the math, you can work it out into a script (none of the above are correct):userX = scripterX / scripterDesktopWidth * userDesktopWidthuserY = scripterY / scripterDesktopHeight * userDesktopHeightYou 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 September 13, 2009 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 More sharing options...
jvanegmond Posted September 13, 2009 Share Posted September 13, 2009 Sorry, I read over the brackets/didn't realize the expression would be evaluated as a whole before performing it on the variables $x and $y.userX = scripterX / (scripterDesktopWidth / userDesktopWidth)is a lot different than what I read:userX = scripterX / scripterDesktopWidth / userDesktopWidth: ) github.com/jvanegmond Link to comment Share on other sites More sharing options...
DW1 Posted September 13, 2009 Share Posted September 13, 2009 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) ) AutoIt3 Online Help Link to comment Share on other sites More sharing options...
Hawkwing Posted September 13, 2009 Share Posted September 13, 2009 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 More sharing options...
DW1 Posted September 13, 2009 Share Posted September 13, 2009 Oh, well look at that! It's the same person!Please don't double post!Ahaha, lmao... didn't even notice that Hawking, good catch... now I'm really confused... whats not working for you OP? AutoIt3 Online Help Link to comment Share on other sites More sharing options...
epicfail Posted September 14, 2009 Author Share Posted September 14, 2009 i have tryed that script it only clicks where u click 1st how do i change it to click with out have to click 1st Link to comment Share on other sites More sharing options...
DW1 Posted September 14, 2009 Share Posted September 14, 2009 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: expandcollapse popup#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") AutoIt3 Online Help Link to comment Share on other sites More sharing options...
epicfail Posted September 14, 2009 Author Share Posted September 14, 2009 thankyou Link to comment Share on other sites More sharing options...
epicfail Posted September 14, 2009 Author Share Posted September 14, 2009 it dosnt really work it clicks a little bit off when i change my screen resolution! Is there a fix 4 that? Link to comment Share on other sites More sharing options...
jvanegmond Posted September 14, 2009 Share Posted September 14, 2009 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. github.com/jvanegmond Link to comment Share on other sites More sharing options...
epicfail Posted September 14, 2009 Author Share Posted September 14, 2009 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 More sharing options...
jvanegmond Posted September 14, 2009 Share Posted September 14, 2009 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. github.com/jvanegmond Link to comment Share on other sites More sharing options...
epicfail Posted September 14, 2009 Author Share Posted September 14, 2009 would it be cos im on a eee 900 pc it has like a 9inch screen? i will test it on my other computer tomorrow then Link to comment Share on other sites More sharing options...
jvanegmond Posted September 14, 2009 Share Posted September 14, 2009 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. github.com/jvanegmond Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now