Jump to content

Mouse down inside of a controlclick?


John404
 Share

Recommended Posts

Hi all, I'm wanting to make controlclick send a mouse down then mouse up after 3 seconds(inside of a window), could I get any assistance with this? Have been searching for over 2 hours!!!

Edited by John404
Link to comment
Share on other sites

Something like that (untested):

Global $aCtrlPos = ControlGetPos("Title", "", "Control1")
Global $aMousePos_old = MouseGetPos()
MouseMove($aCtrlPos[0], $aCtrlPos[1], 0)
MouseDown("primary")
Sleep(3000)
MouseMove($aCtrlPos[0], $aCtrlPos[1], 0)
MouseUp("primary")
MouseMove($aMousePos_old[0], $aMousePos_old[1], 0)

Edit: Post 666 :evil:

Edited by funkey

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to comment
Share on other sites

Something like that (untested):

Global $aCtrlPos = ControlGetPos("Title", "", "Control1")
Global $aMousePos_old = MouseGetPos()
MouseMove($aCtrlPos[0], $aCtrlPos[1], 0)
MouseDown("primary")
Sleep(3000)
MouseMove($aCtrlPos[0], $aCtrlPos[1], 0)
MouseUp("primary")
MouseMove($aMousePos_old[0], $aMousePos_old[1], 0)

Edit: Post 666 :evil:

Hi, thanks for your reply

Is it possible to make this only work in the specified window just like normal clicks would? (So it doesn't interfere with my actual keyboard/mouse and I can multitask)

Edited by John404
Link to comment
Share on other sites

no thats not possible but suggestion is to run a virtual machine on your PC then you can multitask it independently

Which VM would you recommend? I've had trouble with them in the past.

Thanks for your help.

I once tried this as a sort of ControlClickDrag, never got there, even with C/++ I got the controlclick but the drag never worked.

Ah, thanks for your help. Hopefully someone will create a script for it one day kinda like _Mouseclickplus

Link to comment
Share on other sites

@John404: 
You can simulate the mouse down event using _WinAPI_PostMessage with $WM_LBUTTONDOWN, and using AdlibRegister to simulate the mouse up with $WM_LBUTTONUP, too. But you will *not* get the *click* behavior, because it requires the correct state when the button receive $WM_LBUTTONUP msg.
 
If what you expected is only down, then up, then a pair of _WinAPI_PostMessage is enough.
But if what you want is a mouse click in 3 secs after mouse down, then you need some tweak like this:

$hWndButtonToBeClick = GUICtrlGetHandle($idCtrlButtonToBeClick)

Func ClickWait()
  _WinAPI_PostMessage($hWndButtonToBeClick, $WM_LBUTTONDOWN, 0, 0)
  AdlibRegister(3000, 'ClickExecute')
EndFunc

Func ClickExecute()
  AdlibUnRegister('ClickExecute')
  _WinAPI_PostMessage($hWndButtonToBeClick, $WM_LBUTTONUP, 0, 0)
  ; Need addition message to simulate click!
  _WinAPI_PostMessage($hWndButtonToBeClick, $WM_LBUTTONDOWN, 0, 0)
  _WinAPI_PostMessage($hWndButtonToBeClick, $WM_LBUTTONUP, 0, 0)
EndFunc

Edit:

If you want to click a control in a window outside your script, then try ControlGetHandle instead of GUICtrlGetHandle

Edited by binhnx

99 little bugs in the code

99 little bugs!

Take one down, patch it around

117 little bugs in the code!

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...