Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include <string>
- #include <vector>
- #include <utility>
- #include <iostream>
- #include <Windows.h>
- #pragma comment(lib, "winmm.lib")
- namespace ulib
- {
- namespace io
- {
- using time_ms = double;
- using position = std::pair<int, int>;
- using file_path = std::string;
- using msg = std::string;
- using key_code = unsigned short;
- using msg_vector = std::vector<msg>;
- enum input_type
- {
- KEYBOARD = INPUT_KEYBOARD,
- MOUSE = INPUT_MOUSE,
- };
- enum input_mode
- {
- KEYRELEASE = 0,
- KEYPRESS = KEYEVENTF_KEYUP,
- MOUSEPRESSLEFT = MOUSEEVENTF_LEFTDOWN,
- MOUSEPRESSRIGHT = MOUSEEVENTF_RIGHTDOWN,
- MOUSERELEASELEFT = MOUSEEVENTF_LEFTUP,
- MOUSERELEASERIGHT = MOUSEEVENTF_RIGHTUP,
- };
- enum sleep_modes
- {
- PREV = 0,
- CURR = 1,
- NEXT = 2,
- };
- struct key
- {
- key_code code;
- time_ms before = 0, during = 0, after = 0;
- input_mode mode;
- };
- struct Input
- {
- INPUT input_struct;
- Input(const key_code& code, const input_type& type, const input_mode& mode)
- {
- INPUT ip;
- ip.type = type;
- ip.ki.wScan = 0;
- ip.ki.time = 0;
- ip.ki.dwExtraInfo = 0;
- ip.ki.wVk = code;
- ip.ki.dwFlags = mode;
- SendInput(1, &ip, sizeof(INPUT));
- }
- };
- const msg GetMsg();
- const bool CheckKey(const key_code&);
- key MakeKey(const key_code&);
- key_code MakeKeyCode(const int&);
- void SetCursorPosition(const position&);
- const position GetCursorPosition();
- void SendMsg(const msg& to_send);
- void SendMsg(const msg_vector to_send);
- void SendSound(const file_path&);
- void PressKey(const key&);
- void PressKey(const key_code&, const time_ms& = 0, const time_ms& = 20, const time_ms& = 20);
- void HoldKey(const key&);
- void HoldKey(const key_code&, const time_ms& = 20, const time_ms& = 20);
- void ReleaseKey(const key&);
- void ReleaseKey(const key_code& = 20, const time_ms& = 20);
- void RightClick(const time_ms& = 20);
- void LeftClick(const time_ms& = 20);
- }
- using namespace io;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement