Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Function to select input-keyboard language
#1
I have written and use the following function to select an input-keyboard language :

Function Keyboard_Shift
Code:
Copy      Help
;/
function int'sw [int'w] ;; 0 :shift to English,  >=1 : Shift to Greek

int k l hwnd
,
hwnd=iif(w=0 win() w)

l=GetKeyboardLayout(GetWindowThreadProcessId(hwnd 0))
;out l
int lo=l&0xffff
k=iif(lo=1032 1 0)
;outt F"{sw} - {k} - {l} - {_s.getwintext(hwnd)}"
if sw <> k
,str exename.getwinexe(hwnd)
,if StrCompare(exename "EXCEL")=0
,,key CS          ;; Ctrl+Shift
,else
,,SendKeysToWindow hwnd key((VK_LBUTTON) (VK_CONTROL) (VK_SHIFT))

I find it very useful because this function is called using two keyboard triggers, namely F11 to shift to greek and Shift+F11 to shift to Latin. This function works perfectly. However, I cannot understand the following issue, since I came to this solution almost empirically :

When I wrote the function, in the first place, I used to change keyboard language, in all applications :

Quote: SendKeysToWindow hwnd key((VK_LBUTTON) (VK_CONTROL) (VK_SHIFT))

Nevertheless, I experienced that Shift+F11 did not work in Excel files. I found empirically that
Quote: key CS ;; Ctrl+Shift

works in Excel and only in Excel.

I am just seeking an explanation about it and/or any better solution.

I hope that Gintaras will certainly advise as always. In anyway I am most obliged to him, for excellent, perfect, reliable and prompt advises.
#2
I use this macro:

Function switch_language
Trigger I     Help - how to add the trigger to the macro
Code:
Copy      Help
key SA

It remaps Insert -> Shift+Alt, which never leaves Alt toggled which often happens when I press Alt+Shift manually. On my computer Shift+Alt is default, not changed to Shift+Ctrl.

I don't know why SendKeysToWindow works, it seems it shouldn't because it is a system hotkey.
#3
Dear Gintaras, thank you for your advice. As I wrote, it was empirically that I found that SendKeysToWindow works. I would prefer to use instead :
Quote:key CS
but when in Notepad this command switches to "Right-to-Left Reading Order". Actually, when keying manually it is Control+Right Shift that is switching to Right-to-Left. I wonder whether there exists any tweak in XP to disable this shortcut in Notepad. I have searched, but in vain.

Best Regards.


Forum Jump:


Users browsing this thread: 1 Guest(s)