Assist.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #ifndef __ASSIST__
  2. #define __ASSIST__
  3. #pragma once
  4. #include <map>
  5. #include <string>
  6. #include <vector>
  7. #include <tchar.h>
  8. #include <windows.h>
  9. #include <Shlwapi.h>
  10. #pragma comment(lib,"Shlwapi.lib") /*需要加上此行才可以正确link,VC6.0*/
  11. #include <tlhelp32.h>
  12. namespace Assist {
  13. extern int titleBarHeight;
  14. extern int frameWidth;
  15. extern TCHAR g_szCurModuleFileName[MAX_PATH];
  16. extern TCHAR g_szCurModuleDir[MAX_PATH];
  17. extern TCHAR g_szCurModulePath[MAX_PATH];
  18. extern TCHAR g_szFna[_MAX_FNAME];
  19. extern TCHAR g_szExt[_MAX_EXT];
  20. extern TCHAR g_szAssistConfig[MAX_PATH];
  21. extern std::string g_strAppdir;
  22. extern std::string g_strGameDir;
  23. extern TCHAR g_szGameApp[MAX_PATH];
  24. typedef struct __HWNINFO__ {
  25. DWORD dwId; // 控件id;
  26. std::string strWinText; // 控件文本;
  27. std::string strClassName; // 控件类名;
  28. HWND hwnd; // 控件句柄;
  29. }WinInfo, * pWinInfo;
  30. extern std::vector<WinInfo> g_vtWndInfo;
  31. void Init();
  32. // 设置窗口前置;
  33. void SetWindowForeground(HWND hWnd);
  34. // 判断窗口是否前置;
  35. bool IsWindowForeground(HWND hWnd);
  36. bool StartApp(const TCHAR* szAppPath, const TCHAR* szAppArgs = NULL);
  37. void CloseProcess(LPCTSTR lpProcessName);
  38. // 根据进程名获取进程pid;
  39. DWORD GetProcessId(LPCTSTR lpProcessName );
  40. void GetAllProcessId(std::vector<DWORD>& vtPid, LPCTSTR lpProcessName);
  41. // 根据进程pid获取进程对应程序的窗口句柄;
  42. HWND GetProcessMainWnd(const DWORD& dwTagetProcessId, LPCTSTR lpTagetWndName);
  43. // 获取指定进程名的进程主窗口;
  44. HWND GetProcessMainWnd(LPCTSTR lpProcessName, LPCTSTR lpTagetWndName);
  45. // 根据进程pid获取进程类名对应的窗口;
  46. HWND GetClassNameWnd(const DWORD& dwTagetProcessId, LPCTSTR lpTagetClassName);
  47. // 根据进程pid获取进程窗口名对应的窗口;
  48. HWND GetWindowNameWnd(const DWORD& dwTagetProcessId, LPCTSTR lpTagetWindowName);
  49. // 获取符合要求的窗口进程;
  50. HWND GetWindowNameWnd(LPCTSTR lpProcessName, LPCTSTR lpTagetWindowName);
  51. void WriteTextLog(const TCHAR* format, ...);
  52. };
  53. #endif // __ASSIST__