Im already using GetAsyncKeyState. How do I know when the numpad keys?
At this point im going to put up my code, so everyone can see what im doing. You don't have to take it and edit it and spit it back out. Infact, please don't. I would rather learn how to do it than have someone do it for me.
Code:
#include <iostream>
#include <stdio.h>
#include <conio.h>
#include <windows.h>
#define SHIFTED 0x8000
//define variables
int LEFT; int RIGHT; int UP; int DOWN;
int LSHIFT; int RSHIFT;
int ENTER;
int LALT; int RALT;
int PRESSED;
int scale;
int main ( void ){
//set arrow-key keycodes
LEFT=37; RIGHT=39; UP=38; DOWN=40;
//set shift keycodes
LSHIFT=160; RSHIFT=161;
//set enter keycode
ENTER=13;
//set alt keycodes
LALT=164; RALT=165;
//set key-pressed value
PRESSED=-32767;
//set default movement scale
scale=2;
//define cursor point
POINT XY;
//print instructions
cout<<"Use the arrow keys to move the cursor, hold SHIFT to move the cursor faster."<<endl;
cout<<"Press ENTER to left-click, and ALT to right-click."<<endl;
//main loop
while(1==1)
{
//if enter pressed then left-click
if(GetAsyncKeyState(ENTER)==PRESSED){
mouse_event(MOUSEEVENTF_LEFTDOWN, XY.x, XY.y, 0, 0);
Sleep(100);
mouse_event(MOUSEEVENTF_LEFTUP, XY.x, XY.y, 0, 0);
}
//if alt pressed then right-click
if(GetAsyncKeyState(LALT)==PRESSED||GetAsyncKeyState(RALT)==PRESSED){
mouse_event(MOUSEEVENTF_RIGHTDOWN, XY.x, XY.y, 0, 0);
Sleep(100);
mouse_event(MOUSEEVENTF_RIGHTUP, XY.x, XY.y, 0, 0);
}
//move mouse with arrow keys. set scale to 10 if shift is pressed, else 2
if(GetAsyncKeyState(LEFT)==PRESSED){
if(GetKeyState(LSHIFT) & SHIFTED||GetKeyState(RSHIFT) & SHIFTED){
scale=10;
}else{
scale=2;
}
GetCursorPos( &XY );
SetCursorPos( XY.x - scale, XY.y);
}
if(GetAsyncKeyState(RIGHT)==PRESSED){
if(GetKeyState(LSHIFT) & SHIFTED||GetKeyState(RSHIFT) & SHIFTED){
scale=10;
}else{
scale=2;
}
GetCursorPos( &XY );
SetCursorPos( XY.x + scale, XY.y);
}
if(GetAsyncKeyState(UP)==PRESSED){
if(GetKeyState(LSHIFT) & SHIFTED||GetKeyState(RSHIFT) & SHIFTED){
scale=10;
}else{
scale=2;
}
GetCursorPos( &XY );
SetCursorPos( XY.x, XY.y - scale );
}
if(GetAsyncKeyState(DOWN)==PRESSED){
if(GetKeyState(LSHIFT) & SHIFTED||GetKeyState(RSHIFT) & SHIFTED){
scale=10;
}else{
scale=2;
}
GetCursorPos( &XY );
SetCursorPos( XY.x, XY.y + scale );
}
}
return 0;
}