No clue what I'm doing wrong

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
YuvalAmir
Posts: 5
Joined: 09 May 2021, 17:25

No clue what I'm doing wrong

09 May 2021, 17:31

I am trying to learn AutoHotKey and I really have no clue why this code isn't working:

Code: Select all

bool := false

!+::
{
    bool := not bool
    if (bool) 
    SetInputLang(0x0409) 
    else
    SetInputLang(0x040d) 
}

AppsKey::SetInputLang(0x0408)
AppsKey up::
{
    if (bool) 
    SetInputLang(0x0409) 
    else
    SetInputLang(0x040d) 
}

SetInputLang(Lang)
{
    WinExist("A")
    ControlGetFocus, CtrlInFocus
    PostMessage, 0x50, 0, % Lang, %CtrlInFocus%
}
User avatar
mikeyww
Posts: 26879
Joined: 09 Sep 2014, 18:38

Re: No clue what I'm doing wrong

09 May 2021, 17:45

You can inspect examples here on the forum, and read the intro as well. Multi-line hotkey routines generally end in Return. Try a short and simple hotkey routine first, to get the hang of it. Once working, you can expand.

I don't have a way to test, but have you displayed the value of CtrlInFocus, to see if it is what you think it is?

There are also forum examples of working with the lang bar, in case helpful.
Last edited by mikeyww on 10 May 2021, 05:41, edited 1 time in total.
YuvalAmir
Posts: 5
Joined: 09 May 2021, 17:25

Re: No clue what I'm doing wrong

10 May 2021, 04:56

I've tried that and it's still not working...

Code: Select all

bool := true

!+::
bool := not bool
if (bool) 
    SetInputLang(0x0409) 
else
    SetInputLang(0x040d) 
return

AppsKey::SetInputLang(0x0408)
AppsKey up::
if (bool) 
    SetInputLang(0x0409) 
else
    SetInputLang(0x040d) 
return

SetInputLang(Lang)
{
    WinExist("A")
    ControlGetFocus, CtrlInFocus
    PostMessage, 0x50, 0, % Lang, %CtrlInFocus%
}
edit: the SetInputLang method is working as intended, I pretty much copy pasted it and I tested it separately.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Anput, Google [Bot], Nerafius and 83 guests