What coords to click from other corners (instead of top/left) Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
whats_up
Posts: 86
Joined: 29 Apr 2018, 05:09

What coords to click from other corners (instead of top/left)

29 Apr 2018, 05:34

I need to click, but I cannot find info about syntax of coords, if for example, I want to click x350 y350 not from TOP LEFT, but counting 350px and 350px from the BOTTOM LEFT corner.

Here is my simple code:

Code: Select all

x::ControlClick, x350 y350, WinTitle
Is there should be some kinda function? If so, does anybody have it?

Thanks in advance! ;)
User avatar
Masonjar13
Posts: 1555
Joined: 20 Jul 2014, 10:16
Location: Не Россия
Contact:

Re: What coords to click from other corners (instead of top/left)

29 Apr 2018, 15:58

A bit of math can do that.

Code: Select all

x::controlClick,% "x350 y" . a_screenHeight - 350,WinTitle
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build
User avatar
whats_up
Posts: 86
Joined: 29 Apr 2018, 05:09

Re: What coords to click from other corners (instead of top/left)

29 Apr 2018, 23:31

Masonjar13 wrote: ...
Nice solution, but it actually does not work.

Because you've written a_screenHeight, but I need height of the active window.

So, for simple example we can take Paint:

Code: Select all

SetTitleMatchMode, 2
#IfWinActive Paint
{
  x::ControlClick, % "x350 y" . A_ScreenHeight - 350, Paint
}
And you will see, that pressing of X will draw dots not from 350/350px Paint's left/bottom corner.
I've already tried A_GuiHeight, but it doesn't work at all :think:
User avatar
Masonjar13
Posts: 1555
Joined: 20 Jul 2014, 10:16
Location: Не Россия
Contact:

Re: What coords to click from other corners (instead of top/left)  Topic is solved

30 Apr 2018, 11:27

Probably should have specified which corner you were referring to in your OP. You can get the offset using the same math, but replace a_screenHeight with the window height.

Code: Select all

winTitle:="ahk_class MSPaintApp ahk_exe mspaint.exe"
#if winActive(winTitle)
x::
winGetPos,,,,wh
controlClick,% "x350 y" . wh - 350,% winTitle
return
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build
User avatar
whats_up
Posts: 86
Joined: 29 Apr 2018, 05:09

Re: What coords to click from other corners (instead of top/left)

01 May 2018, 18:12

Masonjar13 wrote:Probably should have specified which corner you were referring to in your OP. You can get the offset using the same math, but replace a_screenHeight with the window height.

Code: Select all

winTitle:="ahk_class MSPaintApp ahk_exe mspaint.exe"
#if winActive(winTitle)
x::
winGetPos,,,,wh
controlClick,% "x350 y" . wh - 350,% winTitle
return
Thanks, this one works!

Although, I don't understand what "return" does. Can you explain in simple way? I did read the docs, but can't get it.
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: What coords to click from other corners (instead of top/left)

01 May 2018, 19:00

in this context(that is, defining a hotkey) return marks the end of your hotkey subroutine, so that other stuff(labels, hotkeys, what have u) uve declared below the hotkey dont get automatically executed when u trigger the hotkey

Code: Select all

x::
...
....
...mode stuff to do
...
...ok im done
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 425 guests