Is this possible?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
RozRoyal
Posts: 24
Joined: 21 Nov 2017, 14:19

Is this possible?

23 Nov 2017, 20:10

Hi!

Is it possible to click in an area where I last clicked?

For example, when I click in the blue area and move my mouse around, when I press a key I want to click in the same place where I first clicked

Image

What code should I use to do this?

Thank you!
Osprey
Posts: 453
Joined: 18 Nov 2017, 05:50

Re: Is this possible?

23 Nov 2017, 20:21

Code: Select all

~LButton::MouseGetPos, MouseX, MouseY

^LButton::Click %MouseX%, %MouseY%
With that, holding down Ctrl while left clicking will click in the same location that you last left clicked (while not holding Ctrl down).
RozRoyal
Posts: 24
Joined: 21 Nov 2017, 14:19

Re: Is this possible?

23 Nov 2017, 20:29

Thank you Osprey!
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Is this possible?

23 Nov 2017, 20:51

- That's a great script, cheers. I've done a little mod, that returns the mouse to where it was.
- Btw I believe that the CoordMode for the mouse is constantly reset to the default, so if the default was not screen, then you have to set it to screen in each hotkey subroutine.

Code: Select all

~LButton::
CoordMode, Mouse, Screen
MouseGetPos, vCurX, vCurY
return

^LButton::
SendInput, {Ctrl Up}{LButton Up}
CoordMode, Mouse, Screen
MouseGetPos, vCurX2, vCurY2
Click, % vCurX ", " vCurY
MouseMove, % vCurX2, % vCurY2
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
RozRoyal
Posts: 24
Joined: 21 Nov 2017, 14:19

Re: Is this possible?

24 Nov 2017, 10:14

Thank you Jeeswg! I will take a look : )
Last edited by RozRoyal on 24 Nov 2017, 10:37, edited 1 time in total.
RozRoyal
Posts: 24
Joined: 21 Nov 2017, 14:19

Re: Is this possible?

24 Nov 2017, 10:37

What if:
I click on the youtube video and then
I leave the video and interact with something ells by clicking
and when I come back to the youtube video I want to click in the same place I last clicked within that video?

How about this approach? I that possible?
vikcode

Re: Is this possible?

24 Nov 2017, 14:00

RozRoyal wrote:What if:
I click on the youtube video and then
I leave the video and interact with something ells by clicking
and when I come back to the youtube video I want to click in the same place I last clicked within that video?

How about this approach? I that possible?
you can make the entire thing only work if you are in the chrome or in the firefox, so maybe that an idea for you?
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Is this possible?

24 Nov 2017, 14:39

You can also restart/loop a video from a specific position using YouTube's command line/URL "start"-parameter (the value is counted in seconds)

[your original url]
[... starting at minute 1.30 = 90sec] (uses ...&start=90)
[... starting at minute 1.50 = 110sec] (uses ...&t=1m50s)

Another option if you're interested in start+end time: http://www.youtubestartend.com/
Osprey
Posts: 453
Joined: 18 Nov 2017, 05:50

Re: Is this possible?

24 Nov 2017, 19:26

The following will save the position of your last click on every window or tab, allowing you to re-click there, no matter how many other windows or tabs you've visited since:

Code: Select all

Array := Object()                      ; Create an array that will be used for saving mouse click coordinates for each window
CoordMode, Mouse, Client               ; Limit mouse coordinate saving to only the client area of each window (i.e. the area excluding the title bar and borders)

~LButton::
  WinGetActiveTitle, CurrentWindow     ; Get the title of the currently active window
  MouseGetPos, MouseX, MouseY          ; Get the current mouse coordinates
  Array[CurrentWindow, "X"] := MouseX  ; Save the mouse's X coordinates in the array for the current active window title
  Array[CurrentWindow, "Y"] := MouseY  ; Save the mouse's Y coordinates in the array for the current active window title
return

^LButton::
  WinGetActiveTitle, CurrentWindow     ; Get the title of the currently active window
  MouseX := Array[CurrentWindow, "X"]  ; Retrieve the mouse's X coordinates from the array for the current active window title
  MouseY := Array[CurrentWindow, "Y"]  ; Retrieve the mouse's Y coordinates from the array for the current active window title
  Click %MouseX%, %MouseY%             ; Click on those mouse coordinates
return
Two caveats:
* It relies on unique window titles, so, for example, if you have two tabs open with the title of "New Tab", it'll treat them as the same window.
* If you plan to use it with tabs in a browser, you should use the standard Ctrl+Tab and Ctrl+Shift+Tab shortcuts to switch tabs, since clicking on a tab to change to it counts as a click on that first tab.

If you want a little more control (and to avoid the second issue), you might consider changing "~LButton" above to, for example, "+LButton", so that you need to Shift-click to save coordinates. That would allow you to click around the same page without erasing the coordinates that you saved. In that case, think of it like a clipboard for mouse coordinates, but, instead of Ctrl+C and Ctrl+V, you're doing Shift+click and Ctrl+click. In fact, it might may more sense to do Ctrl+click (^LButton::) to store the click and Alt+click (!LButton::) to re-click, since Ctrl and Alt are left and right of one another, like C and V are.
Last edited by Osprey on 25 Nov 2017, 13:22, edited 9 times in total.
RozRoyal
Posts: 24
Joined: 21 Nov 2017, 14:19

Re: Is this possible?

25 Nov 2017, 00:46

OMG! Osprey you are a legend!!! THANK YOU!!!

I would give you a tenner if I could!!!

Thanks BoBo and Vikcode for the tips!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: jameswrightesq, wpulford and 426 guests