Forum > Windows

Fire the CTRL-F9 button everywhere in windows 10.

(1/2) > >>

pascalbythree:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState  );begin   if (Shift = [ssCtrl]) AND (Key = 120) then memo1.Lines.Append('Ctrl F9');end;
Like this it got to work to receive the CTRL-F9 key when pressed on the form.

Does anybody know what to change to fire the code from the CTRL-F9 key, everywhere in windows 10 ? Even though the form is not focused ?

Greets, Wouter van Wegen

Bart:
Especially Lazarus users are going to thank you for "stealing" Ctrl+F9  O:-)

Bart

pascalbythree:
CTRL-F10 will also do.

Just as it responds everywhere in windows when application not focused.

Martin_fr:
google: msdn global key hook

marcov:
In Delphi this is done via applicationevents.shortcut


--- Code: ---procedure TRootMain.ApplicationEvents1ShortCut(var Msg: TWMKey;
  var Handled: Boolean);

var
 RawMessage: TMessage;
 fkey,shift : integer;
begin
 if not assigned(basehandling) or not allowkeys then
    exit;
 // Kijk in de raw message welke message er gestuurd is.

{  if Msg.Msg = WM_KEYDOWN then
 begin}
   // Debug: Log de tijd in een memo op het main form om te zien of het werkt.
   // Memo1.Lines.Insert(0, DateTimeToStr(Now));
   // Gebruik een 'normale' TMessage omdat dat makkelijker is.

   RawMessage:= TMessage(Msg);

   // Die is namelijk eventueel te typecasten naar een speciaal daarvoor
   // gemaakt record. Je kunt natuurlijk ook rechtstreeks de WParam en LParam
   // van Msg gaan ontleden, maar dit is makkelijker.

   if (msg.CharCode >=VK_F1) and (msg.CharCode <=VK_F12) and not BaseHandling.canclose  then
     begin
       fkey:=msg.charcode-vk_f1;
       shift:=0;
       if HiByte(GetKeyState(VK_SHIFT))>0 then inc(shift,1);
       if (HiByte(GetKeyState(VK_MENU))>0) then inc(shift,2);
       if (HiByte(GetKeyState(VK_CONTROL))>0) then inc(shift,4);
       basehandling.keyevent(fkey,shift);
         //handled:=true;
     end
end;


--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version