Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. #include <filesystem>
  5. #include <chrono>
  6. #include <thread>
  7. #include <windows.h>
  8. using namespace std;
  9.  
  10. void PrintText(string log_copy) {
  11. string line;
  12. size_t found = line.find("@");
  13. ifstream myFile;
  14. myFile.open(log_copy);
  15. getline(myFile, line);
  16. if (found) {
  17. cout << line << endl;
  18. }
  19. myFile.close();
  20. }
  21.  
  22. void RefreshText(const filesystem::path& filename) {
  23. HWND hwnd;
  24. hwnd = FindWindow(NULL, "Path of Exile");
  25. string s;
  26. string log_copy = "C:\\Users\\Toffer\\Desktop\\testfile.txt";
  27. auto file_time = filesystem::last_write_time(filename);
  28.  
  29. while (true) {
  30. if (hwnd != 0) {
  31. if (filesystem::last_write_time(filename) != file_time) {
  32. file_time = filesystem::last_write_time(filename);
  33. filesystem::copy_file(filename, log_copy, filesystem::copy_options::overwrite_existing);
  34. PrintText(log_copy);
  35. this_thread::sleep_for(chrono::milliseconds(100));
  36. RefreshText("C:\\Users\\Toffer\\Desktop\\extreme.txt");
  37. break;
  38. }
  39. }
  40. if (hwnd == 0) {
  41. cout << "PoE is not running, launch it and restart this program." << endl;
  42. cout << "If you wish to close this program, press ENTER.";
  43. string s;
  44. getline(cin, s);
  45. break;
  46. }
  47. }
  48. }
  49.  
  50. int main() {
  51. RefreshText("C:\\Users\\Toffer\\Desktop\\extreme.txt");
  52.  
  53. return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement