I love the ability to change to a different keyboard with a hot key.
Is there a way to designate a particular font when doing this?
The default for the Devanagari Unicode [US] is Mangal, but Nirmal UI is a better font IMHO.
The way fonts are chosen depends on the application you are using – it isn’t part of the keyboarding system, but part of the display or document system.
If you are using Word, you can create a macro to swap both font and keyboard at the same time. For other applications, it can vary. Which application(s) are you using?
I am using an older version of Word (2003). I set up Macros to change both the font and the keyboard. Oddly, the MS Word Macro does not change the keyboard properly, but only the font.
I am having to apply two steps. I have not found a way to handle in one:
Set the font (using MS Word macro)
Set the keyboard (using Keyman hotkey)
Thank you again for your help! It is a wonderful product. I did not see a way to contribute. I would like to do that.
Which version of the macros are you using? The ones that reference “Keymanapi” or the ones that use a numeric identifier for the language?
Glad we can serve! There is a donation link on www.sil.org or you can visit the following direct link: https://www.givedirect.org/donate/?cid=13536. Select “Language Software” from the Program Menu in the form and add “Keyman” into the comment field.
I am just using the macros within MS Word. I am using an older version - 2003. So I am creating a new macro by selecting Tools / Macro / Record new macro. It sets the font correctly, but does not set the keyboard, even though as part of the macro, I selected the keyboard from the taskbar.
I see. The issue you are having is that the Word macro recorder only captures events from within the Word application – and switching languages is an event that takes place outside the context of the Word application. You can follow the instructions in the link I provided (https://help.keyman.com/kb/93) to edit the macro and add the language switching command into that.
Since I am using a 32-bit application (Word 2003), would I use this approach?
Do I include both macros or do you choose one of the methods below?
1. Keyman COM API access in Visual Basic for Applications
2. You can create a macro that toggles the Keyman keyboard and font as follows
It is a bit confusing as there are references to keyboard and font in both, but different types of keyboards / fonts in each
Thank you again,
David
Yes, you can use the approach in KMKB0093 for a 32-bit version of Word, and I would recommend this approach because it will continue to work if you do update to a new version of Word in the future.
I’m not sure what you mean by “both paragraphs”? Just follow steps 1-3 in KB article 93; they should work fine on 32 bit Word as well as 64 bit Word.
Okay, that content is not from the link I gave you, though. The link I gave you was https://help.keyman.com/kb/93. The code in question on that page is:
'
' Keyboard switching in Visual Basic for Applications x64
' -------------------------------------------------------
'
Private Declare PtrSafe Function ActivateKeyboardLayout Lib "user32" (ByVal HKL As LongPtr, _
ByVal flags As Long) As Long
Private Declare PtrSafe Function GetKeyboardLayoutList Lib "user32" (ByVal size As Long, _
ByRef layouts As LongPtr) As Long
Sub SwitchKhmerOn()
Selection.Font.Name = "Khmer OS Content"
ActivateKeyboardLayout &H4530453, 0
End Sub
Sub SwitchKeymanOff()
Selection.Font.Name = "Arial"
ActivateKeyboardLayout &H4090C09, 0
End Sub
Sub ShowLoadedLayouts()
Dim numLayouts As Long
Dim i As Long
Dim layouts() As LongPtr
numLayouts = GetKeyboardLayoutList(0, ByVal 0&)
ReDim layouts(numLayouts - 1)
GetKeyboardLayoutList numLayouts, layouts(0)
Dim msg As String
msg = "Loaded keyboard layouts: " & vbCrLf & vbCrLf
For i = 0 To numLayouts - 1
msg = msg & Hex(layouts(i)) & vbCrLf
Next
MsgBox msg
End Sub
In this code, you’d need to change the references to fonts and keyboard layout identifiers in the SwitchKhmerOn and SwitchKeymanOff functions. To find out the keyboard layout identifier to use (known as a HKL in Windows), run the ShowLoadedLayouts function – this will give you a list of all the loaded keyboard layouts and their identifiers. (To run the ShowLoadedLayouts function, click inside the function, then press F5).