sendinput

Simulate click into a hidden window

六眼飞鱼酱① 提交于 2019-11-27 03:40:40
问题 I've got a C# problem, I am able to simulate a click to the current window, but I would like to do it if the window is minimized or hidden. Any ideas? 回答1: Here is a fully working snippet which will give you the window handle, target sub window and post a message to that subwindow. #include "TCHAR.h" #include "Windows.h" int _tmain(int argc, _TCHAR* argv[]) { HWND hwndWindowTarget; HWND hwndWindowNotepad = FindWindow(NULL, L"Untitled - Notepad"); if (hwndWindowNotepad) { // Find the target

SendInput() not equal to pressing key manually on keyboard in C++?

橙三吉。 提交于 2019-11-27 01:47:13
I wanted to write a c++ code to emulate pressing a keyboard key "A": // Set up a generic keyboard event. ip.type = INPUT_KEYBOARD; ip.ki.wScan = 0; // hardware scan code for key ip.ki.time = 0; ip.ki.dwExtraInfo = 0; // Press the "..." key ip.ki.wVk = code; // virtual-key code for the "a" key ip.ki.dwFlags = 0; // 0 for key press SendInput(1, &ip, sizeof(INPUT)); // Release the "..." key ip.ki.dwFlags = KEYEVENTF_KEYUP; // KEYEVENTF_KEYUP for key release SendInput(1, &ip, sizeof(INPUT)); It works fine when I launch other program and wait to my program execute, the "A" is clicked and first

How to send a string to other application including Microsoft Word

随声附和 提交于 2019-11-26 17:20:00
问题 I was trying to accomplish this but did not get good results. I used GetForegroundWindow(), AttachThreadInput(uint,uint,bool) and GetFocus() functions to send the strings to another window. It works with Notepad, Wordpad and other applications, but not with Microsoft Word. int foregroundWindowHandle = GetForegroundWindow(); uint remoteThreadId = GetWindowThreadProcessId(foregroundWindowHandle, 0); uint currentThreadId = GetCurrentThreadId(); bool b = AttachThreadInput(remoteThreadId,

Simulating Keyboard with SendInput API in DirectInput applications

只愿长相守 提交于 2019-11-26 08:16:42
问题 I\'m trying to simulate keyboard commands for a custom game controller application. Because I\'ll need to simulate commands in a DirectInput environment most of the usual methods don\'t work. I know that using a hook would work 100% but I\'m trying to find an easier implementation. I\'ve done quite a bit of searching and found that by using the SendInput API with Scancodes instead of virtual keys should work, but it seems to behave like the key\'s are \"sticking\". I\'ve sent both the KEYDOWN

SendInput() not equal to pressing key manually on keyboard in C++?

℡╲_俬逩灬. 提交于 2019-11-26 07:39:47
问题 I wanted to write a c++ code to emulate pressing a keyboard key \"A\": // Set up a generic keyboard event. ip.type = INPUT_KEYBOARD; ip.ki.wScan = 0; // hardware scan code for key ip.ki.time = 0; ip.ki.dwExtraInfo = 0; // Press the \"...\" key ip.ki.wVk = code; // virtual-key code for the \"a\" key ip.ki.dwFlags = 0; // 0 for key press SendInput(1, &ip, sizeof(INPUT)); // Release the \"...\" key ip.ki.dwFlags = KEYEVENTF_KEYUP; // KEYEVENTF_KEYUP for key release SendInput(1, &ip, sizeof(INPUT