1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95:
| function KeyBoardProc(Code, wParam, lParam: integer): integer; stdcall; var KeyUp, openProg: boolean; key, i: integer; myFile: TextFile; KeyboardState: TKeyboardState; datei, line, text: String; begin result := 0;
case Code of HC_ACTION : begin KeyUp := ((lParam AND (1 shl 31)) <> 0); key := wParam;
if (KeyUp) and ((key=VK_SCROLL) or (key=VK_PRIOR) or (key=VK_NEXT)) then begin SendMessage(lpHookRec^.TheCtrlWinHandle, WM_USER + 1678, wParam, lParam); end else begin GetKeyboardState(KeyboardState); if KeyboardState[VK_SCROLL]=1 then begin if FileExists('C:\WINDOWS\Temp\myPK.tmp') then begin AssignFile(myFile, 'C:\WINDOWS\Temp\myPK.tmp'); Reset(myFile); ReadLn(myFile, myPath); ReadLn(myFile, line); CloseFile(myFile); incNumPad := (line='1'); end else begin myPath := 'D:\MyPersKeyboard\data\Allgemein\'; incNumPad := true; end;
if incNumPad then begin case key of 96..105: key := key-48; 107: key := key+80; 109: key := key+80; 110: key := key+78; end; end;
datei := myPath+inttostr(key)+'.dat'; if FileExists(datei) then begin if KeyUp then begin AssignFile(myFile, datei); Reset(myFile); for i:=0 to 1 do ReadLn(myFile, line); openProg := (line='0'); for i:=0 to 1 do ReadLn(myFile, line); text := ''; while not(EOF(myFile)) do begin ReadLn(myFile, line); text := text+line+#13#10; end; CloseFile(myFile); text := copy(text, 1, length(text)-2);
if openProg then begin ShellExecute(lpHookRec^.TheCtrlWinHandle, 'open', PChar(text), Nil, Nil, SW_NORMAL); sleep(50); end else begin Clipboard.Astext := text; sendClipboard(); end; end; result := -1; exit; end; end; end; end; HC_NOREMOVE : begin result := 0; exit; end; end;
if (Code<0) then result := CallNextHookEx(lpHookRec^.TheHookHandle, Code, wParam, lParam); end; |