AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

keyboard layout

Ein Thema von chukalv · begonnen am 7. Jan 2007 · letzter Beitrag vom 9. Jan 2007
Antwort Antwort
chukalv

Registriert seit: 21. Mär 2005
8 Beiträge
 
Delphi 6 Professional
 
#1

keyboard layout

  Alt 7. Jan 2007, 19:47
How to change a keyboard layout for another program? As I understood it`s not possible to do really. But I have successfully created a keyboard hook and can receive and send keyboard codes.
The question- How to change a received keyboard code to the code form another installed keyboard layout? For example, I have an "a" from the english layout('00000409') and it have to translated to "ф" from the russian keyboard layout('00000419')
May the source be with You!
  Mit Zitat antworten Zitat
Olli
(Gast)

n/a Beiträge
 
#2

Re: keyboard layout

  Alt 7. Jan 2007, 21:11
Привет,

I wonder how a hook can send things ... it first of all needs to get notified of whatever to do any action

A translation of the key codes to Unicode characters can be found in the respective keyboard layout DLL and can be parsed. You can find more information in the temporary files created by Bei Google suchenMSKLC and in the DDK/WDK.

However, what are you trying to achieve? Typing translit (or phonetically similar letters) and receive Russian ones? Why change it for another program? Wouldn't it be sufficient to create your own phonetic/translit keyboard layout so you can use it anywhere? This is how I do it.
  Mit Zitat antworten Zitat
chukalv

Registriert seit: 21. Mär 2005
8 Beiträge
 
Delphi 6 Professional
 
#3

Re: keyboard layout

  Alt 8. Jan 2007, 06:55
Thanks for the link. Actually I`ve already have the keyboard layout dll's. What I was trying to do, is to change the layout for other programs. For example on a hotkey press, my program changes the active input fields's layout to russian (what is already installed on the windows system)... The only one way to do that, I thought is to change the corresponfing ket to another...Actually a dirty way...
Any ideas how to do that in another way?
May the source be with You!
  Mit Zitat antworten Zitat
Olli
(Gast)

n/a Beiträge
 
#4

Re: keyboard layout

  Alt 8. Jan 2007, 10:41
If you ask me, other ways seem just as "dirty" as the first. However, what you can possibly do is to hook the input and wait for your "hotkey". Then, as soon as the hotkey gets pressed, you send input to the current window and in the context of the current process. This should suffice to switch the language. However, you'll have to have a way to check the current input language, you'll need a way to enumerate existing layouts and a way to check which system-wide setting exists for the input language switching hotkey (so you send the right one). All in all quite much for such a simple functionality.

Another method could be (for Unicode text fields in other apps) to inject the DLL and subclass the control (i.e. the text field) so that you can manipulate the respective messages ... was it WM_CHAR and WM_IME_CHAR?!
  Mit Zitat antworten Zitat
chukalv

Registriert seit: 21. Mär 2005
8 Beiträge
 
Delphi 6 Professional
 
#5

Re: keyboard layout

  Alt 8. Jan 2007, 12:06
OK now. The part where I find the installed layouts, the default layout and how to change it, is already done. All the information is in the registry... After a login and logout, the keyboard layout changes perfect. Just how to send the hotkey for the active process? I've no clue...
May the source be with You!
  Mit Zitat antworten Zitat
chukalv

Registriert seit: 21. Mär 2005
8 Beiträge
 
Delphi 6 Professional
 
#6

Re: keyboard layout

  Alt 8. Jan 2007, 12:44
Well, I misunderstood You and myself.
The idea to simulate the language hotkey works fine. If someone presess my registered hotkey, I`m sending the windows language hotkey to the program and the keyboard layout changes. It works fine.
But if I wan't to change the keyboard layout without the hotkey? Meaning not to change only one step forward but to change it directly to another keyboard layout. I`ve made that my program finds out what keyboard layout is using the program, but I can`t find out how to change it... Maybe there are some possibilities to call the ActivateKeyboardLayout function to the active program?
May the source be with You!
  Mit Zitat antworten Zitat
Olli
(Gast)

n/a Beiträge
 
#7

Re: keyboard layout

  Alt 9. Jan 2007, 01:11
Zitat von chukalv:
Well, I misunderstood You and myself.
The idea to simulate the language hotkey works fine. If someone presess my registered hotkey, I`m sending the windows language hotkey to the program and the keyboard layout changes. It works fine.
But if I wan't to change the keyboard layout without the hotkey? Meaning not to change only one step forward but to change it directly to another keyboard layout. I`ve made that my program finds out what keyboard layout is using the program, but I can`t find out how to change it... Maybe there are some possibilities to call the ActivateKeyboardLayout function to the active program?
Hint: a hook runs inside the process (and thread) which handles a certain window messages. This means you can use this to your advantage since you can call anything from within your hook function (such as checking the current layout and changing it to your needs).

The only problem: hooks are event based. So if you think it is no overkill to load your (hook) DLL into any running GUI application, it would be a way to check the current window receiving a message (such as WM_CHAR), if it is of the window class (e.g. EDIT or TEdit or TMemo) you want to process, you can check what is the current thread's keyboard layout and change it if needed.
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 16:22 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz