|
|
So implementare gli object
- Group:
- Admin
- Posts:
- 1,215
- Reputazione:
- +150
- Status:
| |
| Tutti qui sono abituati a usare il caro e vecchio Send() di AutoIt (che poi sarebbe il SendKeys.Send() del framework .NET), ma come sappiamo i giochi se ne fregano altamente di quella funzione Per ovviare al problema si può usare SendInput(), funzione per cui AutoIt non offre ancora un wrapper Comunque ecco un esempio per l'utilizzo in C o C++: CODICE #include <stdio.h> #include <Windows.h>
void spostaMouse(int x, int y);
int _tmain(int argc, _TCHAR* argv[]) { int i;
for (i = 0; i < GetSystemMetrics(SM_CXSCREEN); i++) { spostaMouse(i, 200); Sleep(10); }
return 0; }
void spostaMouse(int x, int y) { INPUT input;
memset(&input, 0, sizeof(INPUT));
input.type = INPUT_MOUSE; input.mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE;
input.mi.mouseData = 0;
input.mi.dx = x * (65536 / GetSystemMetrics(SM_CXSCREEN)); input.mi.dy = y * (65536 / GetSystemMetrics(SM_CYSCREEN));
SendInput(1, &input, sizeof(INPUT));
return; } Spero che possa servire a qualcuno... PastebinTra poco aggiungo un esempio per la tastiera. EDIT: altro esempio per il mouse (da compilare per il sottosistema Windows): http://pastebin.com/BPdeSgJCEdited by ‡ (dd) - 26/6/2012, 19:57
|
| |