[Delphi版]羅技無限靈貂,驅(qū)動程序補(bǔ)?。瓕?shí)現(xiàn)真正的多媒體播放器!附QQ圖標(biāo)偽裝程序
██████████ QQ圖標(biāo)偽裝程序
將 QQ 聊天窗口的標(biāo)題欄中的 “與 某某 聊天” 變成 “我的文檔 某某”,而且聊天窗口的圖標(biāo)變成 Word 文檔的圖標(biāo),托盤中的圖標(biāo)在不同狀態(tài)時(shí)也變成其它圖標(biāo):例如在線=網(wǎng)絡(luò)驅(qū)動器、離開=軟盤驅(qū)動器、隱身=硬盤驅(qū)動器、離線=斷開網(wǎng)絡(luò)驅(qū)動器。
變圖標(biāo)不需要編程,修改 QQ2004 的 QQRes.Dll 文件即可。
██████████ 羅技無限靈貂,驅(qū)動程序補(bǔ)丁-實(shí)現(xiàn)真正的多媒體播放器
羅技無限靈貂是羅技公司推出的一款多功能無線鼠標(biāo),英文名稱叫做“Logitech Media Player”,顧名思義-多媒體遙控器。
該款鼠標(biāo)最大的特色就是嵌入了眾多的功能鍵,除滾輪外,另有8個(gè)鍵。其中側(cè)面的兩個(gè)鍵在羅技眾多的中高檔鼠標(biāo)都已配備,功能主要是上下瀏覽;頂部的六個(gè)鍵組成多媒體鍵區(qū),包括:“Media、Play/Pause、Forward、Backward、+、-”。此外,滾輪可進(jìn)行十字導(dǎo)航,即多了左右瀏覽功能。
但在實(shí)際使用中,多媒體鍵的功能實(shí)在有限,以我的標(biāo)準(zhǔn)看來,根本發(fā)揮不了遙控器的作用!為什么這么說呢?
我鐘愛使用的媒體播放器是MPC(MS Windows Media Player Classic),它短小精悍、啟動快、占資源少、快捷鍵豐富,用鼠標(biāo)、鍵盤操作起來十分簡單。
下面針對 MPC 說說靈貂的缺憾:
播放/暫停 點(diǎn)擊左鍵或 Space 即可,左鍵就在鼠標(biāo)上,因此 Play/Pause 鍵就多余了;
下一個(gè)/上一個(gè) 點(diǎn)擊 PgUp/PgDown 即可,雖然鼠標(biāo)上對應(yīng)的是 Forward/Backward,但我們在看一個(gè)電影或者視頻片斷的時(shí)候,有多少機(jī)會能在中途去看上一個(gè)或者下一個(gè)文件呢?即使針對超過10分鐘的視頻文件,看完一個(gè),手工去點(diǎn)擊下一個(gè)文件也不是很費(fèi)事的工作么,因此這兩個(gè)鍵也就多余了。
羅技提供的最新驅(qū)動程序并未提供上述三個(gè)鍵的自定義功能,因此為了充分地利用上鼠標(biāo)上的眾多功能鍵,我只好在 QQ 圖標(biāo)程序中加入了新的代碼來實(shí)現(xiàn)這三個(gè)鍵的自定義功能,并且還可以在不同的應(yīng)用程序中令同一個(gè)鼠標(biāo)鍵實(shí)現(xiàn)不同的自定義功能。
利用官方的驅(qū)動設(shè)置程序設(shè)置:
Media 鍵的功能為組合鍵:Ctrl+F4,縮放的功能為關(guān)閉程序(效率十分高)。
之后的程序可以實(shí)現(xiàn)如下功能(主要是組合鍵):
◎MPC
向上瀏覽:前進(jìn)10秒;向下瀏覽:倒退10秒。
◎ACDSee
Play/Pause:Ctrl+Del;Forward:Alt+C;Backward:Alt+M。
◎ACD FotoCanvas
Play/Pause:Ctrl+S;Forward:Shift+A;Backward:Shift+S。
◎NetCaptor
Play/Pause:Ctrl+Shift+S;Foward:F3;Backward:F2。
◎UltraEdit
Play/Pause:Ctrl+S;Foward:Ctrl+Shift+F6;Backward:Ctrl+F6。
最后我要鄙視一下羅技無限靈貂驅(qū)動程序的開發(fā)人員!
鼠標(biāo)驅(qū)動的核心功能在于對鼠標(biāo)傳來的位移信號的換算與處理,還有諸如各種按鍵的定義、加速度的處理等問題,但這些相對于移動信號的處理與分析來說只是小問題,在這一方面的程序編制并不存在功能上的技術(shù)困難。既然你們作出了那么多中高檔的鼠標(biāo),尤其是我花了360人民幣買的這款靈貂,為何不再多敲些代碼,把多媒體鍵區(qū)的幾個(gè)鍵也加入自定義功能。畢竟計(jì)算機(jī)不是電視、錄音機(jī)、VCD機(jī)、DVD機(jī)、組合音響…,多媒體功能只是計(jì)算機(jī)的一部分功能,多數(shù)人還是要用它來做其它很多游泳的事情的,如果能在更多的應(yīng)用軟件中讓每個(gè)鍵都實(shí)現(xiàn)自定義功能,那么以它目前不到400元的價(jià)格和為數(shù)眾多的鼠標(biāo)鍵,絕對是一款超值的鼠標(biāo)!
██████████ Delphi 代碼如下,其中只有MPC用到了鉤子,因?yàn)樵诿襟w播放軟件中,多媒體鍵區(qū)的鍵及兩個(gè)側(cè)鍵產(chǎn)生的消息都被羅技的驅(qū)動鉤子給拐跑了,所以要自己編個(gè)全局鉤子提前把消息攔住,讓羅技的鉤子鉤不到我需要的消息。
//▓▓▓▓▓▓▓▓▓ ReTitle.dPR
program ReTitle;
uses
Forms,
SysUtils,
Windows,
Unit1 in 'Unit1.pas' {f},
DlgDebug_U in 'DlgDebug_U.pas' {dlgDebug};
{$R *.res}
begin
application.Initialize;
//調(diào)試狀態(tài)
dbg := findCmdLineSwitch('debug', ['/', '-'], true);
if dbg then with dlgDebug do begin
dlgDebug := TDlgDebug.Create(Application); Show;
Left := GetSystemMetrics(SM_CXSCREEN)-Width ;
Top := GetSystemMetrics(SM_CYSCREEN)-Height-60;
end;
Application.CreateForm(Tf, f);
Application.Run;
end.
//▓▓▓▓▓▓▓▓▓ Unit1.pas
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, DlgDebug_U;
type
Tf = class(TForm)
Tmr: TTimer;
procedure FormCreate(Sender: TObject);
procedure TmrTimer(Sender: TObject);
procedure WndProc(var Message: TMessage); override;
private
{ Private declarations }
hFocus: HWND;
Buf: array[0..1024] of Char;
sTitle: string;
//QQ
procedure GetMousePosHwndAndClassName(Sender : TPoint);
function replacing(s,source,target:string):string;
//羅技無限靈貂
procedure Down(VK: byte);
procedure UP (VK: byte);
procedure Key1(VK1 : byte);
procedure Key2(VK1, VK2 : byte);
procedure Key3(VK1, VK2, VK3: byte);
public
{ Public declarations }
end;
var
f: Tf;
const
LOGITECH = $0319;
PLAY_PAUSE = $E0000;
PLAY_LEFT = $C0000;
PLAY_RIGHT = $B0000;
implementation
procedure EnableWheelHook ; stdcall; external 'HookPrj.dll';
procedure DisableWheelHook; stdcall; external 'HookPrj.dll';
{$R *.dfm}
procedure Tf.FormCreate(Sender: TObject);//█████████████ 界面初始化
begin
FormStyle := fsStayOnTop;
Height:=0;
Width:=0;
Hide;
Tmr.Interval := 50;
ShowWindow(Application.Handle, SW_HIDE);
SetWindowLong(Application.Handle, GWL_EXSTYLE,
GetWindowLong(Application.handle, GWL_EXSTYLE) or WS_EX_TOOLWINDOW AND NOT WS_EX_APPWINDOW);
EnableWheelHook;//羅技靈貂藍(lán)色側(cè)鍵,WM_MouseWheel 消息鉤子
end;
procedure Tf.GetMousePosHwndAndClassName(Sender: TPoint);//███ 偽裝標(biāo)題欄
var hWnd: THandle;
aTitle: array [0..255] of char;
str:string;
begin
hWnd := WindowFromPoint(Sender);
if boolean(GetWindowText(hWnd, aTitle, 256)) then begin
str := string(aTitle);
//QQ
if ((pos('與',str)>0) and (pos('聊天中',str)>0)) then begin
str:=replacing(str, ' 聊天中', '');
str:=replacing(str, '與', '我的文檔');
SetWindowText(hWnd,pchar(str));
end;
if ((pos('群 -',str)>0) or (pos('高級群 -',str)>0)) then begin
str:=replacing(str, '群 -', '我的信件');
str:=replacing(str, '高級', '');
SetWindowText(hWnd,pchar(str));
end;
//聊天室
if pos('QQ 聊天室', str)>0 then begin
str := 'Microsoft Visual C++ 6.2';
SetWindowText(hWnd,pchar(str));
end;
//MSN
if pos(' - 對話', str)>0 then begin
str := replacing(str, ' - 對話', '工作文檔');
SetWindowText(hWnd,pchar(str));
end;
end;
end;
procedure Tf.TmrTimer(Sender: TObject);//████████████▌定時(shí)器
var rPos: TPoint;
begin
if boolean(GetCursorPos(rPos)) then GetMousePosHwndAndClassName(rPos);
end;
function Tf.replacing(s,source,target:string):string;//█████ 替換字符串
var site, strlen: integer;
begin
site:=pos(source,s);
strlen:=length(source);
delete(s,site,strlen);
insert(target,s,site);
result:=s;
end;
procedure Tf.WndProc(var Message: TMessage);////███████▌羅技無限靈貂
begin with Message do begin
inherited;
//如果不是多媒體鍵區(qū)的中右側(cè)三個(gè)鍵按下,則退出
IF NOT( (Msg=LOGITECH) and ((lParam=PLAY_PAUSE)or(lParam=PLAY_LEFT)or(lParam=PLAY_RIGHT)) ) THEN exit;
hFocus := GetForegroundWindow;
GetWindowText(hFocus, buf, 1024);
sTitle := string(buf);
deb(sTitle);
//ACDSee
if (pos('ACDSee', sTitle)>0) and (pos('5.0', sTitle)>0) and (Msg=LOGITECH) then case lParam of
PLAY_PAUSE: Key2(VK_Control, VK_Delete);//Ctrl+Del
PLAY_LEFT : Key2(VK_Menu , ord('M') );//Alt+M
PLAY_RIGHT: Key2(VK_Menu , Ord('C') );//Alt+C
end;
if (pos('ACD', sTitle)>0) and (pos('FotoCanvas', sTitle)>0) and (Msg=LOGITECH) then case lParam of
PLAY_PAUSE: Key2(VK_Control, ord('S'));//Ctrl+S
PLAY_LEFT : Key2(VK_Shift , ord('S'));//Shift+S
PLAY_RIGHT: Key2(VK_Shift , Ord('A'));//Shift+A
end;
//NetCaptor
if (pos('NetCaptor', sTitle)>0) and (Msg=LOGITECH) then case lParam of
PLAY_PAUSE: Key3(VK_Control, VK_Shift, ord('S'));//Ctrl+Shift+S
PLAY_LEFT : Key1(VK_F2);
PLAY_RIGHT: Key1(VK_F3);
end;
//UltraEdit
if (pos('UltraEdit-32', sTitle)>0) and (Msg=LOGITECH) then case lParam of
PLAY_PAUSE: Key2(VK_Control, ord('S'));//Ctrl+S
PLAY_LEFT : Key2(VK_Control, VK_F6 );//Ctrl+F6
PLAY_RIGHT: Key3(VK_Control, VK_Shift, VK_F6);//Ctrl+Shift+F6
end;
end; end;
procedure Tf.Down(VK: byte); begin keybd_event(VK, MapVirtualKey(VK, 0), 0, 0); end;
procedure Tf.UP (VK: byte); begin keybd_event(VK, MapVirtualKey(VK, 0), KEYEVENTF_KEYUp, 0); end;
procedure Tf.Key1(VK1: byte); begin
Down(VK1);
Up (VK1);
end;
procedure Tf.Key2(VK1, VK2: byte); begin
Down(VK1);
Down(VK2);
Up (VK2);
Up (VK1);
end;
procedure Tf.Key3(VK1, VK2, VK3: byte); begin
Down(VK1);
Down(VK2);
Down(VK3);
Up (VK3);
Up (VK2);
Up (VK1);
end;
end.
//▓▓▓▓▓▓▓▓▓ DlgDebug_U.pas
{*******************************************************************************
程序中用來顯示調(diào)試信息的非模態(tài)對話框
2005/02
*******************************************************************************}
unit DlgDebug_U; interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls;
procedure deb(theMsg: string); overload;//Debug 信息
procedure deb(theMsg: integer);overload;
procedure deb(const theStr: string; const Args: array of const); overload;
type
TdlgDebug = class(TForm)
re: TRichEdit;
procedure mmKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
indent: byte;
selColor: TColor;
procedure TimeLine;
end;
var dlgDebug: TdlgDebug;
dbg: Boolean;
implementation
{$R *.dfm}
procedure TdlgDebug.mmKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if Key=VK_SPACE then begin
re.Tag := integer( not boolean(re.Tag) );
//mm.Tag := integer( not boolean(mm.Tag) );
//if boolean(mm.Tag) then Red.Suspend
//else Red.Resume;
end;
end;
procedure deb(theMsg: string); begin
if not dbg then exit;
with dlgDebug do begin//Debug 信息
TimeLine;
re.SelAttributes.Color := selColor;
re.paragraph.FirstIndent := indent;
re.Lines.Add(theMsg);
//mm.Lines.Add(theMsg);
end;
end;
procedure deb(theMsg: integer);
begin
if not dbg then exit;
with dlgDebug do begin//Debug 信息
TimeLine;
re.SelAttributes.Color := selColor;
re.paragraph.FirstIndent := indent;
re.Lines.Add(intToStr(theMsg));
//mm.Lines.Add(intToStr(theMsg));
end;
end;
procedure deb(const theStr: string; const Args: array of const); overload;
begin
if not dbg then exit;
with dlgDebug do begin//Debug 信息
TimeLine;
re.SelAttributes.Color := selColor;
re.paragraph.FirstIndent := indent;
re.Lines.Add(format(theStr, Args));
//mm.Lines.Add(format(theStr, Args));
end;
end;
procedure TdlgDebug.TimeLine;
begin with re do begin
paragraph.FirstIndent := 0;
SelAttributes.Color := clRed;
lines.Add(formatDateTime(LongTimeFormat, now));
end; end;
procedure TdlgDebug.FormCreate(Sender: TObject);
begin
indent := 10;
selColor := clYellow;
end;
end.
//▓▓▓▓▓▓▓▓▓ HookPrj.dpr
library HookPrj;
uses
SysUtils,
Classes,
Hook_U in 'Hook_U.pas';
exports
EnableWheelHook ,
DisableWheelHook;
begin
end.
//▓▓▓▓▓▓▓▓▓ Hook_U.pas
unit Hook_U; interface
uses Windows,Messages, SysUtils, dialogs;
var HK: HHOOK;//鉤子的句柄值
hFocus: HWnd;
buf: array [0..1024] of char;
sTitle: string;
iC: byte;
zDelta: short;
function WheelHookProc(Code: Integer; WParam: Longint; Msg: Longint): LRESULT; stdcall;
function EnableWheelHook : Boolean; stdcall; export;
function DisableWheelHook: Boolean; stdcall; export;
implementation
//██████████████████████████████████▌處理鉤子
function WheelHookProc(Code: Integer; WParam: Longint;Msg:Longint): LRESULT; stdcall;
begin
zDelta := short(HiWord(PMsg(Msg)^.wParam));
if (Code=HC_ACTION) and (PMsg(Msg)^.Message=WM_MOUSEWHEEL) and (abs(zDelta)>200) then begin
hFocus := GetForegroundWindow;
GetWindowText(hFocus, buf, 1024);
sTitle := string(buf);
if ( pos('mplayerc', sTitle)>0 )or( pos('Media Player Classic', sTitle)>0 ) then begin
inc(iC);
//按一次藍(lán)色側(cè)鍵產(chǎn)生兩條消息,二合一處理的話相當(dāng)于快進(jìn)1次,即5秒,
//都處理的話相當(dāng)于快進(jìn)2次,即10秒
//if (iC mod 2)=0 then begin
keybd_event(VK_Control, MapVirtualKey(VK_Control, 0), 0, 0); //CTRL Down
if zDelta>200 then begin
keybd_event(VK_Right, MapVirtualKey(VK_Right, 0), 0, 0); //RIGHT Down
keybd_event(VK_Right, MapVirtualKey(VK_Right, 0), KEYEVENTF_KEYUP, 0);//RIGHT Up
end else begin
keybd_event(VK_Left , MapVirtualKey(VK_Left , 0), 0, 0); //LEFT Down
keybd_event(VK_Left , MapVirtualKey(VK_Left , 0), KEYEVENTF_KEYUP, 0);//LEFT Up
end;
keybd_event(VK_Control, MapVirtualKey(VK_Control, 0), KEYEVENTF_KEYUP, 0);//CTRL Up
//end;
PMsg(Msg)^.Message := 0;//因?yàn)閭?cè)鍵消息已經(jīng)本地處理過了,不必再交給其它線程處理
end else Result := CallNextHookEx(HK, Code, WParam, Longint(@Msg));//如果不是MPC,則向下傳遞
end else Result := CallNextHookEx(HK, Code, WParam, Longint(@Msg));//如果不是兩個(gè)藍(lán)色側(cè)鍵則向下傳遞
end;
function EnableWheelHook: Boolean; stdcall; export;//█████████ 加載鉤子
begin
if HK=0 then begin
HK := SetWindowsHookEx(WH_GETMESSAGE, @WheelHookProc, Hinstance, 0);
Result := True;
end else Result := False;
end;
function DisableWheelHook: Boolean; stdcall; export;//████████▌卸載鉤子
begin
if HK<>0 then begin
UnHookWindowsHookEx(HK);
HK := 0;
Result := True;
end else Result := False;
end;
end.
QQ:7995.7944(薪絲路)
E-Mail:gg7853@163.com
新聞熱點(diǎn)
疑難解答
圖片精選