Please help to force keyboard layout to Dvorak in Webstorm

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
tvishy
Posts: 2
Joined: 29 Nov 2022, 09:06

Please help to force keyboard layout to Dvorak in Webstorm

Post by tvishy » 29 Nov 2022, 09:11

Whenever I open a Webstorm IDE window I want to have always always Dvorak keyboard layout.
I created script. But I didn't help me.

Code: Select all

#Persistent
SetTimer, СhangeToEnglishLayout, 250

СhangeToEnglishLayout:
If WinActive("ahk_exe webstorm64.exe")		
{
        PostMessage, 0x0050, 0, 0xF0020409,, A  ; 0x0050 is WM_INPUTLANGCHANGEREQUES
}
return

[Mod edit: Added [code][/code] tags. Please use them yourself when posting code.]

User avatar
mikeyww
Posts: 26437
Joined: 09 Sep 2014, 18:38

Re: Please help to force keyboard layout to Dvorak in Webstorm

Post by mikeyww » 29 Nov 2022, 22:12

Welcome to this AutoHotkey forum!

Code: Select all

#SingleInstance Force
wTitle = ahk_exe notepad.exe
us     =   67699721
dvorak = -268303351
switch = {Ctrl down}{Shift}{Ctrl up}
Loop {
 WinWaitActive, %wTitle%
 Send % layout() = dvorak ? "" : switch       ; US => Dvorak
 Gosub, Tip
 SoundBeep, 1500
 WinWaitNotActive
 Send % layout() = dvorak ? switch : ""       ; Dvorak => US
 Gosub, Tip
 SoundBeep, 1000
}

Tip:
ToolTip, % layout() = dvorak ? "Dvorak" : "", 300, 10
Return

layout() {
 Return DllCall("GetKeyboardLayout", "UInt"
      , DllCall("GetWindowThreadProcessId", "UInt", WinExist("A"), "UInt", 0))
}
There is probably some DLL call that can do this more efficiently!

tvishy
Posts: 2
Joined: 29 Nov 2022, 09:06

Re: Please help to force keyboard layout to Dvorak in Webstorm

Post by tvishy » 30 Nov 2022, 06:52

Thx mikeyww, for the help
First I assigned the shortcut "shift+ctrl+!" in keyboard settings for the Dvorak layout.
Then I modified your script a little , and got always only Dvorak in the Webstorm!

Code: Select all

#SingleInstance Force
wTitle = ahk_exe webstorm64.exe
dvorak = -268303351
switch = {Ctrl down}{!}{Ctrl up}
Loop {
 IfWinActive, %wTitle%
 {
  Send % layout() = dvorak ? "" : switch       ; whatever layout => Dvorak
 }
}

layout() {
 Return DllCall("GetKeyboardLayout", "UInt"
      , DllCall("GetWindowThreadProcessId", "UInt", WinExist("A"), "UInt", 0))
}
[Mod edit: Added [code][/code] tags. Please use them yourself when posting code.]

Post Reply

Return to “Ask for Help (v1)”