Execute script with ClassNN, and from bottom right position.. Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
wise_mike
Posts: 90
Joined: 28 Feb 2014, 01:37

Execute script with ClassNN, and from bottom right position..

13 Dec 2018, 01:33

I am using a graphics software that has child windows, each with ClassNN: AfxFrameOrView#### (where #### are changing numbers for each window). I want to MouseMove, 40, 40, relative to the current child window (starting from the bottom right, not from the default top left). However when I try, it always go to that position for the whole software window and not the child window.

I tried something like the following, but I am missing how to point to any ClassNN that starts with "AfxFrameOrView", and how to point to the position in that window from the bottom right position:

Code: Select all

Numpad0::
controlgetfocus, thiscontrol
if(thiscontrol = "AfxFrameOrView")
ControlFocus, "AfxFrameOrView"
MouseMove, -40, -40, Relative
Return
Here is an image of the program:
Image
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Execute script with ClassNN, and from bottom right position..

13 Dec 2018, 02:06

Something like this might be useful. Cheers.

Code: Select all

q:: ;Notepad Find dialog - move cursor relative to Edit control
ControlGet, hCtl, Hwnd,, Edit1, A
WinGetPos, vCtlX, vCtlY,,, % "ahk_id " hCtl
CoordMode, Mouse, Screen
MouseMove, % vCtlX+5, % vCtlY+5
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
wise_mike
Posts: 90
Joined: 28 Feb 2014, 01:37

Re: Execute script with ClassNN, and from bottom right position..

13 Dec 2018, 03:26

I am not sure I follow you. I tried to put the control name instead of Edit1 in your example, and the ahk_pid from Window Spy instead of the ahk_id you mentioned, but it didn't do anything. Can you please edit the original script in my post as suggested if possible? Thanks

Code: Select all

Numpad0::
ControlGet, hCtl, Hwnd,, AfxFrameOrView, A
WinGetPos, vCtlX, vCtlY,,, % "14860 " hCtl
CoordMode, Mouse, Screen
MouseMove, % vCtlX+5, % vCtlY+5
return
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Execute script with ClassNN, and from bottom right position..  Topic is solved

13 Dec 2018, 05:28

Perhaps like this.

Code: Select all

q::
ControlGetFocus, vCtlClassNN, A
if (SubStr(vCtlClassNN, 1, 14) = "AfxFrameOrView")
{
	ControlGet, hCtl, Hwnd,, % vCtlClassNN, A
	WinGetPos, vCtlX, vCtlY,,, % "ahk_id " hCtl
	CoordMode, Mouse, Screen
	MouseMove, % vCtlX+5, % vCtlY+5
}
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
wise_mike
Posts: 90
Joined: 28 Feb 2014, 01:37

Re: Execute script with ClassNN, and from bottom right position..

13 Dec 2018, 07:12

Thanks.. it worked great..

One final thing, is it possible with the same code to MouseMove with a percentage instead of pixels? And what should the edit to the code be?
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Execute script with ClassNN, and from bottom right position..

13 Dec 2018, 12:49

This would move the cursor to the centre of the control.

Code: Select all

q::
ControlGetFocus, vCtlClassNN, A
if (SubStr(vCtlClassNN, 1, 14) = "AfxFrameOrView")
{
	ControlGet, hCtl, Hwnd,, % vCtlClassNN, A
	WinGetPos, vCtlX, vCtlY, vCtlW, vCtlH, % "ahk_id " hCtl
	CoordMode, Mouse, Screen
	MouseMove, % vCtlX+vCtlW*0.5, % vCtlY+vCtlH*0.5
}
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
SteveMylo
Posts: 233
Joined: 22 Jun 2021, 00:50
Location: Australia
Contact:

Re: Execute script with ClassNN, and from bottom right position..

28 Nov 2021, 01:50

jeeswg wrote:
13 Dec 2018, 12:49
This would move the cursor to the centre of the control.
Years later, this has helped me so much. Just found this. Thanks jeeswg

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: downstairs, mikeyww and 301 guests