[Delphi] Skrót

0

Jak wyglądałaby procedura która zaemulowałaby naciśniecie w tym samym momencie klawisza 'Win' i 'L'

0

Zależy od pisma :-) mogłaby wyglądać ładnie lub brzydko :-) .

Przykłady:

procedure SimulateKeyDown(Key : byte); begin keybd_event(Key, 0, 0, 0); end;

procedure SimulateKeyUp(Key : byte); begin keybd_event(Key, 0, KEYEVENTF_KEYUP, 0); end;

procedure SimulateKeystroke(Key : byte; extra : DWORD); begin keybd_event(Key, extra, 0, 0); keybd_event(Key, extra, KEYEVENTF_KEYUP, 0); end;

procedure SendKeys(s : string); var i : integer; flag : bool; w : word; begin {Get the state of the caps lock key} flag := not GetKeyState(VK_CAPITAL) and = 0; {If the caps lock key is on then turn it off} if flag then SimulateKeystroke(VK_CAPITAL, 0); for i := to Length(s) do begin w := VkKeyScan(s[i]); {If there is not an error in the key translation} if ((HiByte(w) $FF) and (LoByte(w) $FF)) then begin {If the key requires the shift key down - hold it down} if HiByte(w) and = then SimulateKeyDown(VK_SHIFT); {Send the VK_KEY} SimulateKeystroke(LoByte(w), 0); {If the key required the shift key down - release it} if HiByte(w) and = then SimulateKeyUp(VK_SHIFT); end; end; {if the caps lock key was on at start, turn it back on} if flag then SimulateKeystroke(VK_CAPITAL, 0); end;

procedure TForm .Button Click(Sender: TObject); begin {Toggle the cap lock} SimulateKeystroke(VK_CAPITAL, 0); end;

procedure TForm .Button2Click(Sender: TObject); begin {Capture the entire screen to the clipboard} {by simulating pressing the PrintScreen key} SimulateKeystroke(VK_SNAPSHOT, 0); end;

procedure TForm .Button3Click(Sender: TObject); begin {Capture the active window to the clipboard} {by simulating pressing the PrintScreen key} SimulateKeystroke(VK_SNAPSHOT, ); end;

procedure TForm .Button4Click(Sender: TObject); begin {Set the focus to a window (edit control) and send it a string} Application.ProcessMessages; Edit .SetFocus; SendKeys('Delphi Is RAD!'); end

Powyższy to bżydkie pismo

0

Zależy od pisma :-) mogłaby wyglądać ładnie lub brzydko :-) .

Przykłady:

procedure SimulateKeyDown(Key : byte); begin keybd_event(Key, 0, 0, 0); end;

procedure SimulateKeyUp(Key : byte); begin keybd_event(Key, 0, KEYEVENTF_KEYUP, 0); end;

procedure SimulateKeystroke(Key : byte; extra : DWORD); begin keybd_event(Key, extra, 0, 0); keybd_event(Key, extra, KEYEVENTF_KEYUP, 0); end;

procedure SendKeys(s : string); var i : integer; flag : bool; w : word; begin {Get the state of the caps lock key} flag := not GetKeyState(VK_CAPITAL) and = 0; {If the caps lock key is on then turn it off} if flag then SimulateKeystroke(VK_CAPITAL, 0); for i := to Length(s) do begin w := VkKeyScan(s[i]); {If there is not an error in the key translation} if ((HiByte(w) $FF) and (LoByte(w) $FF)) then begin {If the key requires the shift key down - hold it down} if HiByte(w) and = then SimulateKeyDown(VK_SHIFT); {Send the VK_KEY} SimulateKeystroke(LoByte(w), 0); {If the key required the shift key down - release it} if HiByte(w) and = then SimulateKeyUp(VK_SHIFT); end; end; {if the caps lock key was on at start, turn it back on} if flag then SimulateKeystroke(VK_CAPITAL, 0); end;

procedure TForm .Button Click(Sender: TObject); begin {Toggle the cap lock} SimulateKeystroke(VK_CAPITAL, 0); end;

procedure TForm .Button2Click(Sender: TObject); begin {Capture the entire screen to the clipboard} {by simulating pressing the PrintScreen key} SimulateKeystroke(VK_SNAPSHOT, 0); end;

procedure TForm .Button3Click(Sender: TObject); begin {Capture the active window to the clipboard} {by simulating pressing the PrintScreen key} SimulateKeystroke(VK_SNAPSHOT, ); end;

procedure TForm .Button4Click(Sender: TObject); begin {Set the focus to a window (edit control) and send it a string} Application.ProcessMessages; Edit .SetFocus; SendKeys('Delphi Is RAD!'); end

Powyższy to bżydkie pismo

Czyli ten moj skrót to jakby wyglądał?

0

wystarczy zrobić proga co po naciśnięciu kawisza będze wyświetlał jego numer. Naciszkasz Win, naciszkasz L i w wywołaniu piszesz #(tu numer win) i 'L'

1 użytkowników online, w tym zalogowanych: 0, gości: 1