string richtig benutzen
-
Hallo,
Ich möchte ein programm schreiben der tasten drücke simuliert,
undzwar soll man vorher eingeben können welche taste.
habe folgendes schon probiert aber ohne erfolg
#include <cstdlib> #include <iostream> #include <conio.h> #include <windows.h> #include <string.> using namespace std; int main(int argc, char *argv[]) { cout<<"Welche Taste?"<<endl; int taste=getch(); while(true){ HWND hwnd = FindWindow(NULL, "1.txt - Editor"); if(hwnd) { SetForegroundWindow(hwnd); Sleep(1000); keybd_event("%d",taste, 0, 0, 0); keybd_event("%d",taste, 0, KEYEVENTF_KEYUP, 0); } } return 0; }bin auf jeden hilfe dankbar
mfg
-
-
#include <cstdlib> #include <iostream> #include <conio.h> #include <windows.h> #include <string.> using namespace std; int taste; int main(int argc, char *argv[]) { cout<<"Welche Taste?"<<endl; taste=getch(); cout << taste<<endl; for(int i=0;i<=5;i++) { HWND hwnd = FindWindowEx( NULL, NULL, "Notepad", NULL ); if(hwnd) { Sleep(500); SetWindowPos(hwnd, HWND_TOPMOST, 0,0,0,0, SWP_NOMOVE|SWP_NOSIZE); SetForegroundWindow(hwnd); if (taste>=65&&i==0) { taste =taste -32; } keybd_event(taste, 0, 0, 0); keybd_event(taste, 0, KEYEVENTF_KEYUP, 0); } else { cout << "Nicht gefunden "<<endl; break; } } getch(); }so sollte es gehen
