Перейти к содержанию

приложение отливливающее нажатия доп. кнопок на мышке


Рекомендуемые сообщения

хочу сделать сабж висящий в трее, мышка a4tech x718bk, сбоку 2 кнопки (4 и 5), их кодов не знаю (гуглил), да и не знаю как писать эвент, отлавливающий нажатие (по таймеру?)

вообщем надо чтобы при нажатии кнопок (в полноэкранных приложениях) прога это засекала, ну и код соответствующий выполнялся

как сделать? на билдере6

накидайте ссылок хотя-бы пожолосто

http://msdn.microsoft.com/en-us/library/ms927178.aspx тут вроде подходящих кодов нету

Ссылка на комментарий

кодов мышки не нашел, сделал на клаву


#include
#pragma hdrstop
#include "Unit1.h"
#include
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
AnsiString dir = ExtractFilePath(ParamStr(0));
TIniFile *Ini = new TIniFile(dir+"\options.ini");
TPoint cPt;
int y, x, key1,key2;
double coorSpell1X, coorSpell1Y, screenW, screenH;
INPUT inp[2];
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
AnsiString temp = Ini->ReadString("screen","w",GetSystemMetrics(SM_CXSCREEN));
screenW = atof(temp.c_str());
temp = Ini->ReadString("screen","h",GetSystemMetrics(SM_CYSCREEN));
screenH = atof(temp.c_str());
Ini->WriteString("screen","w",FloatToStrF(screenW,ffNumber,15,3));
Ini->WriteString("screen","h",FloatToStrF(screenH,ffNumber,15,3));
}

void click(double x1, double y1) {
GetCursorPos(&cPt);
y=cPt.y;
x=cPt.x;
screenW=GetSystemMetrics(SM_CXSCREEN);
screenH=GetSystemMetrics(SM_CYSCREEN);
coorSpell1X = screenW/x1;
coorSpell1Y = screenH/y1;
SetCursorPos(coorSpell1X,coorSpell1Y);
memset(inp,0,sizeof(inp));
inp[0].type=INPUT_MOUSE;
inp[0].mi.dwFlags=MOUSEEVENTF_LEFTDOWN;
inp[1].type=INPUT_MOUSE;
inp[1].mi.dwFlags=MOUSEEVENTF_LEFTUP;
Sleep(16);
SendInput(2,inp,sizeof(INPUT));
Sleep(16);
SetCursorPos(x,y);
Sleep(16);
}
void __fastcall TForm1::ApplicationEvents1Message(tagMSG &Msg,
bool &Handled)
{
if (Msg.message == WM_HOTKEY) {
if (Msg.wParam == 0x00F) {
click(1.17,1.13);
}
else
if (Msg.wParam == 0x00E) {
click(1.1,1.13);
}
}
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button2Click(TObject *Sender)
{
ShowMessage("Invoker Spell Clicker 0.1 build 001 \n program allows to cast any of two invokers allowed spells by one key, not defaluts");
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
Application->Terminate();
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button3Click(TObject *Sender)
{
Application->Minimize();
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button4Click(TObject *Sender)
{
if (ComboBox1->ItemIndex!=ComboBox2->ItemIndex&&ComboBox1->ItemIndex!=84&&ComboBox2->ItemIndex!=84&&ComboBox1->Text!=""&&ComboBox2->Text!="") {
switch (ComboBox1->ItemIndex)
{
case 0: key1 = VK_MBUTTON;
break;
case 1: key1 = VK_BACK;
break;
case 2: key1 = VK_TAB;
break;
case 3: key1 = VK_RETURN;
break;
case 4: key1 =VK_PAUSE;
break;
case 5: key1 =VK_CAPITAL;
break;
case 6: key1 =VK_ESCAPE;
break;
case 7: key1 =VK_SPACE;
break;
case 8: key1 =VK_PRIOR;
break;
case 9: key1 =VK_NEXT;
break;
case 10: key1 =VK_END;
break;
case 11: key1 =VK_HOME;
break;
case 12: key1 =VK_LEFT;
break;
case 13: key1 =VK_UP;
break;
case 14: key1 =VK_RIGHT;
break;
case 15: key1 =VK_DOWN;
break;
case 16: key1 =VK_SNAPSHOT;
break;
case 17: key1 =VK_INSERT;
break;
case 18: key1 =VK_DELETE;
break;
case 19: key1 =0x31;//1
break;
case 20: key1 =0x32;//2
break;
case 21: key1 =0x33;//3
break;
case 22: key1 =0x34;//4
break;
case 23: key1 =0x35;//5
break;
case 24: key1 =0x36;//6
break;
case 25: key1 =0x37;//7
break;
case 26: key1 =0x38;//8
break;
case 27: key1 =0x39;//9
break;
case 28: key1 =0x30;//0,digits end
break;
case 29: key1 =0x41;//a
break;
case 30: key1 =0x42;//b
break;
case 31: key1 =0x43;//c
break;
case 32: key1 =0x44;//d
break;
case 33: key1 =0x45;//e
break;
case 34: key1 =0x46;//f
break;
case 35: key1 =0x47;//g
break;
case 36: key1 = 0x48;//h
break;
case 37: key1 = 0x49;//i
break;
case 38: key1 = 0x4A;//j
break;
case 39: key1 = 0x4B;//k
break;
case 40: key1 = 0x4C;//l
break;
case 41: key1 = 0x4D;//m
break;
case 42: key1 = 0x4E;//n
break;
case 43: key1 = 0x4F;//o
break;
case 44: key1 = 0x50;//p
break;
case 45: key1 = 0x51;//q
break;
case 46: key1 = 0x52;//r
break;
case 47: key1 = 0x53;//s
break;
case 48: key1 = 0x54;//t
break;
case 49: key1 = 0x55;//u
break;
case 50: key1 = 0x56;//v
break;
case 51: key1 = 0x57;//w
break;
case 52: key1 = 0x58;//x
break;
case 53: key1 = 0x59;//y
break;
case 54: key1 = 0x5A;//z
break;
case 55: key1 = VK_NUMPAD0;
break;
case 56: key1 = VK_NUMPAD1;
break;
case 57: key1 = VK_NUMPAD2;
break;
case 58: key1 = VK_NUMPAD3;
break;
case 59: key1 = VK_NUMPAD4;
break;
case 60: key1 = VK_NUMPAD5;
break;
case 61: key1 = VK_NUMPAD6;
break;
case 62: key1 = VK_NUMPAD7;
break;
case 63: key1 = VK_NUMPAD8;
break;
case 64: key1 = VK_NUMPAD9;
break;
case 65: key1 = VK_SEPARATOR;
break;
case 66: key1 = VK_SUBTRACT;
break;
case 67: key1 = VK_DECIMAL;
break;
case 68: key1 = VK_DIVIDE;
break;
case 69: key1 = VK_F1;
break;
case 70: key1 = VK_F2;
break;
case 71: key1 = VK_F3;
break;
case 72: key1 = VK_F4;
break;
case 73: key1 = VK_F5;
break;
case 74: key1 = VK_F6;
break;
case 75: key1 = VK_F7;
break;
case 76: key1 = VK_F8;
break;
case 77: key1 = VK_F9;
break;
case 78: key1 = VK_F10;
break;
case 79: key1 = VK_F11;
break;
case 80: key1 = VK_F12;
break;
case 81: key1 = VK_NUMLOCK;
break;
case 82: key1 = VK_SCROLL;
break;
case 83: key1 = VK_OEM_3;
break;
}
switch (ComboBox2->ItemIndex)
{
case 0: key2 = VK_MBUTTON;
break;
case 1: key2 = VK_BACK;
break;
case 2: key2 = VK_TAB;
break;
case 3: key2 = VK_RETURN;
break;
case 4: key2 =VK_PAUSE;
break;
case 5: key2 =VK_CAPITAL;
break;
case 6: key2 =VK_ESCAPE;
break;
case 7: key2 =VK_SPACE;
break;
case 8: key2 =VK_PRIOR;
break;
case 9: key2 =VK_NEXT;
break;
case 10: key2 =VK_END;
break;
case 11: key2 =VK_HOME;
break;
case 12: key2 =VK_LEFT;
break;
case 13: key2 =VK_UP;
break;
case 14: key2 =VK_RIGHT;
break;
case 15: key2 =VK_DOWN;
break;
case 16: key2 =VK_SNAPSHOT;
break;
case 17: key2 =VK_INSERT;
break;
case 18: key2 =VK_DELETE;
break;
case 19: key2 =0x31;//1
break;
case 20: key2 =0x32;//2
break;
case 21: key2 =0x33;//3
break;
case 22: key2 =0x34;//4
break;
case 23: key2 =0x35;//5
break;
case 24: key2 =0x36;//6
break;
case 25: key2 =0x37;//7
break;
case 26: key2 =0x38;//8
break;
case 27: key2 =0x39;//9
break;
case 28: key2 =0x30;//0,digits end
break;
case 29: key2 =0x41;//a
break;
case 30: key2 =0x42;//b
break;
case 31: key2 =0x43;//c
break;
case 32: key2 =0x44;//d
break;
case 33: key2 =0x45;//e
break;
case 34: key2 =0x46;//f
break;
case 35: key2 =0x47;//g
break;
case 36: key2 = 0x48;//h
break;
case 37: key2 = 0x49;//i
break;
case 38: key2 = 0x4A;//j
break;
case 39: key2 = 0x4B;//k
break;
case 40: key2 = 0x4C;//l
break;
case 41: key2 = 0x4D;//m
break;
case 42: key2 = 0x4E;//n
break;
case 43: key2 = 0x4F;//o
break;
case 44: key2 = 0x50;//p
break;
case 45: key2 = 0x51;//q
break;
case 46: key2 = 0x52;//r
break;
case 47: key2 = 0x53;//s
break;
case 48: key2 = 0x54;//t
break;
case 49: key2 = 0x55;//u
break;
case 50: key2 = 0x56;//v
break;
case 51: key2 = 0x57;//w
break;
case 52: key2 = 0x58;//x
break;
case 53: key2 = 0x59;//y
break;
case 54: key2 = 0x5A;//z
break;
case 55: key2 = VK_NUMPAD0;
break;
case 56: key2 = VK_NUMPAD1;
break;
case 57: key2 = VK_NUMPAD2;
break;
case 58: key2 = VK_NUMPAD3;
break;
case 59: key2 = VK_NUMPAD4;
break;
case 60: key2 = VK_NUMPAD5;
break;
case 61: key2 = VK_NUMPAD6;
break;
case 62: key2 = VK_NUMPAD7;
break;
case 63: key2 = VK_NUMPAD8;
break;
case 64: key2 = VK_NUMPAD9;
break;
case 65: key2 = VK_SEPARATOR;
break;
case 66: key2 = VK_SUBTRACT;
break;
case 67: key2 = VK_DECIMAL;
break;
case 68: key2 = VK_DIVIDE;
break;
case 69: key2 = VK_F1;
break;
case 70: key2 = VK_F2;
break;
case 71: key2 = VK_F3;
break;
case 72: key2 = VK_F4;
break;
case 73: key2 = VK_F5;
break;
case 74: key2 = VK_F6;
break;
case 75: key2 = VK_F7;
break;
case 76: key2 = VK_F8;
break;
case 77: key2 = VK_F9;
break;
case 78: key2 = VK_F10;
break;
case 79: key2 = VK_F11;
break;
case 80: key2 = VK_F12;
break;
case 81: key2 = VK_NUMLOCK;
break;
case 82: key2 = VK_SCROLL;
break;
case 83: key2 = VK_OEM_3;
break;
}
bool RHKret1 = RegisterHotKey(Form1->Handle, 0x00F, 0, key1);
bool RHKret2 = RegisterHotKey(Form1->Handle, 0x00E, 0, key2);
} else {ShowMessage("Try again!"); }
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------

Ссылка на комментарий

Пожалуйста, войдите, чтобы комментировать

Вы сможете оставить комментарий после входа в



Войти
  • Последние посетители   0 пользователей онлайн

    • Ни одного зарегистрированного пользователя не просматривает данную страницу
×
×
  • Создать...