AutoHotkey Community

It is currently May 27th, 2012, 4:27 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 13 posts ] 
Author Message
PostPosted: October 1st, 2004, 12:08 am 
Offline

Joined: August 26th, 2004, 3:11 pm
Posts: 80
Location: Chelsea - MA, USA
Quote:
Quote from Planned Features:
A built-in variable called A_Layout or A_Language that indicates the script's current keyboard layout and/or language Does anyone know a way to find out the current language/layout of specific window/application?


Maybe you could add new variables called "A_OSLangID" and "A_UserLangID".

_________________
Working now on:
NumpadMouse v2 (Draw)
top-recode project (private server script) (pkodev)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 1st, 2004, 2:21 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
I don't know how useful these variables would be. Bobo pointed out that the language ID (both user and system) is probably in the registry somewhere; if so, built-in variables probably aren't needed.

What would be much better is the ability to find out the current keyboard layout of an individual window (each window can have its own). That way, the script could automatically adjust to match the active window, which would allow hotstrings, hotkeys, and even the Send command to work more consistently.

As it stands now, multi-layout users have to activate the script's main window and then switch languages there to get it to match the switch they did in some other window. I guess they could save a few clicks by creating a hotkey to do both switches.

For reference, here is one of the topics that originally brought this up: http://www.autohotkey.com/forum/viewtop ... =4594#4594

UPDATE: Hopefully the keyboard layout issue is no longer present in newer versions. If anyone has any trouble with it, please let me know.


Last edited by Chris on September 2nd, 2006, 5:07 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 2nd, 2004, 10:00 pm 
Maybe that helps to provide another usefull feature/variable in a future AHK :arrow: GetLocaleInfo API

Quote:
Microsoft country codes are defined as constants in winnls.h and are identical to the values returned from their GetLocaleInfo API with the LOCALE_ICOUNTRY parameter (sometimes referred to as the IBM country code). For more information about the LCID (Locale ID) parameter that is passed to the GetLocaleInfo API and which uniquely defines a country and language, see the Microsoft Platform SDK docs


8)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 2nd, 2004, 10:18 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Thanks, I'll look into it.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 15th, 2004, 10:12 am 
Offline

Joined: September 24th, 2004, 3:00 pm
Posts: 814
Location: Germany
Hi Chris,

I also would like to check the language to create multi-language scripts.

Tekl


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 15th, 2004, 11:57 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
That's a good use; thanks for mentioning it.

Until it's added, you might be able to use one of the values stored in HKEY_CURRENT_USER\Control Panel\International

This might only work for Windows NT/2k/XP.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 18th, 2004, 10:13 am 
Offline

Joined: September 24th, 2004, 3:00 pm
Posts: 814
Location: Germany
Thanks Chris!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 21st, 2004, 7:56 am 
Offline

Joined: September 24th, 2004, 3:00 pm
Posts: 814
Location: Germany
Hi,

I use this:

Code:
RegRead,Lang,HKEY_CURRENT_USER,Control Panel\International\Language
StringLeft,Lang,Lang,2
if Lang <> DE
{
   ; Wrong language
   ExitApp
}
if A_OSType <> WIN32_NT
{
   ; Wrong system
   ExitApp
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 21st, 2004, 12:44 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Thanks for sharing that.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 22nd, 2004, 4:20 pm 
Offline

Joined: July 30th, 2004, 11:30 pm
Posts: 74
Location: Deutschland (sorry for my english)
Tekl wrote:
Hi,

I use this:

Code:
RegRead,Lang,HKEY_CURRENT_USER,Control Panel\International\Language
StringLeft,Lang,Lang,2
if Lang <> DE
{
   ; Wrong language
   ExitApp
}
if A_OSType <> WIN32_NT
{
   ; Wrong system
   ExitApp
}



FYI:
I have no 'Language' entry
in 'HKEY_CURRENT_USER\Control Panel\International'

I have only 'sLanguage' == DEU

( W2k SP2 + W2k SP3)

But i have 'Locale == 00000407'

Maybe this is better for identification ???

Only let you know....

_________________
Image Stefan

This post was created with the kindly help of http://dict.leo.org/ and remember: “Allways look on the bright side of Life”


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 29th, 2004, 7:27 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
A built-in variable for the system's default language has been added. Thanks for suggesting it. See A_Language.

If there is ever a need, a similar variable can be added for the current user's language (in case it differs from the system's).


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Multilanguage scripts
PostPosted: September 26th, 2005, 2:58 pm 
Offline

Joined: July 15th, 2005, 3:19 pm
Posts: 140
Location: Denmark
I am considering using AutoHotKey to create an advanced AutoCompletion and AutoCorrection tool. I plan to distribute this tool widely so it needs to operate regardless of the current language selection. I have created a test-script to show the difficulties with multilanguage AHK scripts.

Code:
;This script register the keys that are being pushed and duplicates them. "David" is turned into "DDaavviidd". The script should work for all key, including Enter, Arrow, and function keys.

#a::reload
#x::
{
   FileDelete, C:\Test.txt  ;Used for to show what was picked up from the keyboard
   Loop
   {
      ArrayLength += 1
      ;Should pick up all keys pushed on the keyboard.
      Input, Key, VL1, {Enter}{Escape}{F1}{F2}{F3}{F4}{F5}{F6}{F7}{F8}{F9}{F10}{F11}{F12}{Left}{Right}{Up}{Down}{Home}{End}{PgUp}{PgDn}{Del}{Ins}{BS}{Capslock}{Numlock}{PrintScreen}{Pause}
      if ErrorLevel <> Max ;ErrorLevel is not "Max" if i.e. F1 was pushed
      {
         StringTrimLeft, Key, ErrorLevel, 7

         ;In order for Send to send i.e. F1 it needs to put brackets around it, like {F1}
         Key = {%Key%}
      }
      
      ;other special characters that need brackets around them in order for Send to send them i.e. {{}
      if (Key = "{" or Key = "}" or Key = "^" or Key = "+" or Key = "#" or Key = "!")
      {
         Key = {%Key%}
      }
      Key := INCLUDESTATE(Key, "Control")
      Key := INCLUDESTATE(Key, "RAlt")
      Key := INCLUDESTATE(Key, "LAlt")
      Send, %Key%
      FileAppend, %Key%, C:\Test.txt
   }
   return
}

;Adds i.e. {Alt down} + character so the characters are written correctly
INCLUDESTATE(Key, modifier)
{
   GetKeyState, state, %modifier%
   if (state = "d")
   {
      Key = {%modifier% down}%key%{%modifier% up}
   }
   return key
}





This script works mostly fine if a window's language is the same as the default language. A problem arises if they are different. The problem has to do with that different languages have their dead keys located in different places. You can test this my making German the default keyboard layout and select for example english as the keyboard of a Notepad Window. Try then to play around with the keys next to the enter button. You will then discover that some keys have become dead, eventhough they are not dead on the english keyboard.

You can get a hint about why the script is acting as it is by viewing the c:\test.txt file where all keys are stored.

As far as I have understood, there is no way in AHK to detect the current window's language. Does anyone know when such a function could come? Is there any workaround for this that can be used to make this script reliable even if the user has installed four different keyboard layouts?


Report this post
Top
 Profile  
Reply with quote  
PostPosted: September 27th, 2005, 3:11 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
David Andersen wrote:
As far as I have understood, there is no way in AHK to detect the current window's language. Does anyone know when such a function could come?
I believe there is now a solution to this thanks to shimanov. See http://www.autohotkey.com/forum/viewtopic.php?t=5511


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 3 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group