Sign in to follow this  
Followers 0
Insolence

Minimized clicking -- Great for game-bots

84 posts in this topic

#1 ·  Posted (edited)

;===============================================================================
  ;
  ; 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 Larry made the _MakeLong function, so credit goes to him on that. I got a lot of help on the entire thing, I just threw it into a function.

I'll have to figure out how to get the actual area size of the window excluding the title bar for some games, atleast in Diablo II.

EDIT: To get D2 offsets use this code:

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

And use it like so:

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

"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

Share this post


Link to post
Share on other sites

I kno this is a pointless post, but ive been trying to do that forever. THANK YOU ALOT!!!! lol. Im still very new to AutoIt.

Peace,

Crome_BAD

Share this post


Link to post
Share on other sites

Pointless by NO means!

I do this to help people, my personal benefit is minimal seeing as how I don't play the game.


"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

Share this post


Link to post
Share on other sites

ive been playing since it came out. I thank you for this wonderful function. Now to figure out how to use it:P

Very new at this...lol.

Crome_BAD

Share this post


Link to post
Share on other sites

I posted an example at the bottom of my script, just include that function inside your script and call it.

All you gotta do :idiot:


"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

Share this post


Link to post
Share on other sites

I make things so hard :idiot: Well, TY again

Share this post


Link to post
Share on other sites

very nice @insolence :D very nice !!!!!!!!! can u also use pixelgetcolor in a minimized window ?

:idiot:

Share this post


Link to post
Share on other sites

Well, i tried ur function with a test.au3 file, i couldnt get it to delete it. Any suggestions?

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

very nice @insolence :D very nice !!!!!!!!! can u also use pixelgetcolor in a minimized window ?

:idiot:

<{POST_SNAPBACK}>

Nope, sadly you cannot.

[EDIT]

Delete what???

Edited by Insolence

"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

Share this post


Link to post
Share on other sites

A file, i dont have diablo installed on this cp or i would test on it, all i have is a file saved in a folder, and the folder iz minimized, trying to delete it from there

Ive also tried MSWord i couldnt get it to click on the close button

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

wtf ? it wont click in the d2 window at alll dunno why ...

do i have to use borderwidht and title height ?

Edit: Insolence reply plz :idiot: it wont click man .. or if it clicks it clicks like 5 extra pixels in X axis and about 30 extra pixels in Y axis

Edited by pcdestroyer

Share this post


Link to post
Share on other sites

You have to use the offsets thing I supplied at the bottom.


"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

hmm .. i use the offset but it makes it even worse .....

it just doesnt work for me :idiot:

Edit: nevermind i got it !!!!!!!!! now it is 100% accurate with my editing in the script :D

give me some tiem ... ill post an explanation

Edited by pcdestroyer

Share this post


Link to post
Share on other sites

Alright :idiot:


"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

ok look @ the picture :D

enjoy :idiot:

Edited by Jon

Share this post


Link to post
Share on other sites

Yeah I knew that was the problem -.- I mentioned it in the first post.

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

msgbox("", "", $borderwidth & " " & $titleheight)

But you need to automize that, does the above code not find those values?

If not maybe this will work:

$winsize = WinGetPos("Diablo II")
$borderwidth = $winsize[2] - 800
$titleheight = $winsize[3] - 600

msgbox("", "", $borderwidth & " " & $titleheight)

"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

oooooooo :idiot: thnx :D)

Edit: hmm i tried it with $borderwidht and $titleheight ... but it clicks on a completely different place ... dont know why ;(

Edited by pcdestroyer

Share this post


Link to post
Share on other sites

Again Insolence, i thank you alot for this function. And to you PcDestroyer for clarifing it. Bots will be much easier :idiot:

Peace,

Crome_BAD

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

hmm... it seems that , when i use $borderwidth and $titleheight it clicks on a completely different place BUT if i use their real values which are "3" and "26" it works .... :idiot: if i use them as a variable it wont work ... is this a bug or something ?!

Edited by pcdestroyer

Share this post


Link to post
Share on other sites

No it's gotta be something in your script, why don't you post it in support.


"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0