keyboard-layout

SendInput() and non-English characters and keyboard layouts

心不动则不痛 提交于 2019-12-05 12:43:51
I'm having trouble simulating character keypresses when a non-English input keyboard language is being used in Windows. I tried calling SendInput() with KEYEVENTF_UNICODE: KEYBDINPUT ki; INPUT input; int character = 0; ki.wVk = 0; ki.wScan = character; ki.dwFlags = KEYEVENTF_UNICODE; ki.time = 0; ki.dwExtraInfo = 0; input.type = INPUT_KEYBOARD; input.ki = ki; SendInput(1, &input, sizeof(INPUT)); And this actually works (of course, in my code, I also do a KEYUP after the key down)... except in GTK+ apps (there may be other instances where it doesn't work either). According to MSDN , If

Efficient Implementation of Fitness-Proportionate “Roulette” Selection

懵懂的女人 提交于 2019-12-05 08:33:50
问题 I am currently writing a keyboard layout optimization algorithm in C (such as the one designed by Peter Klausler) and I want to implement a fitness-proportionate selection as described here (PDF Link): With roulette selection you select members of the population based on a roullete wheel model. Make a pie chart, where the area of a member’s slice to the whole circle is the ratio of the members fitness to the total population. As you can see if a point on the circumfrence of the circle is

Keyboard Layout library to find Neighboring Keys given an input key (java preferable) [closed]

﹥>﹥吖頭↗ 提交于 2019-12-05 07:25:03
Does anyone know of a library (preferably java) that can give me neighboring keys given a key input for US_ENGLISH standard keyboard? E.g. if I input the character 'd', I should get the following characters returned: [w,e,r,s,f,x,c,v]. Alternatively a grid manipulation api would work too (so that I can instantiate a grid with a qwerty keyboard layout and use it to find my neighbors). Note 1: I am using the words 'character' and 'key' synonymously to refer to characters. Note 2: I know I can hard-code a method to map the 50-or-so primary keys to their neighbors. I am looking for a better

Can I change a user's keyboard input?

戏子无情 提交于 2019-12-05 03:17:54
问题 I found this keyboard hook code, which I'm trying to slightly modify for my purposes: http://blogs.msdn.com/toub/archive/2006/05/03/589423.aspx As an overview, I want to have the user press a key, say 'E', and have the keyboard return a different character, 'Z', to whatever app is in focus. The relevant method I changed now looks like: private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam) { if (nCode >= 0 && wParam == (IntPtr)WM_KEYDOWN) { //The truely typed character:

js: how to get LOCALIZED character on keypress?

风流意气都作罢 提交于 2019-12-04 19:52:16
问题 I need to get localized character on keypress event. For example: on czech keybord I need to get ř not 5 character (key code 53) (see Czech keyboard layout). Is there any other way to get character and to not use text input and reading value? By other words is there any way how to get character from event object respecting current user keyboard layout? (added sample code) <html> <body> <script language="JavaScript"> function onLoad() { console.log(document.getElementById("test")); document

Can I change a user's keyboard input?

对着背影说爱祢 提交于 2019-12-03 16:41:03
I found this keyboard hook code, which I'm trying to slightly modify for my purposes: http://blogs.msdn.com/toub/archive/2006/05/03/589423.aspx As an overview, I want to have the user press a key, say 'E', and have the keyboard return a different character, 'Z', to whatever app is in focus. The relevant method I changed now looks like: private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam) { if (nCode >= 0 && wParam == (IntPtr)WM_KEYDOWN) { //The truely typed character: int vkCode = Marshal.ReadInt32(lParam); Console.WriteLine((Keys)vkCode); KBDLLHOOKSTRUCT replacementKey

Preserving keyboard layout in swing app?

微笑、不失礼 提交于 2019-12-03 13:55:33
I have a Java Swing application wich spawns child dialogs with text controls. And the problem is that when you change keyboard layout in child dialog, it changes back right after the dialog is closed. What I need is the keboard layout to stay after being switched whether it was switched in the main frame or in a child frame. Here is a SSCCE that illustrates the problem: import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class InheritInputContext { public static void main(String[] arg) { final MainFrame mainFrame = new

Preserving keyboard layout in a JTextfield?

时光总嘲笑我的痴心妄想 提交于 2019-12-03 08:57:03
Simple example: 2 JTextFields , one for a spanish word another one for it's translation. Is there a way to preserve keyboard layout per JTextField so that the user wouldn't have to switch back and forth? TIA. Yes, this demo code uses the keyboard layout for the selected locales in each text field: public class InputMethodTest { public static void main(String[] args) { final InputContext en = InputContext.getInstance(); en.selectInputMethod(Locale.UK); final InputContext es = InputContext.getInstance(); es.selectInputMethod(new Locale("es", "ES")); JTextArea english = new JTextArea() {

How to map a X11 KeySym to a Unicode character?

半腔热情 提交于 2019-12-01 18:20:26
This is an exact duplicate of this question ; however the code linked in the accepted answer is nearly 11 years old, and this comment in the code leads to my duplicate question: The keysym -> UTF-8 conversion will hopefully one day be provided by Xlib via XmbLookupString() and should ideally not have to be done in X applications. But we are not there yet. Are we there yet? I'm aware of XwcLookupString , but something like... wchar_t unicode = XKeySymToWideChar( keysym ); ... would be much simpler and logical, and not require updating whenever KeySyms are added or changed. Is there a simple

How to map a X11 KeySym to a Unicode character?

冷暖自知 提交于 2019-12-01 17:49:44
问题 This is an exact duplicate of this question; however the code linked in the accepted answer is nearly 11 years old, and this comment in the code leads to my duplicate question: The keysym -> UTF-8 conversion will hopefully one day be provided by Xlib via XmbLookupString() and should ideally not have to be done in X applications. But we are not there yet. Are we there yet? I'm aware of XwcLookupString , but something like... wchar_t unicode = XKeySymToWideChar( keysym ); ... would be much