keystroke

SendInput Not working for Games

依然范特西╮ 提交于 2019-11-30 16:09:06
I am using the following standard GenerateKey Code : void GenerateKey ( int vk , BOOL bExtended) { KEYBDINPUT kb={0}; INPUT Input={0}; // generate down if ( bExtended ) kb.dwFlags = KEYEVENTF_EXTENDEDKEY; kb.wVk = vk; Input.type = INPUT_KEYBOARD; Input.ki = kb; ::SendInput(1,&Input,sizeof(Input)); // generate up ::ZeroMemory(&kb,sizeof(KEYBDINPUT)); ::ZeroMemory(&Input,sizeof(INPUT)); kb.dwFlags = KEYEVENTF_KEYUP; if ( bExtended ) kb.dwFlags |= KEYEVENTF_EXTENDEDKEY; kb.wVk = vk; Input.type = INPUT_KEYBOARD; Input.ki = kb; ::SendInput(1,&Input,sizeof(Input)); } I call this function to simulate

Send Ctrl+Key to a 3rd Party Application

流过昼夜 提交于 2019-11-30 15:51:39
问题 Im using a 3rd Party Application that exports a file. The application uses a hot key ( Ctrl + E ) as a shortcut for this function. How can I send this key combination from my Delphi XE application to the 3rd Party one? 回答1: Here is an example which shows how to send Ctrl + E to the foreground application using SendInput: var Inputs: array [0..3] of TInput; begin // press Inputs[0].Itype := INPUT_KEYBOARD; Inputs[0].ki.wVk := VK_CONTROL; Inputs[0].ki.dwFlags := 0; Inputs[1].Itype := INPUT

bash scripting - read single keystroke including special keys enter and space

岁酱吖の 提交于 2019-11-30 09:20:37
Not sure if I should put this on stackoverflow or unix.stackexchange but I found some similar questions here, so here it goes. I'm trying to create a script to be called by .bashrc that allows me to select one of two options based on a single keystroke. That wouldn't be hard normally but I want the two keys corresponding to the two options to be space and enter. Here's what I got so far: #!/bin/bash SELECT="" while [[ "$SELECT" != $'\x0a' && "$SELECT" != $'\x20' ]]; do echo "Select session type:" echo "Press <Enter> to do foo" echo "Press <Space> to do bar" read -s -N 1 SELECT echo "Debug/

Sending keystrokes to a program

三世轮回 提交于 2019-11-30 09:09:33
In window form, I made a button and I'm trying to make it send F1 to a specific window (Such as FireFox, My Computer, etc...) My questions are : How do I do it by the window's name? (such as "Mozilla Firefox") How do I do it by the process's name? (such as firefox.exe) Kyle Rozendo By Window name: [DllImport("User32.dll")] static extern IntPtr FindWindow(string lpClassName, string lpWindowName); [DllImport("User32.dll")] static extern int SetForegroundWindow(IntPtr hWnd); IntPtr ptrFF = FindWindow(null, "Mozilla Firefox"); SetForegroundWindow(ptrFF); SendKeys.SendWait("{F1}"); By Process name:

How do I capture keystrokes on the web?

非 Y 不嫁゛ 提交于 2019-11-29 17:59:35
Using PHP, JS, or HTML (or something similar) how would I capture keystokes? Such as if the user presses ctrl+f or maybe even just f, a certain function will happen. ++++++++++++++++++++++++EDIT+++++++++++++++++++ Ok, so is this correct, because I can't get it to work. And I apologize for my n00bness is this is an easy question, new to jQuery and still learning more and more about JS. <script> var element = document.getElementById('capture'); element.onkeypress = function(e) { var ev = e || event; if(ev.keyCode == 70) { alert("hello"); } } </script> <div id="capture"> Hello, Testing 123 </div>

Only allowing up to three digit numeric characters in a text box

ぃ、小莉子 提交于 2019-11-29 17:05:14
Is there a way to only allow a user to input a maximum number of characters into a text box? I want the user to input a mark/grade and only be able to input 0 - 100. Below I have code that monitors the keystroke and only allows for numbers to be input, but I want to find a way to only allow the user to input a number with a minimum value of 0 and a maximum of 100. private void TxtMark4_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar < '0' || e.KeyChar > '9' || e.KeyChar == ' ') { e.Handled = true; } else { e.Handled = false; } } or I could use the following: if (e.KeyChar >= 48 &&

bash scripting - read single keystroke including special keys enter and space

好久不见. 提交于 2019-11-29 14:12:37
问题 Not sure if I should put this on stackoverflow or unix.stackexchange but I found some similar questions here, so here it goes. I'm trying to create a script to be called by .bashrc that allows me to select one of two options based on a single keystroke. That wouldn't be hard normally but I want the two keys corresponding to the two options to be space and enter. Here's what I got so far: #!/bin/bash SELECT="" while [[ "$SELECT" != $'\x0a' && "$SELECT" != $'\x20' ]]; do echo "Select session

Sending keystrokes to a program

早过忘川 提交于 2019-11-29 13:46:57
问题 In window form, I made a button and I'm trying to make it send F1 to a specific window (Such as FireFox, My Computer, etc...) My questions are : How do I do it by the window's name? (such as "Mozilla Firefox") How do I do it by the process's name? (such as firefox.exe) 回答1: By Window name: [DllImport("User32.dll")] static extern IntPtr FindWindow(string lpClassName, string lpWindowName); [DllImport("User32.dll")] static extern int SetForegroundWindow(IntPtr hWnd); IntPtr ptrFF = FindWindow

Java: Use keystroke with arrow key

廉价感情. 提交于 2019-11-29 11:28:42
I have some code that I need to modify. In the code, the original author uses KeyStroke.getKeyStroke to take user input. In this code, for example, he uses a instead of left arrow. I want to change this, but I don't know how. Here is the original code: registerKeyboardAction( new ActionListener() { public void actionPerformed(ActionEvent e) { tick(RIGHT); } }, "right", KeyStroke.getKeyStroke('d'), WHEN_IN_FOCUSED_WINDOW ); I have to change it to something like this, but when run, it doesn't work: KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT); KeyStroke.getKeyStroke("RIGHT"); Do start the program

VBScript SendKeys CTRL+LWIN+TAB?

血红的双手。 提交于 2019-11-29 10:44:11
I am trying to write a simple script that will send the key combo of CTRL + WINDOWS KEY + TAB . The code below sends the keys CTRL + ALT + TAB Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.SendKeys "^%{TAB}" However when I try to replace "%" (aka the ALT key) with LWIN (aka the Left Windows Key) it says Syntax Error. I tried the following, but had no luck: Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.SendKeys "^{LWIN}{TAB}" Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.SendKeys "^{LWIN}+{TAB}" Set WshShell = WScript.CreateObject("WScript.Shell")