daily pastebin goal
44%
SHARE
TWEET

Untitled

a guest Oct 16th, 2018 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. bool SetKey(UINT message, WPARAM wParam, CVar *cVar );
  2. BOOL GetKeyName(UINT message, UINT nVK, string* strOut);
  3.  
  4. bool CVarManager::SetKey(UINT message, WPARAM wParam, CVar *cVar )
  5. {
  6.     static bool set = true;
  7.  
  8.     int iKey = 0;
  9.  
  10.     switch (message)
  11.     {
  12.     case WM_LBUTTONDOWN:
  13.         iKey = VK_LBUTTON;
  14.         set = false;
  15.         break;
  16.     case WM_RBUTTONDOWN:
  17.         iKey = VK_RBUTTON;
  18.         set = false;   
  19.         break;
  20.     case WM_MBUTTONDOWN:
  21.         iKey = VK_MBUTTON;
  22.         set = false;
  23.         break;
  24.     case WM_XBUTTONDOWN:
  25.         iKey = VK_XBUTTON1;
  26.         set = false;
  27.         break;
  28.     case WM_KEYDOWN:
  29.         if(wParam >= 'A' && wParam <= 'Z' || wParam >= '0' && wParam <= '9')
  30.             iKey = (int)VkKeyScanEx(wParam,GetKeyboardLayout(0));
  31.         else
  32.             iKey = (int)wParam;
  33.         set = false;
  34.         break;
  35.     default:
  36.         break;
  37.     }
  38.     if (set == false)
  39.     {
  40.         string strKey;
  41.         GetKeyName(message,wParam,&strKey);
  42.         if (message == WM_KEYDOWN )
  43.             iKey = (int)wParam;
  44.         cVar->SetInteger(iKey);
  45.         cVar->SetString(strKey);
  46.         return true;
  47.     }
  48.     return false;
  49. }
  50. BOOL CVarManager::GetKeyName( UINT message, UINT nVK, string* strOut )
  51. {
  52.     BOOL bResult = FALSE;
  53.     char keystr [20] = "";
  54.     switch(nVK)
  55.     {
  56.         // Keys which are "extended" (except for Return which is Numeric Enter as extended)
  57.     case VK_LBUTTON:
  58.         strOut->assign("MOUSE L");
  59.         bResult = true;
  60.         break;
  61.     case VK_RBUTTON :
  62.         strOut->assign("MOUSE R");
  63.         bResult = true;
  64.         break;
  65.     case VK_MBUTTON:
  66.         strOut->assign("MOUSE M");
  67.         bResult = true;
  68.         break;
  69.     case VK_XBUTTON1:
  70.         strOut->assign("MOUSE X");
  71.         bResult = true;
  72.         break;
  73.     default:
  74.         break;
  75.     }
  76.     if (bResult)
  77.         return bResult;
  78.  
  79.     switch (message)
  80.     {
  81.     case WM_LBUTTONDOWN:
  82.         strOut->assign("MOUSE L");
  83.         bResult = true;
  84.         break;
  85.     case WM_RBUTTONDOWN :
  86.         strOut->assign("MOUSE R");
  87.         bResult = true;
  88.         break;
  89.     case WM_MBUTTONDOWN:
  90.         strOut->assign("MOUSE M");
  91.         bResult = true;
  92.         break;
  93.     case WM_XBUTTONDOWN:
  94.         strOut->assign("MOUSE X");
  95.         bResult = true;
  96.         break;
  97.     case WM_KEYDOWN:
  98.         {
  99.             UINT nScanCode = MapVirtualKeyEx(nVK, /*MAPVK_VSC_TO_VK*/ MAPVK_VK_TO_VSC, GetKeyboardLayout(0));
  100.             switch(nVK)
  101.             {
  102.                 // Keys which are "extended" (except for Return which is Numeric Enter as extended)
  103.             case VK_INSERT:
  104.             case VK_DELETE:
  105.             case VK_HOME:
  106.             case VK_END:
  107.             case VK_NEXT:  // Page down
  108.             case VK_PRIOR: // Page up
  109.             case VK_LEFT:
  110.             case VK_RIGHT:
  111.             case VK_UP:
  112.             case VK_DOWN:
  113.                 //          case VK_MENU:
  114.                 nScanCode |= 0x100; // Add extended bit
  115.             }
  116.             // GetKeyNameText() expects the scan code to be on the same format as WM_KEYDOWN
  117.             // Hence the left shift
  118.             bResult = GetKeyNameText(nScanCode << 16,keystr , 19);
  119.             strOut->assign(keystr);
  120.         }
  121.         break;
  122.     default:
  123.         strOut->assign("Unknown");
  124.         break;
  125.     }
  126.     return bResult;
  127. }
  128.  
  129.  
  130.  
  131.     Vars Cvars = CVarManager::Instance()->Cvars;
  132.     if (!Cvars[CVAR_AimKey]->GetBoolean())
  133.     {
  134.         CVar *cVar = Cvars[CVAR_AimKey];
  135.         cVar->SetString("");
  136.         if (GetAsyncKeyState(VK_MENU)&1)
  137.             CVarManager::Instance()->SetKey(WM_KEYDOWN,VK_MENU,cVar);
  138.         else if (uMsg == WM_KEYDOWN || (uMsg >=WM_MOUSEFIRST && uMsg <= WM_MOUSELAST) )
  139.             CVarManager::Instance()->SetKey(uMsg,wParam, cVar);
  140.  
  141.         Cvars[CVAR_AimBot]->SetBoolean(false);
  142.  
  143.         return CallWindowProc(g_pfnWndProc, hWnd, uMsg, wParam, lParam);
  144.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top