Jump to content
Sign in to follow this  
pcdestroyer

help with minimized clicking ...

Recommended Posts

pcdestroyer

this function is used to click in a minimized window:

;===============================================================================
;
; 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>
;
;===============================================================================
Opt("MouseCoordMode", 0)
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
         ; this is where i use the function

$winsize = WinGetPos("Diablo II")
$borderwidth = ($winsize[2] - 800) / 2
$titleheight = $winsize[3] - 600 - (2 * $borderwidth)
_MouseClickPlus("Diablo II", "left", 275 - $borderwidth, 495 - $titleheight, 1)

so i want it to click @ (275, 495) but it doesnt .. there seems to be a problem with the variables ... if i substitute $borderwidth with its original value "3" and $titleheight with its original value "26" it works ... but when i use the variables it clicks on a completely different place ..... :idiot:

Edited by pcdestroyer

Share this post


Link to post
Share on other sites
Crome_BAD

Is that position a button, im workin with it right now also. I got the Single player button to work, and character stuff. Let me kno where ur clicking, and ill help ya

Peace,

Crome_BAD

Share this post


Link to post
Share on other sites
pcdestroyer

it doesnt matter if it is a button all im saying is when i use the variables it doesnt click on the correct place

Share this post


Link to post
Share on other sites
Crome_BAD

hmmm kk let me try a sample code real quick

Share this post


Link to post
Share on other sites
pcdestroyer

i think it's a bug with winsize or something because if i declare the variables like this:

$borderwidth = 3

$titleheight = 28

then it works ...

but if it is like this:

$winsize = WinGetPos("Diablo II")

$borderwidth = ($winsize[2] - 800) / 2

$titleheight = $winsize[3] - 600 - (2 * $borderwidth)

it doesnt work

Share this post


Link to post
Share on other sites
Insolence

Check what:

$winsize = WinGetPos("Diablo II")

Is returning...

The window has to be active and stuff.


"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
Crome_BAD

I think if u just declare $ycoord and $xcoord with 3 and 28, it will work from there on, ill see if i can come up with a solution to this...

Peace,

Crome_BAD

Share this post


Link to post
Share on other sites
pcdestroyer

oooooooh i see :idiot:)

so nvm it works fine :/

the window has to be active as insonlence just said :D

it didnt work cause it was minimized hehe

all right thnx a lot and sry for the inconvenience

Share this post


Link to post
Share on other sites
Insolence

None at all, but it worked though, right? :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
Crome_BAD

It works great. This will be alot easier then doing MouseClick

:idiot:

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.