-
keyboard fonctions
Hey guys,
Im using this code to write "hi" to notepad:
Code:
#define _WIN32_WINNT 0x0500
#include "windows.h"
void SendKey(BYTE vKey)
{
INPUT Input;
ZeroMemory(&Input, sizeof(Input));
Input.type = INPUT_KEYBOARD;
Input.ki.dwFlags = KEYEVENTF_EXTENDEDKEY;
Input.ki.wVk = vKey;
SendInput(1, &Input, sizeof(INPUT));
}
int main()
{
HWND Notepad = FindWindow("Notepad", 0);
if(!Notepad) return 0;
SetForegroundWindow(Notepad);
Sleep(500);
SendKey((UCHAR)VkKeyScan('h'));
SendKey((UCHAR)VkKeyScan('i'));
return 0;
}
But if the notepad is minimized it won't work. Is there a way to write "Hi" to it WHILE IT IS MINIMIZED?
-
Should be in Windows Programming...
-
-
I think keybd_event() is obsolete.
-
-
So does void main.
EDIT:
But to answer NoFearXD's question...
The answer is no, as you cannot type anything in Notepad while minimized, SendInput() and keybd_event() just "virtually press the key", they can't do anything you can't.
You could however, use FindWindow() to get Notepad, then find the child edit using FindWindowEx(), then using SetWindowText(). That would work even if it's minimized.
-