John404 Posted October 22, 2014 Share Posted October 22, 2014 (edited) 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 October 22, 2014 by John404 Link to comment Share on other sites More sharing options...
funkey Posted October 22, 2014 Share Posted October 22, 2014 (edited) 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 Edited October 22, 2014 by funkey Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. Link to comment Share on other sites More sharing options...
John404 Posted October 22, 2014 Author Share Posted October 22, 2014 (edited) 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 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 October 22, 2014 by John404 Link to comment Share on other sites More sharing options...
junkew Posted October 22, 2014 Share Posted October 22, 2014 no thats not possible but suggestion is to run a virtual machine on your PC then you can multitask it independently FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
JohnOne Posted October 22, 2014 Share Posted October 22, 2014 I once tried this as a sort of ControlClickDrag, never got there, even with C/++ I got the controlclick but the drag never worked. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
John404 Posted October 22, 2014 Author Share Posted October 22, 2014 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 More sharing options...
binhnx Posted October 23, 2014 Share Posted October 23, 2014 (edited) @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) EndFuncEdit: If you want to click a control in a window outside your script, then try ControlGetHandle instead of GUICtrlGetHandle Edited October 23, 2014 by binhnx 232showtime 1 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 More sharing options...
232showtime Posted October 23, 2014 Share Posted October 23, 2014 really nice tweak binhnx.. love it... ill get to that... i still need to learn and understand a lot of codes Correct answer, learn to walk before you take on that marathon. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now