Jump to content

Mouseclick without moving mouse


 Share

Recommended Posts

Hi,

I was wondering how I send a mouseclick to a window (that doesn't have focus), but without moving the mouse. (Scenario could be a internet Explorer window).

I want the mouse to click at a specific set of coordinates.

As far as I can, the ControlClick doesn't allow me to specify where on the control to click. On the other hand, I can't send MouseClicks to a window in the background?

I suppose one solution could be store the "current" mouse-position, move the mouse, click, and move the mouse back? (and how do I deal with the focus?)

Link to comment
Share on other sites

Hi,

I was wondering how I send a mouseclick to a window (that doesn't have focus), but without moving the mouse. (Scenario could be a internet Explorer window).

I want the mouse to click at a specific set of coordinates.

As far as I can, the ControlClick doesn't allow me to specify where on the control to click. On the other hand, I can't send MouseClicks to a window in the background?

I suppose one solution could be store the "current" mouse-position, move the mouse, click, and move the mouse back? (and how do I deal with the focus?)

<{POST_SNAPBACK}>

Hello looks on the Help files on your Autoit3 Order! :idiot:

Or use The forum Search.You have troubel wis your code, then post it and any looks for it) :D

Edited by DirtyBanditos
Link to comment
Share on other sites

was wondering how I send a mouseclick to a window (that doesn't have focus)

Wouldnt that make the window active ?

So why not winactive and then mouseclick ?

Edited by Nova
Link to comment
Share on other sites

Wouldnt that make the window active ?

So why not winactive and then mouseclick ?

<{POST_SNAPBACK}>

Actually I have a "robot" for a game I play, that sends the mouseclick to my game and that doesn't make the window active, and was hoping I could do the same with AutoIt

PS sorry about the late reply, I didn't receive e-mail notifications

Link to comment
Share on other sites

Hello looks on the Help files on your Autoit3 Order! :idiot:

Or use The forum Search.You have troubel wis your code, then post it and any looks for it) :D

<{POST_SNAPBACK}>

Hehe, I don't have any code yet, but I'm searching for the function that will allow me to send a mouseclick to a unfocused window :lol:

I've looked at the online documentation and in the examples, but I couldn't seem to find what I'm looking for

Edited by Philster
Link to comment
Share on other sites

Scripts and Scraps forum, I made a UDF for it :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.
Link to comment
Share on other sites

http://www.autoitscript.com/forum/index.ph...12&hl=Insolence

I'll have a look, it seems exactly what I'm looking for

<{POST_SNAPBACK}>

Im trying to make it click in Internet Explorer, but I can't seem to make it work.

http://philip.act-consult.com/game.html

WinActivate ("http://philip.act-consult.com/game.html - Microsoft Internet Explorer", "")
WinWaitActive("http://philip.act-consult.com/game.html - Microsoft Internet Explorer")
MouseMove(531, 324, 3);just to see the coordinate is the blue button
_MouseClickPlus("http://philip.act-consult.com/game.html - Microsoft Internet Explorer", "left", 531, 324, 1)
;===============================================================================
;
; 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)
;Func _MouseClickPlus($Window, $Button, $X, $Y, $Clicks)
  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
Edited by Philster
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...