Guest User

Untitled

a guest
Apr 10th, 2018
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.03 KB | None | 0 0
  1. #define _WIN32_WINNT 0x0500
  2.  
  3. #include <windows.h>
  4. #include <iostream>
  5. #include <fstream>
  6. #include <vector>
  7. #include <algorithm>
  8. #include <sstream>
  9. #include <shellapi.h>
  10. #include <Lmcons.h>
  11. #include <cstring>
  12. #include <tlhelp32.h>
  13. #include <string.h>
  14. #include <stdlib.h>
  15.  
  16.  
  17. const int number_max = 100;
  18. const int usernamebox_width = 100;
  19. const int usernamebox_height = 225;
  20.  
  21. using namespace std;
  22.  
  23. struct userpw{
  24. userpw(string _name, string string_pw):
  25. name(_name),
  26. pw(string_pw) {}
  27.  
  28. string name;
  29. string pw;
  30. };
  31.  
  32. bool PasteToClipboard(const std::string& text)
  33. {
  34. bool succeeded = false ;
  35.  
  36. if ( HANDLE clipdata = GlobalAlloc(GMEM_MOVEABLE,text.length()+1)){
  37. if (HGLOBAL ptr = GlobalLock(clipdata)){
  38. std::memcpy(ptr,text.data(),text.length()+1);
  39. GlobalUnlock(ptr);
  40.  
  41. if (OpenClipboard(NULL)){
  42. if(EmptyClipboard() && SetClipboardData(CF_TEXT,clipdata)){
  43. succeeded=true;
  44. CloseClipboard();
  45. }
  46. }
  47. }
  48. if (!succeeded){
  49. GlobalFree(clipdata);
  50. }
  51. }
  52.  
  53. return succeeded ;
  54. }
  55.  
  56.  
  57.  
  58. bool checkIfClosed()
  59. {
  60. bool ret = true;
  61. char procName[] = "Steam.exe";
  62. PROCESSENTRY32 entry;
  63. entry.dwSize = sizeof(PROCESSENTRY32);
  64.  
  65. HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
  66.  
  67. if (Process32First(snapshot, &entry)){
  68. while (Process32Next(snapshot,&entry)){
  69. if (strcmp(entry.szExeFile, procName) == 0){
  70. HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, entry.th32ProcessID);
  71. TerminateProcess(hProcess,1);
  72. WaitForSingleObject(hProcess,INFINITE);
  73. CloseHandle(hProcess);
  74. ret = false;
  75. break;
  76. }
  77. }
  78. }
  79. CloseHandle(snapshot);
  80.  
  81. return ret;
  82. }
  83.  
  84. void getDesktopRes(double& horizontal, double& vertical)
  85. {
  86. RECT desktop;
  87. const HWND hDesktop = GetDesktopWindow();
  88. GetWindowRect(hDesktop, &desktop);
  89. horizontal = desktop.right;
  90. vertical = desktop.bottom;
  91. }
  92.  
  93.  
  94.  
  95. int main()
  96. {
  97. char username[UNLEN+1];
  98. DWORD username_len = UNLEN+1;
  99. GetUserName(username, &username_len);
  100. HWND m_hWnd;
  101.  
  102. vector<userpw> hej;
  103. string user;
  104. fstream obj("C:\\Users\\wille\\Desktop\\password\\pws.txt", fstream::in | fstream::out);
  105. fstream obj2("C:\\Users\\wille\\Desktop\\password\\direction.txt", fstream::in);
  106.  
  107. while(getline(obj,user)){
  108.  
  109. size_t found = user.find(' ');
  110. hej.push_back(userpw(user.substr(0,found),user.substr(found+1,user.length())));
  111.  
  112. }
  113.  
  114. int Count = 1;
  115. for (vector<userpw>::iterator itr = hej.begin(); itr != hej.end(); ++itr){;
  116. cout << "#" << Count << "\nUser: " << itr->name << "\npassword: " << itr->pw << endl << endl;
  117. Count++;
  118. }
  119.  
  120. string number;
  121. do{
  122. cout << "Select a number please: \n";
  123. getline(cin,number);
  124.  
  125. }while(!(stoi( number ) > 0 && stoi( number ) < number_max));
  126.  
  127.  
  128. stringstream path;
  129. string path_defined;
  130. path << "C:\\Program Files (x86)\\Steam\\Steam.exe";
  131.  
  132. if (obj2.is_open()){
  133. getline(obj2,path_defined);
  134. }
  135.  
  136. //checkIfClosed();
  137. //ShellExecute( m_hWnd,"open",(obj2.is_open() ? path_defined.c_str() : path.str().c_str()),"","", SW_SHOW );
  138. string _str = "Logga in – Steam";
  139. HWND steam = FindWindow(NULL,_str.c_str());
  140. RECT rect;
  141. SetForegroundWindow(steam);
  142. SetFocus(steam);
  143. SetActiveWindow(steam);
  144. ShowWindow(steam,SW_SHOW);
  145. Sleep(250);
  146. cout << GetWindowRect(steam,&rect) << endl;
  147. cout << "screen: " << steam << endl << "RectBottom: " << rect.bottom << endl << "RectTop: " << rect.top << endl << "RectRight: " << rect.right << endl << "RectLeft: " << rect.left << endl;
  148.  
  149.  
  150.  
  151. POINT b;
  152. GetCursorPos(&b);
  153. cout << "x: " << b.x << " y: " << b.y << endl;
  154.  
  155. double fScreenWidth,fScreenHeight;
  156. getDesktopRes(fScreenWidth,fScreenHeight);
  157. double fx = (rect.right-usernamebox_width)*(65535.0f/fScreenWidth);
  158. double fy = (rect.bottom-usernamebox_height)*(65535.0f/fScreenHeight);
  159.  
  160. INPUT event;
  161. event.type = INPUT_MOUSE;
  162. event.mi.dx = fx;
  163. event.mi.dy = fy;
  164. event.mi.mouseData=0;
  165. event.mi.time=0;
  166. event.mi.dwFlags=(MOUSEEVENTF_ABSOLUTE|MOUSEEVENTF_MOVE|MOUSEEVENTF_LEFTDOWN|MOUSEEVENTF_LEFTUP);
  167. SendInput(1,&event,sizeof(INPUT));
  168.  
  169. PasteToClipboard(hej[stoi(number)-1].name);
  170. Sleep(5000);
  171.  
  172. INPUT ip[4];
  173. ip[0].type = INPUT_KEYBOARD;
  174. ip[0].ki.wScan = 0;
  175. ip[0].ki.dwFlags = 0;
  176. ip[0].ki.wVk = VK_CONTROL;
  177. ip[0].ki.time = 0;
  178. ip[0].ki.dwExtraInfo = 0;
  179.  
  180. ip[1].type = INPUT_KEYBOARD;
  181. ip[1].ki.wScan = 0;
  182. ip[1].ki.dwFlags = 0;
  183. ip[1].ki.wVk = 0x56;
  184. ip[1].ki.time = 0;
  185. ip[1].ki.dwExtraInfo = 0;
  186.  
  187. ip[2].type = INPUT_KEYBOARD;
  188. ip[2].ki.wScan = 0;
  189. ip[2].ki.dwFlags = KEYEVENTF_KEYUP;
  190. ip[2].ki.wVk = VK_CONTROL;
  191. ip[2].ki.time = 0;
  192. ip[2].ki.dwExtraInfo = 0;
  193.  
  194. ip[3].type = INPUT_KEYBOARD;
  195. ip[3].ki.wScan = 0;
  196. ip[3].ki.dwFlags = KEYEVENTF_KEYUP;
  197. ip[3].ki.wVk = 0x56;
  198. ip[3].ki.time = 0;
  199. ip[3].ki.dwExtraInfo = 0;
  200.  
  201. SendInput((sizeof(ip)/sizeof(INPUT)), ip, sizeof(INPUT));
  202.  
  203.  
  204.  
  205.  
  206.  
  207. GetCursorPos(&b);
  208. cout << "x: " << b.x << " y: " << b.y << endl;
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215. /* ip.ki.dwFlags = 0; // 0 for key press
  216. ip.ki.wVk = VK_RETURN;
  217. SendInput(1, &ip, sizeof(INPUT));
  218. */
  219.  
  220. /* while (1){ 1324 476
  221. GetCursorPos(&b);
  222. cout << "X: " << b.x << " Y: " << b.y << endl;
  223. }
  224. return 0;
  225. */
  226.  
  227.  
  228.  
  229.  
  230. }
Add Comment
Please, Sign In to add comment