Advertisement
Guest User

Untitled

a guest
Apr 11th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.14 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. GetWindowRect(steam,&rect);
  146. cout << "screen: " << steam << endl << "RectBottom: " << rect.bottom << endl << "RectTop: " << rect.top << endl << "RectRight: " << rect.right << endl << "RectLeft: " << rect.left << endl;
  147.  
  148.  
  149.  
  150. POINT b;
  151. GetCursorPos(&b);
  152. cout << "x: " << b.x << " y: " << b.y << endl;
  153.  
  154. double fScreenWidth,fScreenHeight;
  155. getDesktopRes(fScreenWidth,fScreenHeight);
  156. double fx = (rect.right-usernamebox_width)*(65535.0f/fScreenWidth);
  157. double fy = (rect.bottom-usernamebox_height)*(65535.0f/fScreenHeight);
  158.  
  159. INPUT event;
  160. event.type = INPUT_MOUSE;
  161. event.mi.dx = fx;
  162. event.mi.dy = fy;
  163. event.mi.mouseData=0;
  164. event.mi.time=0;
  165. event.mi.dwFlags=(MOUSEEVENTF_ABSOLUTE|MOUSEEVENTF_MOVE|MOUSEEVENTF_LEFTDOWN|MOUSEEVENTF_LEFTUP);
  166. SendInput(1,&event,sizeof(INPUT));
  167.  
  168. PasteToClipboard(hej[stoi(number)-1].name);
  169. //Sleep(5000);
  170.  
  171. INPUT input[4];
  172. memset(input, 0, 4 * sizeof(input[0]));
  173. input[0].type = INPUT_KEYBOARD;
  174. input[1].type = INPUT_KEYBOARD;
  175. input[0].ki.wVk = VK_CONTROL;
  176. input[1].ki.wVk = towupper('v');
  177. input[2] = input[1];
  178. input[3] = input[0];
  179. input[2].ki.dwFlags = KEYEVENTF_KEYUP;
  180. input[3].ki.dwFlags = KEYEVENTF_KEYUP;
  181. SendInput(4, input, sizeof(input[0]));
  182.  
  183. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement