Tricky...trying to make hotkeys for a program without unique data

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
tjdickinson
Posts: 19
Joined: 07 May 2017, 12:43
Contact:

Tricky...trying to make hotkeys for a program without unique data

09 May 2017, 10:57

I have what I think might be really tricky questions. First a little context, and then the questions, followed by any relevant data which might help address the questions. If it's helpful, I can provide screenshots. Sorry in advance for this post being so long. I just want to include as much relevant information as I can. Thank you in advance for your kind help!

P.S. I'm not asking anyone to write the code for me. If someone does, great, thanks, that saves me a lot of time! But I'm really just asking for help understanding a world I know very little of. (My knowledge of programming in general is basically none...I understand some very--VERY--cursory things, but little beyond that.) Thanks again for your help!

CONTEXT
I'm using the program FontCreator 10.1, and the context of these questions pertains to the OpenType Designer feature. When this window opens, there are a few buttons on the top for adding and modifying scripts. To the left is a virtual tree with various entries for scripts, features, and lookups; only the lookups are relevant for this question. Along the bottom of the window are previews and various options, none of which are relevant.

The main part of the window determines the title of the whole window, as the window title changes depending on which type of the 13 lookup types is selected. Fortunately, the structure of the window is the same for some lookups, so it actually reduces to only 6 sets of hotkeys which could be duplicated as needed for the other lookup types.

Though the layout of the 6 window‑types differs, they have similar features, namely: add buttons, delete buttons, a list box or boxes, and spin boxes/buttons. Some windows have unique features. All features and their data are listed below in the section "DATA".

LIMITS
The limits I want to place on the script focus around minimal mouse movement; thus, I want to avoid virtual clicks as much as possible. Basically, I want to be able to keep track of the mouse, rather than having it change position every time I use a hotkey. Additionally, I need to account for changes to the number and position of items in the list boxes, which further constricts the use of clicks.

QUESTIONS
Basically, here's what I would like to happen:
1. TAB cycles forward through list box entries, and SHIFT+TAB cycles backward through list box entries.
2. Arrow keys adjust x/y advance spin buttons.
3. SHIFT+Arrow keys adjust x/y placement spin buttons.
4. ALT+Arrow keys adjust second set of x/y spin buttons.

And a few questions pertaining to specific windows (see DATA below for explanation)
5. In window 2, TAB activates ClassNN: TButton14, and SHIFT+TAB activates ClassNN: TButton15.
6. CTRL+TAB cycles through tabs in window 4.

DATA
1. Window title contains: (SingleAdjustment)
Listbox ClassNN: TListBox1
Toolbar above Listbox ClassNN: TSpTBXToolbar1 (contains add, delete buttons)
XAdvance Spin Button ClassNN: TSpTBXSpinButton1
YAdvance Spin Button ClassNN: TSpTBXSpinButton2
XPlacement Spin Button ClassNN: TSpTBXSpinButton3
YPlacement Spin Button ClassNN: TSpTBXSpinButton4
2. Window title contains: (CursiveAttachment) or (MarkToBase) or (MarkToLigature) or (MarkToMark)
First Listbox ClassNN: TListBox2
Toolbar above First Listbox ClassNN: TSpTBXToolbar2 (contains add, delete buttons)
Second Listbox ClassNN: TListBox1
Toolbar above Second Listbox ClassNN: TSpTBXToolbar1 (contains add, delete buttons)
Next Button ClassNN: TButton14
Next Button Text: Next>
Previous Button ClassNN: TButton15
Previous Button Text: <Previous
First Xpos Spin Button ClassNN: TSpTBXSpinButton4
First Ypos Spin Button ClassNN: TSpTBXSpinButton3
Second Xpos Spin Button ClassNN: TSpTBXSpinButton1
Second Ypos Spin Button ClassNN: TSpTBXSpinButton2
3. Window title contains: (PairAdjustment)
Listbox ClassNN: TListBox1
Toolbar above Listbox ClassNN: TSpTBXToolbar1 (contains add, delete buttons)
First XAdvance Spin Button ClassNN: TSpTBXSpinButton1
First YAdvance Spin Button ClassNN: TSpTBXSpinButton2
First XPlacement Spin Button ClassNN: TSpTBXSpinButton3
First YPlacement Spin Button ClassNN: TSpTBXSpinButton4
Second XAdvance Spin Button ClassNN: TSpTBXSpinButton8
Second YAdvance Spin Button ClassNN: TSpTBXSpinButton7
Second XPlacement Spin Button ClassNN: TSpTBXSpinButton6
Second YPlacement Spin Button ClassNN: TSpTBXSpinButton5
4. Window title contains: (ChainedContextPositioning) or (ChainingContext)
Tabs contained in ClassNN: TPageControl3 (contains 2 tabs with same ClassNN and no defining control text)
Tab 1:
First Listbox ClassNN: TListBox4
Toolbar above First Listbox ClassNN: TSpTBXToolbar1 (contains add, delete, move up, move down buttons)
Second Listbox ClassNN: TListBox3
Toolbar above Second Listbox ClassNN: TSpTBXToolbar4 (contains add, delete, move up, move down buttons)
Third Listbox ClassNN: TListBox2
Toolbar above Third Listbox ClassNN: TSpTBXToolbar3 (contains add, delete, move up, move down buttons)
Fourth Listbox ClassNN: TListBox1
Toolbar above Fourth Listbox ClassNN: TSpTBXToolbar2 (contains add, delete, move up, move down buttons)
Background fill of selected item in Fourth Listbox: 0078D7
Tab 2:
First Listbox ClassNN: TListBox1
Toolbar above First Listbox ClassNN: TSpTBXToolbar3 (contains add, delete buttons)
Second Listbox ClassNN: TListBox2
Toolbar above Second Listbox ClassNN: TSpTBXToolbar2 (contains add, delete buttons)
Third Listbox ClassNN: TListBox3
Toolbar above Third Listbox ClassNN: TSpTBXToolbar1 (contains add, delete buttons)
5. Window title contains: (SingleSubstitution) or (MultipleSubstitution) or (Alternate) or (Ligature)
Listbox ClassNN: TListBox1
Toolbar above Listbox ClassNN: TSpTBXToolbar1 (contains add, delete buttons)
6. Window title contains: (ReverseChainingContext)
First Listbox ClassNN: TListBox3
Toolbar above First Listbox ClassNN: TSpTBXToolbar3 (contains add, delete, move up, move down buttons)
Second Listbox ClassNN: TListBox2
Toolbar above Second Listbox ClassNN: TSpTBXToolbar2 (contains add, delete, move up, move down buttons)
Third Listbox ClassNN: TListBox1
Toolbar above Third Listbox ClassNN: TSpTBXToolbar1 (contains add, delete, move up, move down buttons)
7. Additional Global Data
A. "Add", "Delete", "Move up", and "Move down" buttons have ClassNN: TSpTBXToolbarx, where x is an integer.
In other words, WindowSpy does not detect any unique value for these buttons except for mouse position.
B. The "Add", "Delete", "Move up" and "Move down" buttons contain a gradient fill.
i. The "Add" button is generally colored green.
ii. The "Delete" button is generally colored red.
iii. The "Move up" and "Move down" arrows are generally colored blue.
C. Each set of up and down spin buttons has a unique ClassNN, but buttons within the set do not have unique ClassNN.
In other words, up1 and down1 have the same ClassNN, but up1 and up2 have different class names.
D. In List boxes, the selected item has background color D1E5FC; non-selected items have background color FFFFFF.
i. Note: see exception listed above (window 4, tab 1, listbox 4)
Thank you!
TD
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Tricky...trying to make hotkeys for a program without unique data

09 May 2017, 12:10

Code: Select all

q:: ;you can use the class/exe name to refer to a window
WinGetTitle, vWinTitle, ahk_class Notepad
MsgBox, % vWinTitle
WinGetTitle, vWinTitle, ahk_exe notepad.exe
MsgBox, % vWinTitle
WinGetTitle, vWinTitle, ahk_class Notepad ahk_exe notepad.exe
MsgBox, % vWinTitle
return

w:: ;techniques involving clicks don't have to move the cursor, or have a window active
ControlClick, Button2, A
return
[For more complicated window identification issues, you can use hWnds, PIDs or further information:]
Maximize only main window, not its scalable submenus. - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=19251

[EDIT:] [To check the window title, perhaps see: 'IF VAR CONTAINS(/STARTS/ENDS) LIST', here:]
RegEx handy examples (RegExMatch, RegExReplace) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=28031

I found a screenshot:
fontcreator-14.png
http://www.high-logic.com/uploads/image ... tor-14.png
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
tjdickinson
Posts: 19
Joined: 07 May 2017, 12:43
Contact:

Re: Tricky...trying to make hotkeys for a program without unique data

10 May 2017, 01:11

Thanks, jeeswg, for the response! You're a brave soul!

Yes, the screenshot you found is exactly the thing.

I will investigate the ControlClick action. I think that might be useful for some buttons. I don't know if it'll work for buttons that don't have unique IDs (like the "add/delete" buttons), but I'll see what I can make of it.

I admit that I don't fully understand your recommendation regarding WinGetTitle. I don't know if it makes a difference or not, but I notice now that these "windows" I've been talking about aren't really windows. Bad word choice on my part, sorry. They don't have their own unique window, they don't have a PID; from the Windows taskbar, it isn't possible to directly open any one of these "windows", but only the main window. For example, in the attached screenshot, you can see I have the OpenType Designer open, but the only open windows shown under fontcreator.exe are the main app and the help file...not the OT Designer.
Screenshot 2017-05-10 08.05.44.png
Screenshot 2017-05-10 08.05.44.png (88.83 KiB) Viewed 2371 times
Thanks again for your help!
Thank you!
TD
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Tricky...trying to make hotkeys for a program without unique data

10 May 2017, 03:19

My code would probably look something like this:

Code: Select all

#IfWinActive, ahk_class Notepad
;or if the class by itself is not unique:
;#IfWinActive, ahk_exe notepad.exe
;#IfWinActive, ahk_class Notepad ahk_exe notepad.exe
q::
WinGet, hWnd, ID, A
WinGetTitle, vWinTitle, % "ahk_id " hWnd
if RegExMatch(vWinTitle, ...)
	ControlClick, Button1, % "ahk_id " hWnd
else if InStr(vText, ...)
	ControlClick, Button2, % "ahk_id " hWnd
else
	ControlClick, Button3, % "ahk_id " hWnd
return
#IfWinActive
You may be able to check the text of a particular Static control e.g. 'Static3' to identify what type of window it is.

You may be able to do a loop to identify what type of window it is:

Code: Select all

Loop, 20
{
	vCount := A_Index-1
	ControlGet, hCtl, Hwnd,, % "Edit" A_Index, % "ahk_id " hWnd
	if !hCtl
		break
}
MsgBox, % vCount
return
[To invoke a toolbar button I might use functions from the Acc library:]
Acc library (MSAA) and AccViewer download links - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=26201

[However a simpler approach instead of Acc, may be that you can use PostMessage/SendMessage and WM_COMMAND to invoke certain menu items, see:]
Choose menu option then exit program - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 77#p147077

It may be that if you click a menu item or a toolbar button, that a WM_COMMAND message is sent to the window, which you can capture with a window spy. Some window spies are mentioned here:
best utilities + best AutoHotkey scripts (+ useful tips) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=28149
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
tjdickinson
Posts: 19
Joined: 07 May 2017, 12:43
Contact:

Re: Tricky...trying to make hotkeys for a program without unique data

11 May 2017, 05:58

Thanks for your response! It's a little Greek to me (ex. I don't know what "static control" means; I don't fully understand what you mean by "window type"), but I'll try to figure it out. It'll take some learning and finagling I suppose, so it might have to be temporarily delayed, as I'm now in paper‑writing mode (end of semester, y'know). Thanks again for your help!
Thank you!
TD
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Tricky...trying to make hotkeys for a program without unique data

11 May 2017, 06:12

A Static control is a control with text in it (or sometimes an image or an icon), e.g. 'Find what:' in the Notepad Find dialog. (If you create a GUI in AutoHotkey, these are created via 'Text' or 'Picture'.)

I said 'what type of window', not in a technical sense, you seemed to be describing the window containing different arrangements/numbers of controls based on different circumstances, I was referring to each of those arrangements as a 'type' of window.

==================================================

Btw I hadn't heard of a 'spin' or 'spinner' control before, I suppose I would call it an up-down control.

About Up-Down Controls (Windows)
https://msdn.microsoft.com/en-us/librar ... s.85).aspx
The following illustration shows an up-down control with an edit control as its buddy window, a combination that is sometimes referred to as a spinner control.
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
tjdickinson
Posts: 19
Joined: 07 May 2017, 12:43
Contact:

Re: Tricky...trying to make hotkeys for a program without unique data

11 May 2017, 06:19

Thanks for the clarification!

Yes, it would be an up-down control. I just went by what the Window Spy called it :)
Thank you!
TD
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Tricky...trying to make hotkeys for a program without unique data

11 May 2017, 07:21

Btw which window spy was that?
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
tjdickinson
Posts: 19
Joined: 07 May 2017, 12:43
Contact:

Re: Tricky...trying to make hotkeys for a program without unique data

12 May 2017, 13:23

jeeswg wrote:Btw which window spy was that?
ummm... :? the one that came with AHK? ... I have no idea haha sorry
Thank you!
TD
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Tricky...trying to make hotkeys for a program without unique data

12 May 2017, 13:33

Haha oh well, I tried AU3_Spy.exe (the old AHK spy) and ActiveWindowInfo.ahk (the new AHK spy), and neither mentioned 'spin' or 'spinner' anywhere on up/down controls, as far as I could see ... although maybe the controls in your program were not the standard Microsoft controls and had the word 'spin' in their class. Ah yes, it says they had the class 'TSpTBXSpinButton' above, and you referred to them as 'spin buttons', makes sense.
Last edited by jeeswg on 12 May 2017, 14:00, edited 1 time in total.
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
tjdickinson
Posts: 19
Joined: 07 May 2017, 12:43
Contact:

Re: Tricky...trying to make hotkeys for a program without unique data

12 May 2017, 13:57

jeeswg wrote:Haha oh well, I tried AU3_Spy.exe (the old AHK spy) and ActiveWindowInfo.ahk (the new AHK spy), and neither mentioned 'spin' or 'spinner' anywhere on up/down controls, as far as I could see ... although maybe the controls in your program were not the standard Microsoft controls and had the word 'spin' in their class. Ah yes, it says they had the class 'TSpTBXSpinButton' above, and you reroofed to them 'spin buttons', makes sense.
:D Indeed, as the attached picture shows (edit: very tiny, it seems...yipes), it calls it a spin button. But, y'know, you say tomato, I say red juicy acid bomb... ;)
Attachments
Screenshot 2017-05-12 20.55.40.png
Screenshot 2017-05-12 20.55.40.png (87 KiB) Viewed 2309 times
Thank you!
TD

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: mikeyww, Noitalommi_2, ulysim and 322 guests