TestDlg.cpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. // TestDlg.cpp : 定义应用程序的类行为。
  2. //
  3. #include "stdafx.h"
  4. #include "TestDlg.h"
  5. #include "TestDlgDlg.h"
  6. #include "SDKInterface.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #endif
  10. // CTestDlgApp
  11. BEGIN_MESSAGE_MAP(CTestDlgApp, CWinApp)
  12. ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
  13. END_MESSAGE_MAP()
  14. // CTestDlgApp 构造
  15. CTestDlgApp::CTestDlgApp()
  16. {
  17. // 支持重新启动管理器
  18. m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART;
  19. // TODO: 在此处添加构造代码,
  20. // 将所有重要的初始化放置在 InitInstance 中
  21. }
  22. // 唯一的一个 CTestDlgApp 对象
  23. CTestDlgApp theApp;
  24. // CTestDlgApp 初始化
  25. BOOL CTestDlgApp::InitInstance()
  26. {
  27. // 如果一个运行在 Windows XP 上的应用程序清单指定要
  28. // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
  29. //则需要 InitCommonControlsEx()。 否则,将无法创建窗口。
  30. INITCOMMONCONTROLSEX InitCtrls;
  31. InitCtrls.dwSize = sizeof(InitCtrls);
  32. // 将它设置为包括所有要在应用程序中使用的
  33. // 公共控件类。
  34. InitCtrls.dwICC = ICC_WIN95_CLASSES;
  35. InitCommonControlsEx(&InitCtrls);
  36. CWinApp::InitInstance();
  37. #if 1
  38. AllocConsole(); // 开辟控制台;
  39. SetConsoleTitle(_T("调试输出")); // 设置控制台窗口标题;
  40. freopen("CONOUT$", "w+t", stdout); // 重定向输出;
  41. freopen("CONIN$", "r+t", stdin); // 重定向输入;
  42. HWND hWnd = NULL;
  43. hWnd = ::FindWindow(NULL, _T("调试输出"));
  44. if (hWnd)
  45. {
  46. if (!::SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE))
  47. {
  48. _tprintf(_T("前置设置失败\n"));
  49. }
  50. else
  51. {
  52. _tprintf(_T("前置设置成功\n"));
  53. }
  54. }
  55. #endif
  56. #if 1
  57. //////////////////////////////////////////////////////////////////////////
  58. SDKInterface tagSDK;
  59. if (!tagSDK.Init())
  60. {
  61. AfxMessageBox(_T("请关闭其他安卓相关的adb进程"));
  62. return FALSE;
  63. }
  64. while (!tagSDK.IsConnect() )
  65. {
  66. Sleep(500);
  67. }
  68. tagSDK.BrightScreen(true);
  69. tagSDK.HomeBtnPress();
  70. // 将微信切换至前台;
  71. tagSDK.SwitchForground();
  72. // 开始点赞任务;
  73. tagSDK.StartDianZan();
  74. Sleep(20000);
  75. // 停止点赞任务;
  76. tagSDK.StopDianZan();
  77. // 获取微信好友列表;
  78. //tagSDK.GetContactList();
  79. // 获取微信群列表;
  80. tagSDK.GetChatroomList();
  81. //////////////////////////////////////////////////////////////////////////
  82. #endif
  83. AfxEnableControlContainer();
  84. // 创建 shell 管理器,以防对话框包含
  85. // 任何 shell 树视图控件或 shell 列表视图控件。
  86. CShellManager *pShellManager = new CShellManager;
  87. // 激活“Windows Native”视觉管理器,以便在 MFC 控件中启用主题
  88. CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));
  89. // 标准初始化
  90. // 如果未使用这些功能并希望减小
  91. // 最终可执行文件的大小,则应移除下列
  92. // 不需要的特定初始化例程
  93. // 更改用于存储设置的注册表项
  94. // TODO: 应适当修改该字符串,
  95. // 例如修改为公司或组织名
  96. SetRegistryKey(_T("应用程序向导生成的本地应用程序"));
  97. CTestDlgDlg dlg;
  98. m_pMainWnd = &dlg;
  99. INT_PTR nResponse = dlg.DoModal();
  100. if (nResponse == IDOK)
  101. {
  102. // TODO: 在此放置处理何时用
  103. // “确定”来关闭对话框的代码
  104. }
  105. else if (nResponse == IDCANCEL)
  106. {
  107. // TODO: 在此放置处理何时用
  108. // “取消”来关闭对话框的代码
  109. }
  110. else if (nResponse == -1)
  111. {
  112. TRACE(traceAppMsg, 0, "警告: 对话框创建失败,应用程序将意外终止。\n");
  113. TRACE(traceAppMsg, 0, "警告: 如果您在对话框上使用 MFC 控件,则无法 #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS。\n");
  114. }
  115. // 删除上面创建的 shell 管理器。
  116. if (pShellManager != NULL)
  117. {
  118. delete pShellManager;
  119. }
  120. // 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序,
  121. // 而不是启动应用程序的消息泵。
  122. return FALSE;
  123. }