Code: Select all
#include <Windows.h>
#pragma once
namespace Input
{
namespace Key
{
void Hold_Shift()
{
keybd_event(VK_SHIFT,0,0,0);
}
void Undo_Shift()
{
keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
}
void A()
{
keybd_event((0x41),0,0,0);
keybd_event((0x41),0,KEYEVENTF_KEYUP,0);
}
void B()
{
keybd_event((0x42),0,0,0);
keybd_event((0x42),0,KEYEVENTF_KEYUP,0);
}
void C()
{
keybd_event((0x43),0,0,0);
keybd_event((0x43),0,KEYEVENTF_KEYUP,0);
}
void D()
{
keybd_event((0x44),0,0,0);
keybd_event((0x44),0,KEYEVENTF_KEYUP,0);
}
void E()
{
keybd_event((0x45),0,0,0);
keybd_event((0x45),0,KEYEVENTF_KEYUP,0);
}
void F()
{
keybd_event((0x46),0,0,0);
keybd_event((0x46),0,KEYEVENTF_KEYUP,0);
}
void G()
{
keybd_event((0x47),0,0,0);
keybd_event((0x47),0,KEYEVENTF_KEYUP,0);
}
void H()
{
keybd_event((0x48),0,0,0);
keybd_event((0x48),0,KEYEVENTF_KEYUP,0);
}
void I()
{
keybd_event((0x49),0,0,0);
keybd_event((0x49),0,KEYEVENTF_KEYUP,0);
}
void J()
{
keybd_event((0x4A),0,0,0);
keybd_event((0x4A),0,KEYEVENTF_KEYUP,0);
}
void K()
{
keybd_event((0x4B),0,0,0);
keybd_event((0x4B),0,KEYEVENTF_KEYUP,0);
}
void L()
{
keybd_event((0x4C),0,0,0);
keybd_event((0x4C),0,KEYEVENTF_KEYUP,0);
}
void M()
{
keybd_event((0x4D),0,0,0);
keybd_event((0x4D),0,KEYEVENTF_KEYUP,0);
}
void N()
{
keybd_event((0x4E),0,0,0);
keybd_event((0x4E),0,KEYEVENTF_KEYUP,0);
}
void O()
{
keybd_event((0x4F),0,0,0);
keybd_event((0x4F),0,KEYEVENTF_KEYUP,0);
}
void P()
{
keybd_event((0x50),0,0,0);
keybd_event((0x50),0,KEYEVENTF_KEYUP,0);
}
void Q()
{
keybd_event((0x51),0,0,0);
keybd_event((0x51),0,KEYEVENTF_KEYUP,0);
}
void R()
{
keybd_event((0x52),0,0,0);
keybd_event((0x52),0,KEYEVENTF_KEYUP,0);
}
void S()
{
keybd_event((0x53),0,0,0);
keybd_event((0x53),0,KEYEVENTF_KEYUP,0);
}
void T()
{
keybd_event((0x54),0,0,0);
keybd_event((0x54),0,KEYEVENTF_KEYUP,0);
}
void U()
{
keybd_event((0x55),0,0,0);
keybd_event((0x55),0,KEYEVENTF_KEYUP,0);
}
void V()
{
keybd_event((0x56),0,0,0);
keybd_event((0x56),0,KEYEVENTF_KEYUP,0);
}
void W()
{
keybd_event((0x57),0,0,0);
keybd_event((0x57),0,KEYEVENTF_KEYUP,0);
}
void X()
{
keybd_event((0x58),0,0,0);
keybd_event((0x58),0,KEYEVENTF_KEYUP,0);
}
void Y()
{
keybd_event((0x59),0,0,0);
keybd_event((0x59),0,KEYEVENTF_KEYUP,0);
}
void Z()
{
keybd_event((0x5A),0,0,0);
keybd_event((0x5A),0,KEYEVENTF_KEYUP,0);
}
void Space()
{
keybd_event(VK_SPACE,0,0,0);
keybd_event(VK_SPACE,0,KEYEVENTF_KEYUP,0);
}
void NumLock()
{
keybd_event(VK_NUMLOCK,0,0,0);
keybd_event(VK_NUMLOCK,0,KEYEVENTF_KEYUP,0);
}
void Plus()
{
keybd_event(VK_ADD,0,0,0);
keybd_event(VK_ADD,0,KEYEVENTF_KEYUP,0);
}
void Add()
{
keybd_event(VK_ADD,0,0,0);
keybd_event(VK_ADD,0,KEYEVENTF_KEYUP,0);
}
void Minus()
{
keybd_event(VK_SUBTRACT,0,0,0);
keybd_event(VK_SUBTRACT,0,KEYEVENTF_KEYUP,0);
}
void Subtract()
{
keybd_event(VK_SUBTRACT,0,0,0);
keybd_event(VK_SUBTRACT,0,KEYEVENTF_KEYUP,0);
}
void Divide()
{
keybd_event(VK_DIVIDE,0,0,0);
keybd_event(VK_DIVIDE,0,KEYEVENTF_KEYUP,0);
}
void F1()
{
keybd_event(VK_F1,0,0,0);
keybd_event(VK_F1,0,KEYEVENTF_KEYUP,0);
}
void F2()
{
keybd_event(VK_F2,0,0,0);
keybd_event(VK_F2,0,KEYEVENTF_KEYUP,0);
}
void F3()
{
keybd_event(VK_F3,0,0,0);
keybd_event(VK_F3,0,KEYEVENTF_KEYUP,0);
}
void F4()
{
keybd_event(VK_F4,0,0,0);
keybd_event(VK_F4,0,KEYEVENTF_KEYUP,0);
}
void F5()
{
keybd_event(VK_F5,0,0,0);
keybd_event(VK_F5,0,KEYEVENTF_KEYUP,0);
}
void F6()
{
keybd_event(VK_F6,0,0,0);
keybd_event(VK_F6,0,KEYEVENTF_KEYUP,0);
}
void F7()
{
keybd_event(VK_F7,0,0,0);
keybd_event(VK_F7,0,KEYEVENTF_KEYUP,0);
}
void F8()
{
keybd_event(VK_F8,0,0,0);
keybd_event(VK_F8,0,KEYEVENTF_KEYUP,0);
}
void F9()
{
keybd_event(VK_F9,0,0,0);
keybd_event(VK_F9,0,KEYEVENTF_KEYUP,0);
}
void F10()
{
keybd_event(VK_F10,0,0,0);
keybd_event(VK_F10,0,KEYEVENTF_KEYUP,0);
}
void F11()
{
keybd_event(VK_F11,0,0,0);
keybd_event(VK_F11,0,KEYEVENTF_KEYUP,0);
}
void F12()
{
keybd_event(VK_F12,0,0,0);
keybd_event(VK_F12,0,KEYEVENTF_KEYUP,0);
}
void Esc()
{
keybd_event(VK_ESCAPE,0,0,0);
keybd_event(VK_ESCAPE,0,KEYEVENTF_KEYUP,0);
}
}
namespace Mouse
{
void Left()
{
INPUT input[1] ;
input[0].type = INPUT_MOUSE ;
input[0].mi.dwFlags = MOUSEEVENTF_LEFTDOWN ;
input[0].mi.dwExtraInfo = 0 ;
SendInput ( 1, input, sizeof ( INPUT ) ) ;
input[0].mi.dwFlags = MOUSEEVENTF_LEFTUP ;
SendInput ( 1, input, sizeof ( INPUT ) ) ;
}
void Right()
{
INPUT input[1] ;
input[0].type = INPUT_MOUSE ;
input[0].mi.dwFlags = MOUSEEVENTF_RIGHTDOWN ;
input[0].mi.dwExtraInfo = 0 ;
SendInput ( 1, input, sizeof ( INPUT ) ) ;
input[0].mi.dwFlags = MOUSEEVENTF_RIGHTUP ;
SendInput ( 1, input, sizeof ( INPUT ) ) ;
}
void Hold_Left()
{
INPUT input[1] ;
input[0].type = INPUT_MOUSE ;
input[0].mi.dwFlags = MOUSEEVENTF_LEFTDOWN ;
input[0].mi.dwExtraInfo = 0 ;
SendInput ( 1, input, sizeof ( INPUT ) ) ;
}
void Hold_Right()
{
INPUT input[1] ;
input[0].type = INPUT_MOUSE ;
input[0].mi.dwFlags = MOUSEEVENTF_RIGHTDOWN ;
input[0].mi.dwExtraInfo = 0 ;
SendInput ( 1, input, sizeof ( INPUT ) ) ;
}
}
namespace KeyIsDown
{
bool A()
{
if(GetAsyncKeyState((0x41)))
return true;
else
return false;
}
bool B()
{
if(GetAsyncKeyState((0x42)))
return true;
else
return false;
}
bool C()
{
if(GetAsyncKeyState((0x43)))
return true;
else
return false;
}
bool D()
{
if(GetAsyncKeyState((0x44)))
return true;
else
return false;
}
bool E()
{
if(GetAsyncKeyState((0x45)))
return true;
else
return false;
}
bool F()
{
if(GetAsyncKeyState((0x46)))
return true;
else
return false;
}
bool G()
{
if(GetAsyncKeyState((0x47)))
return true;
else
return false;
}
bool H()
{
if(GetAsyncKeyState((0x48)))
return true;
else
return false;
}
bool I()
{
if(GetAsyncKeyState((0x49)))
return true;
else
return false;
}
bool J()
{
if(GetAsyncKeyState((0x4A)))
return true;
else
return false;
}
bool K()
{
if(GetAsyncKeyState((0x4B)))
return true;
else
return false;
}
bool L()
{
if(GetAsyncKeyState((0x4C)))
return true;
else
return false;
}
bool M()
{
if(GetAsyncKeyState((0x4D)))
return true;
else
return false;
}
bool N()
{
if(GetAsyncKeyState((0x4E)))
return true;
else
return false;
}
bool O()
{
if(GetAsyncKeyState((0x4F)))
return true;
else
return false;
}
bool P()
{
if(GetAsyncKeyState((0x50)))
return true;
else
return false;
}
bool Q()
{
if(GetAsyncKeyState((0x51)))
return true;
else
return false;
}
bool R()
{
if(GetAsyncKeyState((0x52)))
return true;
else
return false;
}
bool S()
{
if(GetAsyncKeyState((0x53)))
return true;
else
return false;
}
bool T()
{
if(GetAsyncKeyState((0x54)))
return true;
else
return false;
}
bool U()
{
if(GetAsyncKeyState((0x55)))
return true;
else
return false;
}
bool V()
{
if(GetAsyncKeyState((0x56)))
return true;
else
return false;
}
bool W()
{
if(GetAsyncKeyState((0x57)))
return true;
else
return false;
}
bool X()
{
if(GetAsyncKeyState((0x58)))
return true;
else
return false;
}
bool Y()
{
if(GetAsyncKeyState((0x59)))
return true;
else
return false;
}
bool Z()
{
if(GetAsyncKeyState((0x5A)))
return true;
else
return false;
}
bool Plus()
{
if(GetAsyncKeyState(VK_ADD))
return true;
else
return false;
}
bool Add()
{
if(GetAsyncKeyState(VK_ADD))
return true;
else
return false;
}
bool Minus()
{
if(GetAsyncKeyState(VK_SUBTRACT))
return true;
else
return false;
}
bool Subtract()
{
if(GetAsyncKeyState(VK_SUBTRACT))
return true;
else
return false;
}
bool Divide()
{
if(GetAsyncKeyState(VK_DIVIDE))
return true;
else
return false;
}
bool F1()
{
if(GetAsyncKeyState(VK_F1))
return true;
else
return false;
}
bool F2()
{
if(GetAsyncKeyState(VK_F2))
return true;
else
return false;
}
bool F3()
{
if(GetAsyncKeyState(VK_F3))
return true;
else
return false;
}
bool F4()
{
if(GetAsyncKeyState(VK_F4))
return true;
else
return false;
}
bool F5()
{
if(GetAsyncKeyState(VK_F5))
return true;
else
return false;
}
bool F6()
{
if(GetAsyncKeyState(VK_F6))
return true;
else
return false;
}
bool F7()
{
if(GetAsyncKeyState(VK_F7))
return true;
else
return false;
}
bool F8()
{
if(GetAsyncKeyState(VK_F8))
return true;
else
return false;
}
bool F9()
{
if(GetAsyncKeyState(VK_F9))
return true;
else
return false;
}
bool F10()
{
if(GetAsyncKeyState(VK_F10))
return true;
else
return false;
}
bool F11()
{
if(GetAsyncKeyState(VK_F11))
return true;
else
return false;
}
bool F12()
{
if(GetAsyncKeyState(VK_F12))
return true;
else
return false;
}
bool Esc()
{
if(GetAsyncKeyState(VK_ESCAPE))
return true;
else
return false;
}
}
namespace MouseIsDown
{
bool Left()
{
if(GetAsyncKeyState(VK_LBUTTON))
return true;
else
return false;
}
bool Right()
{
if(GetAsyncKeyState(VK_RBUTTON))
return true;
else
return false;
}
}
}
Here' some tutorials on how to use this sucker :
If you want to make your program to press the "a" key, you would type:
Input::Key::A();
if you want the program to do something if the "a" key was hit you would do this:
if(Input::KeyIsDown::A())
{
//DO SHIT
}
Same works for the mouse. Hope you find this use full.
*IMPORTANT*
You are free to use the header in your program, that's why I made it. Also you can add on to it which is why i pasted the whole source, (possibly gut the rest of the keys in there ) but please don't take full credit, i hate when people take all the credit of someone elses work...
Hope this comes in handy to some people