Jump to content

Minimized clicking -- Great for game-bots


Insolence
 Share

Recommended Posts

sorry for reviving this post, but has anyone got this working?

I need badly a mouse click function that works even if the program is not in focus, but this baby doesn't seem to be working for me, heck it doesn't even work in MSpaint or notepad.....

did I do something wrong or does it not work for V3?

Link to comment
Share on other sites

  • 2 months later...
  • 2 weeks later...

Thank you for the code, took me awhile to get it working

DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  WinGetHandle( $Window ), _
        "int",   $WM_MOUSEMOVE, _
        "int",   0, _
        "long",  _MakeLong(Number($X), Number($Y)))

_MakeLong(Number($X), Number($Y))

Cuz it might mistaken it as a string >.>

Link to comment
Share on other sites

I'm trying to make an application launcher and I am looking for something like this. I found that instead of using WM_BUTTONDOWN, I should use WM_KEYPRESS. But I don't know what to put for the next parameter. Do I just put in the key, like "Y"? Or should it be in an ASCII code?

[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

Link to comment
Share on other sites

Why doesn't this work..?

Opt("MouseCoordMode", 0)

HotKeySet("{F1}", "go")

GUICreate("test")
$button = GUICtrlCreateButton("",-5,-5,500,500)
GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $button
            MsgBox(0,"","Yes")
    EndSelect
WEnd

Func go()
    _MouseClickPlus("test", "left", 50, 50) ;should click the button..
EndFunc

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     =  0x020
  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(Number($X), Number($Y)))
        
     DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  WinGetHandle( $Window ), _
        "int",   $ButtonDown, _
        "int",   $Button, _
        "long",  _MakeLong(Number($X), Number($Y)))
        
     DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  WinGetHandle( $Window ), _
        "int",   $ButtonUp, _
        "int",   $Button, _
        "long",  _MakeLong(Number($X), Number($Y)))
  Next
EndFunc

Func _MakeLong($LoWord,$HiWord)
    Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
EndFunc

This is a perfect test to see if it actually does infact work.. However it does not.

Kurt

Awaiting Diablo III..

Link to comment
Share on other sites

  • 2 weeks later...
  • 4 weeks later...
  • 2 months later...

Hello, I know this has been redug lots of times but if someone can prove this works on MSPaint for example then it would be incredibly helpful and the post can be stickied. I can imagine that lots of people are interested in this but are struggling to make it work.

In terms of the code I'm wondering if it's the user32.dll that's causing problems. I've tried using Filemon (third party program) to see if AutoIT accesses the file when running the script but it doesn't seem to be working. I created a loop continually running _MouseClickPlus but AutoIT only accesses user32.dll once despite my script being in a loop constantly running _MouseClickPlus.

Link to comment
Share on other sites

  • 4 weeks later...

i need help with this code, i need to write a script for diablo2, i run diablo2 windowed with d2loader

i need the code for click the enter chat button and after click on the channel button, all this when d2 windowed is minimized

can u help me please?

Link to comment
Share on other sites

  • 7 months later...
  • 1 month later...

Simple MouseDragPlus upgrade to first post:

CODE
Func _MouseDragPlus($Window, $Button = "left", $X1 = "", $Y1 = "", $X2 = "", $Y2 = "")

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

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 $X1 = "" OR $Y1 = "" OR $X2 = "" OR $Y2 = "" Then

$MouseCoord = MouseGetPos()

$X1 = $MouseCoord[0]

$Y1 = $MouseCoord[1]

$X2 = $MouseCoord[0]

$Y2 = $MouseCoord[1]

EndIf

DllCall("user32.dll", "int", "SendMessage", _

"hwnd", WinGetHandle( $Window ), _

"int", $WM_MOUSEMOVE, _

"int", 0, _

"long", _MakeLong($X1, $Y1))

DllCall("user32.dll", "int", "SendMessage", _

"hwnd", WinGetHandle( $Window ), _

"int", $ButtonDown, _

"int", $Button, _

"long", _MakeLong($X1, $Y1))

DllCall("user32.dll", "int", "SendMessage", _

"hwnd", WinGetHandle( $Window ), _

"int", $WM_MOUSEMOVE, _

"int", 0, _

"long", _MakeLong($X2, $Y2))

DllCall("user32.dll", "int", "SendMessage", _

"hwnd", WinGetHandle( $Window ), _

"int", $ButtonUp, _

"int", $Button, _

"long", _MakeLong($X2, $Y2))

EndFunc

Func _MakeLong($LoWord,$HiWord)

Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))

EndFunc

Link to comment
Share on other sites

  • 3 months later...
  • 3 weeks later...
  • 2 weeks later...
  • 2 months later...
  • 2 months later...
  • 3 months later...

Alright then. From looking at this topic it doesn't look like a lot of people have had successes with this so I'm posting an example of what I think the script should look like.

The best way of showing if the script has worked or not would be to test the script in MS Paint. That way if the click works then there's a large area of Paint where the effect can be seen. First you click on Paint's Fill button then run the script.

Theoretically the script should click a certain part of the screen and then fill it in a different colour from that of the original (typically white). The script below doesn't work but I'm interested in why it doesn't and I'm sure that if an answer can be found to make it work, it'd make it easier for other people to solve their own minimised windows click scripts.

Opt("MouseCoordMode", 0)

$winsize = WinGetPos("untitled - Paint")
$borderwidth = ($winsize[2] - 1024) / 2
$titleheight = $winsize[3] - 768 - (2 * $borderwidth)

_MouseClickPlus("untitled - Paint","left",500-$borderwidth,200-$TitleHeight)


;===============================================================================
;
; 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

Me too, who can help for an example for this function
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...