vs 挤房间工具

补上使用方法:
  1. 打开vs
  2. 选中房间,按alt+f1,开始挤房间
  3. 进入房间以后,按alt+f2停止
目前的bug:
  1. 有时候会弹出退出vs的窗口,这个时候请手动选择
  2. 必须放在桌面看的到的地方,不用置顶
下次版本预计加入功能:
  1. 修正bug1
  2. 添加个性化挤房间模式:顺序挤房间(并不针对单一房间)
  3. 自动升级
.h文件
  1. //---------------------------------------------------------------------------
  2. #ifndef Unit1H
  3. #define Unit1H
  4. //---------------------------------------------------------------------------
  5. #include <Classes.hpp>
  6. #include <Controls.hpp>
  7. #include <StdCtrls.hpp>
  8. #include <Forms.hpp>
  9. #include <ExtCtrls.hpp>
  10. #include "trayicon.h"
  11. #include <ImgList.hpp>
  12. #include <Menus.hpp>
  13. //---------------------------------------------------------------------------
  14. class TForm1 : public TForm
  15. {
  16. __published:    // IDE-managed Components
  17.     TTimer *Timer1;
  18.     TTrayIcon *TrayIcon1;
  19.     TPopupMenu *PopupMenu1;
  20.     TImageList *ImageList1;
  21.     TMenuItem *N1;
  22.     TMenuItem *ALTF21;
  23.     TMenuItem *N2;
  24.     void __fastcall Button1Click(TObject *Sender);
  25.     void __fastcall Timer1Timer(TObject *Sender);
  26.     void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
  27.     void __fastcall N1Click(TObject *Sender);
  28.     void __fastcall ALTF21Click(TObject *Sender);
  29.     void __fastcall FormShow(TObject *Sender);
  30.     void __fastcall N2Click(TObject *Sender);
  31. private:    // User declarations
  32.     int StartHotKeyId;
  33.     int StopHotKeyId;
  34.     TPoint pt;
  35.     void __fastcall HotKeyDown(TMessage &Msg);
  36. public:     // User declarations
  37.     __fastcall TForm1(TComponent* Owner);
  38. BEGIN_MESSAGE_MAP
  39.     VCL_MESSAGE_HANDLER(WM_HOTKEY, TMessage, HotKeyDown);
  40. END_MESSAGE_MAP(TForm);
  41. };
  42. //---------------------------------------------------------------------------
  43. extern PACKAGE TForm1 *Form1;
  44. //---------------------------------------------------------------------------
  45. #endif
 .c文件
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "Unit1.h"
  5. //---------------------------------------------------------------------------
  6. #pragma package(smart_init)
  7. #pragma link "trayicon"
  8. #pragma resource "*.dfm"
  9. TForm1 *Form1;
  10. //---------------------------------------------------------------------------
  11. __fastcall TForm1::TForm1(TComponent* Owner)
  12.     : TForm(Owner)
  13. {
  14.     StartHotKeyId = GlobalAddAtom("StartVSLoader")-0xC000; 
  15.     StopHotKeyId = GlobalAddAtom("StopVSLoader")-0xC000;
  16.     RegisterHotKey(Handle , StartHotKeyId , MOD_ALT,VK_F1);
  17.     RegisterHotKey(Handle , StopHotKeyId  , MOD_ALT,VK_F2);
  18.     Application->ShowMainForm = false;
  19. }
  20. //---------------------------------------------------------------------------
  21. void __fastcall TForm1::HotKeyDown(TMessage &Msg)
  22. {
  23.     if( (Msg.LParamLo == MOD_ALT)&& (Msg.LParamHi == VK_F1) ){
  24.         Timer1->Enabled = true;
  25.         TrayIcon1->Animate = true;
  26.         GetCursorPos(&pt);
  27.     }
  28.     if( (Msg.LParamLo == MOD_ALT)&& (Msg.LParamHi == VK_F2) ){
  29.         Timer1->Enabled = false;
  30.         TrayIcon1->Animate = false;
  31.     }
  32. }
  33. //---------------------------------------------------------------------------
  34. void __fastcall TForm1::Button1Click(TObject *Sender)
  35. {
  36.     //HWND listview =   FindWindow(NULL, "VS竞技游戏平台");//
  37.     //TPoint pt;
  38.     //GetCursorPos(&pt);
  39.     Timer1->Enabled = true;
  40. }
  41. //---------------------------------------------------------------------------
  42. void __fastcall TForm1::Timer1Timer(TObject *Sender)
  43. {
  44.     Timer1->Enabled = false;
  45.     TPoint tmp;
  46.     GetCursorPos(&tmp);
  47.     SetCursorPos(pt.x,pt.y);
  48.     HWND win = NULL;
  49.     win =FindWindow(NULL, "VS竞技游戏平台");
  50.     if(win){
  51.         keybd_event(VK_ESCAPE ,0,KEYEVENTF_EXTENDEDKEY   |   0,0   );
  52.         keybd_event(VK_ESCAPE ,0,KEYEVENTF_EXTENDEDKEY   |   KEYEVENTF_KEYUP,0);   
  53.     }
  54.     win =FindWindow(NULL, "VSClient");
  55.     if(win){
  56.         keybd_event(VK_ESCAPE ,0,KEYEVENTF_EXTENDEDKEY   |   0,0   );
  57.         keybd_event(VK_ESCAPE ,0,KEYEVENTF_EXTENDEDKEY   |   KEYEVENTF_KEYUP,0);   
  58.     }
  59.     if(win == NULL){
  60.         mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
  61.         mouse_event(MOUSEEVENTF_LEFTUP  ,0,0,0,0);
  62. //bug001::现在vs版本对应
  63.         mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
  64.         mouse_event(MOUSEEVENTF_LEFTUP  ,0,0,0,0);
  65. //bug001::end
  66.     }
  67.     SetCursorPos(tmp.x, tmp.y);
  68.     Timer1->Enabled = true;
  69. }
  70. //---------------------------------------------------------------------------
  71. void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
  72. {
  73.     UnregisterHotKey(Handle , StartHotKeyId);
  74.     UnregisterHotKey(Handle , StopHotKeyId);
  75. }
  76. //---------------------------------------------------------------------------
  77. void __fastcall TForm1::N1Click(TObject *Sender)
  78. {
  79.     Timer1->Enabled = true;
  80.     TrayIcon1->Animate = true;
  81. }
  82. //---------------------------------------------------------------------------
  83. void __fastcall TForm1::ALTF21Click(TObject *Sender)
  84. {
  85.     Timer1->Enabled = false;
  86.     TrayIcon1->Animate = false;
  87. }
  88. //---------------------------------------------------------------------------
  89. void __fastcall TForm1::FormShow(TObject *Sender)
  90. {
  91.     TrayIcon1->Minimize();
  92. }
  93. //---------------------------------------------------------------------------
  94. void __fastcall TForm1::N2Click(TObject *Sender)
  95. {
  96.     Close();
  97. }
  98. //---------------------------------------------------------------------------

代码和可执行文件下载地址:http://download.csdn.net/source/567156

 

你可能感兴趣的:(游戏,timer,null,工具,button,imagelist)