Ciao ragazzi, tempo fa avevo chiesto una funzione per simulare l'input da tastiera... ebbene l'ho trovata, però ho voluto fare una ritoccatina personale.
Mentre la funzione cercata simulava un input di un tasto... io ho aggiunto l'input di una stringa.
Il seguente include è stato editato da me.... (ho scritto in inglese così tanto per fare....)
La funzione Stirng(char * , int); simula l'imput da tastiera della stringa char * e int è il tempo di Sleep(); tra la digitazione di un tasto e l'altro.
Come si può notare mancano alcuni valori VK_ per esempio '!', '?' e molti altri caratteri speciali,
essi comunque sono facilmente inseribili all'occorrenza .
Compilato con Dev-C++ 4.9.9.2 0 problemi, spero di essere utile a qualcuno.
Codice PHP:
/***********************************/
/* POWERED by kirakira93 */
/* to HTML.it */
/* */
/* Simulation of keyboard input */
/* #include VKM.h */
/* usage: String (char * "Input", */
/* int sleep between the digits); */
/* */
/***********************************/
#define VKM_0 0x30
#define VKM_1 0x31
#define VKM_2 0x32
#define VKM_3 0x33
#define VKM_4 0x34
#define VKM_5 0x35
#define VKM_6 0x36
#define VKM_7 0x37
#define VKM_8 0x37
#define VKM_9 0x39
#define VKM_A 0x41
#define VKM_B 0x42
#define VKM_C 0x43
#define VKM_D 0x44
#define VKM_E 0x45
#define VKM_F 0x46
#define VKM_G 0x47
#define VKM_H 0x48
#define VKM_I 0x49
#define VKM_J 0x4a
#define VKM_K 0x4b
#define VKM_L 0x4c
#define VKM_M 0x4d
#define VKM_N 0x4e
#define VKM_O 0x4f
#define VKM_P 0x50
#define VKM_Q 0x51
#define VKM_R 0x52
#define VKM_S 0x53
#define VKM_T 0x54
#define VKM_U 0x55
#define VKM_V 0x56
#define VKM_W 0x57
#define VKM_X 0x58
#define VKM_Y 0x59
#define VKM_Z 0x5a
#define VKM_NUMPAD0 0x60
#define VKM_NUMPAD1 0x61
#define VKM_NUMPAD2 0x62
#define VKM_NUMPAD3 0x63
#define VKM_NUMPAD4 0x64
#define VKM_NUMPAD5 0x65
#define VKM_NUMPAD6 0x66
#define VKM_NUMPAD7 0x67
#define VKM_NUMPAD8 0x68
#define VKM_NUMPAD9 0x69
#define VKM_F1 0x70
#define VKM_F2 0x71
#define VKM_F3 0x72
#define VKM_F4 0x73
#define VKM_F5 0x74
#define VKM_F6 0x75
#define VKM_F7 0x76
#define VKM_F8 0x77
#define VKM_F9 0x78
#define VKM_F10 0x79
#define VKM_F11 0x80
#define VKM_F12 0x81
#define VKM_MOUSE1 0x05
#define VKM_MOUSE2 0x04
#define VKM_MOUSE3 0x06
#define VKM_TAB 0x09
#define VKM_ENTER 0x0d
#define VKM_SHIFT 0x10
#define VKM_CTRL 0x11
#define VKM_ALT 0x12
#define VKM_DEL 0x2e
#define VKM_ESC 0x1b
#define VKM_PRINT 0x2a
#define VKM_SPACE 0x20
#define VKM_LEFT 0x25
#define VKM_UP 0x26
#define VKM_RIGHT 0x27
#define VKM_DOWN 0x28
#define VKM_CAPITAL 0x14
#define VKM_DECIMAL 0x6e
#define VKM_COMMA 0xbc
#define VKM_ESCLAMATIVE 0//valore da inserire
#define VKM_QUESTION 0//valore da inserire
#define VKM_OTHER 6a //nulla
////////////////////////////////////////////////////////////////////////////////
#define VKM_MAX_SIZE_OF_INT_POINTER 199
int VKM_Size_of_Int_Pointer;
int VKM_Value_for_capital = 1000;
int VKM_String(char *, int);
int VKM_Edit(int *, int);
int VKM_Normal(int);
int VKM_Int_for_capital_cheecking;
int VKM_Normal(int VKM_Normal)
{
KEYBDINPUT VKM_pression = {0};
INPUT VKM_input = {0};
int returnVKM;
//VKM_Button pressed
VKM_pression.wVk = VKM_Normal;
VKM_input.type = INPUT_KEYBOARD;
VKM_input.ki = VKM_pression;
returnVKM = SendInput(1,&VKM_input,sizeof(VKM_input));
//delete VKM_ values
ZeroMemory(&VKM_pression, sizeof(KEYBDINPUT));
ZeroMemory(&VKM_input, sizeof(INPUT));
//VKM_Button relased
VKM_pression.wVk = VKM_Normal;
VKM_pression.dwFlags = KEYEVENTF_KEYUP;
VKM_input.type = INPUT_KEYBOARD;
VKM_input.ki = VKM_pression;
returnVKM = SendInput(1,&VKM_input,sizeof(VKM_input));
if(!returnVKM)
return 0;
else return 1;
//delete VKM_ values
ZeroMemory(&VKM_pression, sizeof(KEYBDINPUT));
ZeroMemory(&VKM_input, sizeof(INPUT));
}
int VKM_Edit(int * VKM_Button, int VKM_Sleep)
{
for (int VKM_Edit_FOR = 0;
VKM_Edit_FOR <= VKM_Size_of_Int_Pointer + 1;
VKM_Edit_FOR++)
{
Sleep(VKM_Sleep);
VKM_Int_for_capital_cheecking = VKM_Button[ VKM_Edit_FOR ];
if (VKM_Int_for_capital_cheecking > 0xff) VKM_Button[ VKM_Edit_FOR ] -= VKM_Value_for_capital;
KEYBDINPUT VKM_pression = {0};
INPUT VKM_input = {0};
int returnVKM;
if (VKM_Int_for_capital_cheecking > 0xff) VKM_Normal(VKM_CAPITAL);
//VKM_Button pressed
VKM_pression.wVk = VKM_Button[ VKM_Edit_FOR ];
VKM_input.type = INPUT_KEYBOARD; //...
VKM_input.ki = VKM_pression;
returnVKM = SendInput(1,&VKM_input,sizeof(VKM_input));
//delete VKM_ values
ZeroMemory(&VKM_pression, sizeof(KEYBDINPUT));
ZeroMemory(&VKM_input, sizeof(INPUT));
//VKM_Button relased
VKM_pression.wVk = VKM_Button[ VKM_Edit_FOR ];
VKM_pression.dwFlags = KEYEVENTF_KEYUP;
VKM_input.type = INPUT_KEYBOARD;
VKM_input.ki = VKM_pression;
returnVKM = SendInput(1,&VKM_input,sizeof(VKM_input));
if (VKM_Int_for_capital_cheecking > 0xff) VKM_Normal(VKM_CAPITAL);
//delete VKM_ values
ZeroMemory(&VKM_pression, sizeof(KEYBDINPUT));
ZeroMemory(&VKM_input, sizeof(INPUT));
}
return 0;
}
////////////////////////////////////////////////////////////////////////////////
int VKM_String(char * VKM_String, int VKM_Sleep)
{//MessageBox(NULL, "()", "", 0);
int VKM_Int_Pointer[VKM_MAX_SIZE_OF_INT_POINTER];
if (VKM_String[ 0 ] == '\0')MessageBox(NULL, "Hard error of the code", "", 0);
for (int FOR_VKM_String = 0;
VKM_String[ FOR_VKM_String ] != '\0' &&
FOR_VKM_String <= VKM_MAX_SIZE_OF_INT_POINTER;
FOR_VKM_String++)
{//MessageBox(NULL, "switch", "", 0);
switch(VKM_String[ FOR_VKM_String ])
{
case 'a': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_A; } break;
case 'b': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_B; } break;
case 'c': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_C; } break;
case 'd': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_D; } break;
case 'e': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_E; } break;
case 'f': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_F; } break;
case 'g': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_G; } break;
case 'h': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_H; } break;
case 'i': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_I; } break;
case 'j': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_J; } break;
case 'k': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_K; } break;
case 'l': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_L; } break;
case 'm': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_M; } break;
case 'n': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_N; } break;
case 'o': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_O; } break;
case 'p': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_P; } break;
case 'q': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_Q; } break;
case 'r': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_R; } break;
case 's': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_S; } break;
case 't': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_T; } break;
case 'u': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_U; } break;
case 'v': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_V; } break;
case 'w': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_W; } break;
case 'x': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_X; } break;
case 'y': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_Y; } break;
case 'z': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_Z; } break;
case 'A': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_A + VKM_Value_for_capital; } break;
case 'B': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_B + VKM_Value_for_capital; } break;
case 'C': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_C + VKM_Value_for_capital; } break;
case 'D': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_D + VKM_Value_for_capital; } break;
case 'E': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_E + VKM_Value_for_capital; } break;
case 'F': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_F + VKM_Value_for_capital; } break;
case 'G': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_G + VKM_Value_for_capital; } break;
case 'H': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_H + VKM_Value_for_capital; } break;
case 'I': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_I + VKM_Value_for_capital; } break;
case 'J': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_J + VKM_Value_for_capital; } break;
case 'K': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_K + VKM_Value_for_capital; } break;
case 'L': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_L + VKM_Value_for_capital; } break;
case 'M': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_M + VKM_Value_for_capital; } break;
case 'N': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_N + VKM_Value_for_capital; } break;
case 'O': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_O + VKM_Value_for_capital; } break;
case 'P': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_P + VKM_Value_for_capital; } break;
case 'Q': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_Q + VKM_Value_for_capital; } break;
case 'R': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_R + VKM_Value_for_capital; } break;
case 'S': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_S + VKM_Value_for_capital; } break;
case 'T': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_T + VKM_Value_for_capital; } break;
case 'U': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_U + VKM_Value_for_capital; } break;
case 'V': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_V + VKM_Value_for_capital; } break;
case 'W': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_W + VKM_Value_for_capital; } break;
case 'X': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_X + VKM_Value_for_capital; } break;
case 'Y': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_Y + VKM_Value_for_capital; } break;
case 'Z': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_Z + VKM_Value_for_capital; } break;
case '0': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_0; } break;
case '1': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_1; } break;
case '2': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_2; } break;
case '3': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_3; } break;
case '4': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_4; } break;
case '5': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_5; } break;
case '6': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_6; } break;
case '7': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_7; } break;
case '8': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_8; } break;
case '9': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_9; } break;
case '!': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_ESCLAMATIVE; } break;
case '?': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_QUESTION; } break;
case '\n': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_ENTER; } break;
case ' ': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_SPACE; } break;
case '.': {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_DECIMAL; } break;
default : {VKM_Int_Pointer[ FOR_VKM_String ] = VKM_DECIMAL; } break;
}
VKM_Size_of_Int_Pointer = FOR_VKM_String - 1;
}
VKM_Edit(VKM_Int_Pointer, VKM_Sleep);
}
////////////////////////////////////////////////////////////////////////////////
Provare per credere... Ciao