* AutoHotKey Script

Questions regarding use of any Version of Family Historian. Please ensure you have set your Version of Family Historian in your Profile. If your question fits in one of these subject-specific sub-forums, please ask it there.
avatar
ColinMc
Superstar
Posts: 442
Joined: 17 Jan 2019 11:35
Family Historian: V7
Location: Edinburgh

AutoHotKey Script

Post by ColinMc » 08 Mar 2021 11:24

As a result of the menu changes in V7, the script available at https://fhug.org.uk/kb/link/autohotkey-3/ needs amending. There are 7 lines of code similar to this

#I::Send !VRI^D ; Win+I opens Records Window Individuals tab Last Name filter

A simple edit to change the "R" to "O" in each of those 7 lines will let it run again.

eg #I::Send !VOI^D ; Win+I opens Records Window Individuals tab Last Name filter.

I'm afraid I do not know enough about the final T option to comment, but it probably needs looking at too. When I tried it, it signed me out of my user and disabled my external keyboard - but that may be because it is a (supposedly) intelligent Logitech one, and WIN+T triggered something there.
Last edited by ColinMc on 08 Mar 2021 11:41, edited 1 time in total.
Colin McDonald - Researching McDonald, McGillivray, Tait, Rountree families

User avatar
ColeValleyGirl
Megastar
Posts: 4853
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: AutoHotKey Script

Post by ColeValleyGirl » 08 Mar 2021 11:36

If sombody who knows what they're doing submits a script that works with V7, that would be great -- the current content does say it works with v6; I've added a note that it doesn't work with V7.

avatar
Gowermick
Megastar
Posts: 1629
Joined: 13 Oct 2015 07:22
Family Historian: V7
Location: Swansea

Re: AutoHotKey Script

Post by Gowermick » 08 Mar 2021 11:59

I do run autohotkey happily in V7, but simply as a way of entering text via a shortcut. For example Ctl-1 enters date of 1911 census when adding a fact, likewise withCtl-3 (1939), Ctl-4 (1841) etc

Where is the script file you are referring to, and what is it meant to do? I’m happy to have a look, it shouldn’t be too hard to fix.
Mike Loney

Website http://www.loney.tribalpages.com
http://www.mickloney.tribalpages.com

avatar
Gowermick
Megastar
Posts: 1629
Joined: 13 Oct 2015 07:22
Family Historian: V7
Location: Swansea

Re: AutoHotKey Script

Post by Gowermick » 08 Mar 2021 12:05

ColeValleyGirl wrote:
08 Mar 2021 11:36
If sombody who knows what they're doing submits a script that works with V7, that would be great -- the current content does say it works with v6; I've added a note that it doesn't work with V7.
Its supposed to say that, but what is says is it won’t work with v& :D :D
Mike Loney

Website http://www.loney.tribalpages.com
http://www.mickloney.tribalpages.com

User avatar
ColeValleyGirl
Megastar
Posts: 4853
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: AutoHotKey Script

Post by ColeValleyGirl » 08 Mar 2021 12:07

Gowermick wrote:
08 Mar 2021 12:05
Its supposed to say that, but what is says is it won’t work with v& :D :D
Thanks -- fixed.

User avatar
tatewise
Megastar
Posts: 27082
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: AutoHotKey Script

Post by tatewise » 08 Mar 2021 12:14

It is my AutoHotkey script, or so it says in the header.
I've modified it for FH V7 but would like feedback about the shortcut keys used because of conflicting initials S & R & T.
The Windows Key plus the following letters open the Records Window tab with the Filter selected:
I = Individuals
F = Families
N = Notes
S = Sources
R = Repositories
M = Media
P = Places
T = Source Templates ~ this is new
E = Research Notes ~ this is new

C = transpose case of selected text ~ this was T

BTW: Would this thread be better in the Web Site Usage forum?
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
ColinMc
Superstar
Posts: 442
Joined: 17 Jan 2019 11:35
Family Historian: V7
Location: Edinburgh

Re: AutoHotKey Script

Post by ColinMc » 08 Mar 2021 12:38

Thanks for updating. I did wonder which forum, but decided it wasn't the web site exactly either, so this was the least worst option!

For me, the new letters are fine.

Colin


PS I had replaced the F option (which I don't use frequently) with

#F::Send !TF ; Win+F opens Facts Edit dialog

to open the Facts dialog which I do prefer
Colin McDonald - Researching McDonald, McGillivray, Tait, Rountree families

User avatar
tatewise
Megastar
Posts: 27082
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: AutoHotKey Script

Post by tatewise » 08 Mar 2021 12:48

Could add that as Win+D for fact type Definitions?
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
ColinMc
Superstar
Posts: 442
Joined: 17 Jan 2019 11:35
Family Historian: V7
Location: Edinburgh

Re: AutoHotKey Script

Post by ColinMc » 08 Mar 2021 13:02

A much better Idea. Thanks
Colin McDonald - Researching McDonald, McGillivray, Tait, Rountree families

avatar
Gowermick
Megastar
Posts: 1629
Joined: 13 Oct 2015 07:22
Family Historian: V7
Location: Swansea

Re: AutoHotKey Script

Post by Gowermick » 08 Mar 2021 14:05

Mike,
Where is the latest version of your script?
The version in Knowledgebase is the old one, which you wrote in 2016

NB I am assuming you've updated already, judging by Colin's comment thanking you.
No worries if it is still inhand
Last edited by Gowermick on 08 Mar 2021 14:08, edited 1 time in total.
Mike Loney

Website http://www.loney.tribalpages.com
http://www.mickloney.tribalpages.com

User avatar
ColeValleyGirl
Megastar
Posts: 4853
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: AutoHotKey Script

Post by ColeValleyGirl » 08 Mar 2021 14:07

Mike L, give Mike T time! He's still gathering feedback and hasn't submitted the new script yet.

avatar
Gowermick
Megastar
Posts: 1629
Joined: 13 Oct 2015 07:22
Family Historian: V7
Location: Swansea

Re: AutoHotKey Script

Post by Gowermick » 08 Mar 2021 14:08

ColeValleyGirl wrote:
08 Mar 2021 14:07
Mike L, give Mike T time! He's still gathering feedback and hasn't submitted the new script yet.
Our posts crossed, my post explains it all :D
Mike Loney

Website http://www.loney.tribalpages.com
http://www.mickloney.tribalpages.com

User avatar
tatewise
Megastar
Posts: 27082
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: AutoHotKey Script

Post by tatewise » 08 Mar 2021 14:23

@ColonMc: The benefit of Win+D to open the Tools > Facts Types dialogue is rather less than the other shortcuts.
Maybe you do not realize that Alt T F will open that dialogue with only one click more than Win+D
So is the Win+D shortcut really necessary?

The other shortcuts are more useful because they effectively use Alt T O F Ctrl+D i.e. 6 clicks.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
ColinMc
Superstar
Posts: 442
Joined: 17 Jan 2019 11:35
Family Historian: V7
Location: Edinburgh

Re: AutoHotKey Script

Post by ColinMc » 08 Mar 2021 15:46

I did realise that Alt T F would open that dialogue with only one click more than Win+D, after all that is what I added the code for in my version of the script

#F::Send !TF ; Win+F opens Facts Edit dialog.

However while Win+D is just one less click, it is a far easier combination of keys than the more awkward keystroke combination Alt T F. For me, I find that it is best accomplished using two hands or by a slightly less natural position if using one hand.

Win+D on the other hand, is a very simple command even for people with small hands (not me), and definitely only needs one hand.

So for me Win+D still has plenty of advantages.
Colin McDonald - Researching McDonald, McGillivray, Tait, Rountree families

User avatar
tatewise
Megastar
Posts: 27082
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: AutoHotKey Script

Post by tatewise » 08 Mar 2021 16:03

Conversely, I have to use two hands/fingers to hold down the Win key while pressing a letter.
Whereas Alt T F is performed with one hand/finger pressing each key in succession as Alt does not need to be held down.

Nevertheless, I can include Win+D

Are there any other shortcuts worth adding?
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
ColinMc
Superstar
Posts: 442
Joined: 17 Jan 2019 11:35
Family Historian: V7
Location: Edinburgh

Re: AutoHotKey Script

Post by ColinMc » 08 Mar 2021 16:42

The only other ones I use are

#Q::Send !VQ ; Win+Q opens Query Window
#A::Send !VPP{enter} ; Win+A opens Publish Window

#Z::Send !TL ; Win+Z opens External File Link
#W::Send !TU ; Win+W opens Plug ins

These are not necessarily the best letters (for all), I did not spend too long thinking about them. But positionally they suit me - others might not find them useful though as it all depends on how you use the keyboard. Mike & I apparently place our hands differently, making the choice of hot-key a personal issue.

Publish needs two P's as CP have created three highlights for this letter - it seems to work though
Unfortunately it doesn't look as if Charts has a shortcut. I haven't experimented to see if there is an obscure one.

Hopefully others have suggestions
Colin McDonald - Researching McDonald, McGillivray, Tait, Rountree families

User avatar
tatewise
Megastar
Posts: 27082
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: AutoHotKey Script

Post by tatewise » 08 Mar 2021 18:40

I like your
#Q::Send !VQ ; Win+Q opens Query Window
and
#L::Send !TL ; Win+Z opens External File Link ~ but prefer L or X to Z
But I've discovered that Win+L invokes the Windows Lock screen so it will have to be Win+X

I tried your
#A::Send !VPP{enter} ; Win+A opens Publish Window
but it only opens the View > Publish menu headed by Publishing Tools Finder... (which is exactly the same as clicking the Publish button in the toolbar) and you then either have to use the mouse or a lot of down key presses to choose a Report, etc. So I don't see it as a significant benefit.

What might be worth adding is:
#C::Send !VC ; Win+C opens Citations to Source Record

and then toggle case would move to Win+U for Upturn
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
HeatherW
Silver
Posts: 7
Joined: 08 Mar 2021 22:39
Family Historian: V7

Re: AutoHotKey Script

Post by HeatherW » 08 Mar 2021 22:52

Mike,
Would you kindly add a shortcut key for: Toolbar>View> Record Links

Thank you!
HeatherW; v7

User avatar
tatewise
Megastar
Posts: 27082
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: AutoHotKey Script

Post by tatewise » 08 Mar 2021 23:29

Yes, that could Win+W for 'Where used'
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
ColinMc
Superstar
Posts: 442
Joined: 17 Jan 2019 11:35
Family Historian: V7
Location: Edinburgh

Re: AutoHotKey Script

Post by ColinMc » 09 Mar 2021 09:41

Thinking of other frequently used commands,

Edit + Find

might be another to consider.

Again not a long alternative, but ....
Colin McDonald - Researching McDonald, McGillivray, Tait, Rountree families

User avatar
tatewise
Megastar
Posts: 27082
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: AutoHotKey Script

Post by tatewise » 09 Mar 2021 14:38

I think I'm running out of meaningful Win key letters!
My proposed FH V7 AutoHotkey script is posted below.
The AutoHotkey program automatically invokes an AutoHotkey.ahk file located in the default Documents folder.
So in the FHUG KB AutoHotkey page both the old FH V6 and new FH V7 download files need to be named AutoHotkey.ahk but I'm not sure if that is possible. Advice please.

I did try and get the script to test whether FH V7 was in use or not and automatically choose the appropriate shortcuts.
However, it did not seem possible to detect that without briefly opening the Help > About Family Historian window.
If that could succeed then only one download AutoHotkey.ahk file would be needed.

These are the FH V7 hotkey shortcuts:
Win+I opens Records Window Individuals tab Last Name filter
Win+F opens Records Window Families tab Last Name filter
Win+N opens Records Window Notes tab Note Starting filter
Win+S opens Records Window Sources tab Title/Short Title filter
Win+R opens Records Window Repositories tab Name filter
Win+M opens Records Window Media tab Title filter
Win+P opens Records Window Places tab Place Name filter
Win+T opens Records Window Source Templates tab Name filter
Win+E opens Records Window Research Notes tab Title filter
Win+Q opens View > Query Window
Win+A opens View > Publish Menu
Win+W opens View > Record Links ~ Where used
Win+C opens View > Citations to Source Record
Win+D opens Tools > Fact Types ~ Definitions dialog
Win+X opens Tools > E'X'ternal File Links
Win+U transposes/upturns case of highlighted text

Code: Select all

; Title:	AutoHotkey Shortcuts Script
; Author:	Mike Tate
; Version:	1.5
; LastUpdated:	09 Mar 2021
; Licence:	This script is copyright (c) 2021 Mike Tate and is licensed under the MIT License
; Description:	Windows key shortcuts to open Records Window tab filters, other dialogues, and transpose case of selected text.
; Path:		...\Documents\AutoHotkey.ahk 
; V1.5:		Changed to support FH V7 records and extra shortcuts
; V1.4:		Changed SetTitleMatchMode to use RegEx
; V1.3:		Add ClipWait and add {Raw} to SendInput {Raw}%Invert_Char_Out% to ignore special chars
; V1.2:		Windows key shortcut to Transpose case of selected text
; V1.1:		SetTitleMatchMode, 2 correction added
; V1.0:		Windows key shortcuts to open Records Window tab filters

; IMPORTANT INFO ABOUT GETTING STARTED: Lines that start with a
; semicolon, such as this one, are comments.  They are not executed.

; This script has a special filename and path because it is automatically
; launched when you run the program directly.  Also, any text file whose
; name ends in .ahk is associated with the program, which means that it
; can be launched simply by double-clicking it.  You can have as many .ahk
; files as you want, located in any folder.  You can also run more than
; one ahk file simultaneously and each will get its own tray icon.

; Note: From now on whenever you run AutoHotkey directly, this script
; will be loaded.  So feel free to customize it to suit your needs.

; Please read the QUICK-START TUTORIAL near the top of the help file.
; It explains how to perform common automation tasks such as sending
; keystrokes and mouse clicks.  It also explains more about hotkeys.

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

SetTitleMatchMode, RegEx	; #WinActive window title matches according to regular expression

; Windows key shortcuts for Family Historian
#IfWinActive, - Family Historian [GP][rojectdom]+ - 
#I::Send !VOI^D	; Win+I opens Records Window Individuals tab Last Name filter
#F::Send !VOF^D	; Win+F opens Records Window Families tab Last Name filter
#N::Send !VON^D	; Win+N opens Records Window Notes tab Note Starting filter
#S::Send !VOS^D	; Win+S opens Records Window Sources tab Title/Short Title filter
#R::Send !VOR^D	; Win+R opens Records Window Repositories tab Name filter
#M::Send !VOM^D	; Win+M opens Records Window Media tab Title filter
#P::Send !VOP^D	; Win+P opens Records Window Places tab Place Name filter
#T::Send !VOT^D	; Win+T opens Records Window Source Templates tab Name filter
#E::Send !VR^D	; Win+E opens Records Window Research Notes tab Title filter
#Q::Send !VQ{enter} ; Win+Q opens View > Query Window
#A::Send !VPP{enter} ; Win+A opens View > Publish Menu
#W::Send !VL	; Win+W opens View > Record Links ~ Where used
#C::Send !VC	; Win+C opens View > Citations to Source Record
#D::Send !TF	; Win+D opens Tools > Fact Types ~ Definitions dialog
#X::Send !TL	; Win+X opens Tools > E'X'ternal File Links (Win+L opens Windows Lock screen)
#IfWinActive

#U::					; Win+U transposes case of highlighted text
 Clip_Save := ClipboardAll		; Save original contents of clipboard
 Clipboard := ""			; Empty clipboard
 SendInput ^C				; Copy highlighted text to clipboard and delete
 ClipWait, 1				; Wait up to 1 sec for text to reach clipboard
 if ErrorLevel
  return
 Invert_Char_Out := ""			; Clear variable that will hold output string
 Loop, % Strlen(Clipboard) {			; Loop for each character in the clipboard
    Invert_Char := Substr(Clipboard, A_Index, 1)	; Isolate the character
    if Invert_Char is upper			; If upper case convert to lower case
       StringLower, Invert_Char, Invert_Char 
    else if Invert_Char is lower			; If lower case convert to upper case
       StringUpper, Invert_Char, Invert_Char 
    else if Invert_Char in `r			; If return then skip it
       Invert_Char := ""
    Invert_Char_Out:= Invert_Char_Out Invert_Char	; Copy character to output text
}
 SendInput {Raw}%Invert_Char_Out%	; Send desired raw text
 Clipboard := Clip_Save			; Restore original clipboard
 Clip_Save := ""
return
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
ColeValleyGirl
Megastar
Posts: 4853
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: AutoHotKey Script

Post by ColeValleyGirl » 09 Mar 2021 14:56

I'll sort the KB page somehow -- fret not. Just submit it.

User avatar
Jane
Site Admin
Posts: 8441
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

Re: AutoHotKey Script

Post by Jane » 09 Mar 2021 15:05

BTW Did you know Microsoft now offers a free alternative to AutoHotKey for Windows 10 users.

https://flow.microsoft.com/en-us/desktop/

Also I should point out quite a few of your proposed keys are already used by Windows, so you might want more complex key patterns to avoid conflicts. I realise you are only doing them when FH is active, but which will take priority is a bit of a toss up.


https://support.microsoft.com/en-us/win ... 9706c75eec
for a list of used ones.
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."

User avatar
tatewise
Megastar
Posts: 27082
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: AutoHotKey Script

Post by tatewise » 09 Mar 2021 16:00

The potential conflict with the Microsoft Windows logo key shortcuts has existed from at least Windows 7.
The ones local to FH don't seem to be a problem except for Win+L that opens the Windows Lock window and takes precedence over an AutoHotkey Win+L shortcut.
The transpose text case is more of a problem as almost all the Windows logo + letter combinations have been used.
So I need to think about that one.

Power Automate Desktop is very different from AutoHotkey. It seems to be designed to capture key/mouse sequences aginst a shortcut but is not programmable like AutoHotkey.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
Gowermick
Megastar
Posts: 1629
Joined: 13 Oct 2015 07:22
Family Historian: V7
Location: Swansea

Re: AutoHotKey Script

Post by Gowermick » 09 Mar 2021 16:27

MikeTate,
Are you aware you can actually compile the ahk file?
I have an ahk file called FH6 Script.ahk on my desktop,which I compiled (right-click and choose Compile) to create FH6 Script.exe, which I loaded into the Startup directory. The compiled version stored the name and path of the script file it compiled, so looks for the FH6 Script.ahk on the desktop and runs it.
This means one can store the ahk file anywhere, because after compilation, the exe file knows where the ahk resides.

It also means that should I need to amend the ahk file, I can do so from the desktop and once saved, will be ready for next start up. If I want changes to have immediate affect, I just double click the ahk file to run it, and after acknowledging the warning that ensues, the changes come into immediate affect.
Mike Loney

Website http://www.loney.tribalpages.com
http://www.mickloney.tribalpages.com

Post Reply