hello i want my script detect the current keyboard layout and if it is English then suspend script.So whenever i change to English i want my script to be suspended(stop work)
i want a constant check for this.if current keyboard layout isn't English then do not suspend.
if current keyboard layout is english then
Re: if current keyboard layout is english then
Try this.
Edit: Corrected an error.
Code: Select all
#Persistent
English := 0x4090409
SetTimer, CheckLang, 200
CheckLang:
if(English = Format("0x{:x}", DllCall("GetKeyboardLayout", "Int", DllCall("GetWindowThreadProcessId", "Int", WinActive("A"), "Int", 0)))){
Suspend, On
} else {
Suspend, Off
}
return
Please excuse my spelling I am dyslexic.
Re: if current keyboard layout is english then
it worked but suspend it doesn't really work and I don't know why.it goes to suspend mode fine but hotkeys etc are still working.suspend works only if I click on tray icon..same happens with suspend off again it doesn't start my script its still like in suspended mode.May I could achieve it with postmessage.I also tried with pause same thing happens.
But the code works great.not the way I wanted to but it does what I asked.Thanks
But the code works great.not the way I wanted to but it does what I asked.Thanks
Re: if current keyboard layout is english then
Could you explain how you wanted it to work ? for instance in what way does Suspend not do what you wanted ?Eguy wrote:it worked but suspend it doesn't really work and I don't know why.it goes to suspend mode fine but hotkeys etc are still working.suspend works only if I click on tray icon..same happens with suspend off again it doesn't start my script its still like in suspended mode.May I could achieve it with postmessage.I also tried with pause same thing happens.
But the code works great.not the way I wanted to but it does what I asked.Thanks
Please excuse my spelling I am dyslexic.
Re: if current keyboard layout is english then
well I want to make my script stop working including my hotstrings and hotkeys etc and some if statements when the keyboard layout is English.And if I cgange keyboard layout to another language continue script.Thats it.I thought the script you gave me was ok but for some reason it doesn't update the state of the script only if I click on the tray icon.I meant it goes to suspended mode which means that my current keyboard layout is English but script continue working even in suspend mode..
Re: if current keyboard layout is english then
Have you tried combining Suspend and Pause ?Eguy wrote:well I want to make my script stop working including my hotstrings and hotkeys etc and some if statements when the keyboard layout is English.And if I cgange keyboard layout to another language continue script.Thats it.I thought the script you gave me was ok but for some reason it doesn't update the state of the script only if I click on the tray icon.I meant it goes to suspended mode which means that my current keyboard layout is English but script continue working even in suspend mode..
Code: Select all
#Persistent
English := 0x4090409
SetTimer, CheckLang, 200
CheckLang:
if(English = Format("0x{:x}", DllCall("GetKeyboardLayout", "Int", DllCall("GetWindowThreadProcessId", "Int", WinActive("A"), "Int", 0)))){
Suspend, On
Pause, On
} else {
Suspend, Off
Pause, Off
}
return
Please excuse my spelling I am dyslexic.
Re: if current keyboard layout is english then
Found a solution, run this script separately, it will suspend and pause another script depending on the file name in the string Script.ahk - AutoHotkey.If you keep your hotkeys in Script.ahk it should work.
Code: Select all
#Persistent
DetectHiddenWindows, on
SetTitleMatchMode, 2
bool := 1
English := 0x4090409
SetTimer, CheckLang, 200
CheckLang:
Suspend, Permit
if(English = Format("0x{:x}", DllCall("GetKeyboardLayout", "Int", DllCall("GetWindowThreadProcessId", "Int", WinActive("A"), "Int", 0)))){
if(bool){
PostMessage, 0x111, 65305, , , Script.ahk - AutoHotkey
PostMessage, 0x111, 65306, , , Script.ahk - AutoHotkey
bool := False
}
} else {
if(!bool){
PostMessage, 0x111, 65305, , , Script.ahk - AutoHotkey
PostMessage, 0x111, 65306, , , Script.ahk - AutoHotkey
bool := True
}
}
return
Please excuse my spelling I am dyslexic.
Re: if current keyboard layout is english then
I will try it.Though I like to have 1 script.I ask for this script because English cause problems to my code.thats why I want to turn off my script if current keyboard layout is English.So I think only 1 method could solve the problem the one you gave me with different script and maybe (I think)if I could use reload command.for example if I change to English reload script.if I change again and go to another keyboard layout reload again.So when ever I change layout keyboard reload script.i tried that but I got loop for ever which means script was reloading for ever and it crashed my windows...Can this be done ?