96辅助游戏论坛 - 辅助工具|www.96fuzhu.com

 找回密码
 立即注册
查看: 2941|回复: 0

LOL地图放大工具

[复制链接]
发表于 2020-6-16 04:04 | 显示全部楼层 |阅读模式
使用Windows放大API,目前仅在1366x768分辨率下进行了测试。 您必须将游戏设置为全屏无边框。
您可以使用`键(波浪号)来切换叠加层。


源代码:

  1. // Ensure that the following definition is in effect before winuser.h is included.
  2. #define _WIN32_WINNT 0x0501   

  3. #include <windows.h>
  4. #include <wincodec.h>
  5. #include <magnification.h>

  6. // Global variables and strings.
  7. HINSTANCE           hInst;
  8. float               MagFactor;
  9. const TCHAR         WindowClassName[]= TEXT("MagnifierWindow");
  10. const TCHAR         WindowTitle[]= TEXT("Screen Magnifier");
  11. const UINT          timerInterval = 16; // close to the refresh rate @60hz
  12. HWND                hwndMag;
  13. HWND                hwndView;
  14. HWND                hwndHost;
  15. RECT                magWindowRect;
  16. HHOOK               hHook;
  17. bool                showMagnifier = true;

  18. // Forward declarations.
  19. LRESULT CALLBACK    LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam);
  20. ATOM                RegisterHostWindowClass(HINSTANCE hInstance);
  21. BOOL                SetupMagnifier(HINSTANCE hinst);
  22. LRESULT CALLBACK    WndProc(HWND, UINT, WPARAM, LPARAM);
  23. void CALLBACK       UpdateMagWindow(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime);
  24. float               GetMagnificationFactor();

  25. //
  26. // FUNCTION: WinMain()
  27. //
  28. // PURPOSE: Entry point for the application.
  29. //
  30. int APIENTRY WinMain(HINSTANCE hInstance,
  31.                      HINSTANCE /*hPrevInstance*/,
  32.                      LPSTR     /*lpCmdLine*/,
  33.                      int       nCmdShow)
  34. {
  35.     if (FALSE == MagInitialize())
  36.     {
  37.         return 0;
  38.     }
  39.     if (FALSE == SetupMagnifier(hInstance))
  40.     {
  41.         return 0;
  42.     }

  43.     ShowWindow(hwndHost, nCmdShow);
  44.     UpdateWindow(hwndHost);
  45.     //ShowCursor(false);
  46.     // Create a timer to update the control.
  47.     UINT_PTR timerId = SetTimer(hwndHost, 0, timerInterval, UpdateMagWindow);

  48.     hHook = SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc, hInstance, 0);

  49.     // Main message loop.
  50.     MSG msg;
  51.     while (GetMessage(&msg, NULL, 0, 0))
  52.     {
  53.         TranslateMessage(&msg);
  54.         DispatchMessage(&msg);
  55.     }

  56.     // Shut down.
  57.     KillTimer(NULL, timerId);
  58.     MagUninitialize();
  59.     return (int) msg.wParam;
  60. }


  61. LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
  62. {
  63.     PKBDLLHOOKSTRUCT press = (PKBDLLHOOKSTRUCT)lParam;
  64.     if (wParam == WM_KEYDOWN && press->vkCode == VK_OEM_3) {
  65.         showMagnifier = !showMagnifier;

  66.         if (showMagnifier) {
  67.             ShowWindow(hwndHost, SW_SHOW);
  68.         }
  69.         else {
  70.             ShowWindow(hwndHost, SW_HIDE);
  71.         }
  72.     }
  73.     return CallNextHookEx(hHook, nCode, wParam, lParam);
  74. }


  75. //
  76. // FUNCTION: HostWndProc()
  77. //
  78. // PURPOSE: Window procedure for the window that hosts the magnifier control.
  79. //
  80. LRESULT CALLBACK HostWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  81. {
  82.     switch (message)
  83.     {
  84.     case WM_KEYDOWN:
  85.         if (wParam == VK_ESCAPE)
  86.         {
  87.             ShowCursor(true);
  88.             PostQuitMessage(0);
  89.             break;
  90.         }

  91.      case WM_SYSCOMMAND:
  92.         return DefWindowProc(hWnd, message, wParam, lParam);
  93.         break;

  94.     case WM_DESTROY:
  95.         ShowCursor(true);
  96.         PostQuitMessage(0);
  97.         break;

  98.     case WM_SIZE:
  99.         if ( hwndMag != NULL )
  100.         {
  101.             GetClientRect(hWnd, &magWindowRect);
  102.             // Resize the control to fill the window.
  103.             SetWindowPos(hwndMag, NULL,
  104.                 magWindowRect.left, magWindowRect.top, magWindowRect.right, magWindowRect.bottom, 0);
  105.         }
  106.         break;

  107.     default:
  108.         return DefWindowProc(hWnd, message, wParam, lParam);
  109.     }
  110.     return 0;  
  111. }

  112. //
  113. //  FUNCTION: RegisterHostWindowClass()
  114. //
  115. //  PURPOSE: Registers the window class for the window that contains the magnification control.
  116. //
  117. ATOM RegisterHostWindowClass(HINSTANCE hInstance)
  118. {
  119.     WNDCLASSEX wcex = {};

  120.     wcex.cbSize = sizeof(WNDCLASSEX);
  121.     wcex.style          = CS_HREDRAW | CS_VREDRAW;
  122.     wcex.lpfnWndProc    = HostWndProc;
  123.     wcex.hInstance      = hInstance;
  124.     wcex.hCursor        = LoadCursor(NULL, IDC_ARROW);
  125.     wcex.hbrBackground  = (HBRUSH)(1 + COLOR_BTNFACE);
  126.     wcex.lpszClassName  = WindowClassName;

  127.     return RegisterClassEx(&wcex);
  128. }

  129. //
  130. // FUNCTION: SetupMagnifier
  131. //
  132. // PURPOSE: Creates the windows and initializes magnification.
  133. //
  134. BOOL SetupMagnifier(HINSTANCE hinst)
  135. {
  136.     int sx = GetSystemMetrics(SM_CXSCREEN);
  137.     int sy = GetSystemMetrics(SM_CYSCREEN);

  138.     // Create the host window.
  139.     RegisterHostWindowClass(hinst);
  140.     hwndHost = CreateWindowEx(WS_EX_TOPMOST | WS_EX_LAYERED | WS_EX_TRANSPARENT,
  141.         WindowClassName, WindowTitle,
  142.         WS_POPUP | WS_CLIPCHILDREN,
  143.         sx / 2 + 100, sy / 2 - 180, 360, 360, NULL, NULL, hInst, NULL);
  144.     if (!hwndHost)
  145.     {
  146.         return FALSE;
  147.     }
  148.     SetLayeredWindowAttributes(hwndHost, 0, (255 * 35) / 100, LWA_ALPHA);

  149.     // Create a magnifier control that fills the client area.
  150.     GetClientRect(hwndHost, &magWindowRect);
  151.     hwndMag = CreateWindow(WC_MAGNIFIER, TEXT("MagnifierWindow"),
  152.         WS_CHILD | MS_SHOWMAGNIFIEDCURSOR | WS_VISIBLE ,
  153.         magWindowRect.left, magWindowRect.top, magWindowRect.right, magWindowRect.bottom, hwndHost, NULL, hInst, NULL );
  154.     if (!hwndMag)
  155.     {
  156.         return FALSE;
  157.     }

  158.     MagFactor = GetMagnificationFactor();
  159.     // Set the magnification factor.
  160.     MAGTRANSFORM matrix;
  161.     memset(&matrix, 0, sizeof(matrix));
  162.     matrix.v[0][0] = MagFactor;
  163.     matrix.v[1][1] = MagFactor;
  164.     matrix.v[2][2] = 1.0f;

  165.     BOOL ret = MagSetWindowTransform(hwndMag, &matrix);
  166.    
  167.     return ret;  
  168. }


  169. //
  170. // FUNCTION: UpdateMagWindow()
  171. //
  172. // PURPOSE: Sets the source rectangle and updates the window. Called by a timer.
  173. //
  174. void CALLBACK UpdateMagWindow(HWND /*hwnd*/, UINT /*uMsg*/, UINT_PTR /*idEvent*/, DWORD /*dwTime*/)
  175. {
  176.     if (showMagnifier) {
  177.         RECT sourceRect;
  178.         sourceRect.left = 1181;
  179.         sourceRect.top = 578;
  180.         sourceRect.right = 1181 + 181;
  181.         sourceRect.bottom = 578 + 181;

  182.         // Set the source rectangle for the magnifier control.
  183.         MagSetWindowSource(hwndMag, sourceRect);

  184.         // Reclaim topmost status, to prevent unmagnified menus from remaining in view.
  185.         SetWindowPos(hwndHost, HWND_TOPMOST, 0, 0, 0, 0,
  186.             SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);

  187.         // Force redraw.
  188.         InvalidateRect(hwndMag, NULL, TRUE);
  189.     }
  190. }


  191. float GetMagnificationFactor(){
  192.     // For simplicity, the sample uses a constant magnification factor.
  193.     return 2.0f;
  194. }
复制代码


LOL地图放大工具.zip

6 KB, 下载次数: 2

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|96辅助游戏论坛

GMT+8, 2025-1-31 23:59 , Processed in 0.090652 second(s), 23 queries .

Powered by Discuz! X3.4

© 2016-2023 Comsenz Inc.

快速回复 返回顶部 返回列表