0

I cannot disable alt+tab. What is wrong?

(1)

var I: LongBool;
SystemParametersInfo(97,Word(true),@I,0);

(2)

procedure TfrmRelatorio.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);

keypreview:=true;
if (Key = VK_Tab) and (ssAlt in Shift) then
Key := 0;
  • The parameters of (1) do not seem to match the [docs of SystemParametersInfo](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-systemparametersinfoa). From where did you get them? (2) As the key combination is an OS level key combo, I don't think you can prevent it from your application, but I might be wrong. Hopefully somebody can correct me. – Tom Brunberg Jun 21 '20 at 16:40
  • Well, I was wrong. A search revealed [this answer](https://stackoverflow.com/a/5850651/2292722), which also makes this question a duplicate. – Tom Brunberg Jun 21 '20 at 16:56

1 Answers1

1

97 or its constant name SPI_SETSCREENSAVERRUNNING stems from Win95 and also only applies to that platform, it was never meant to work on WinNT (which includes i.e. 2000, XP, Vista, 7, 8, 10) platforms. Either you (who copied the code) or the author neglected this important detail.

You have to install a hook thru SetWindowsHookEx( WH_KEYBORD ). Also see the similar question Keyboard hooking alt-tab causing strange behavior?

AmigoJack
  • 5,234
  • 1
  • 15
  • 31
  • thank you. I have installed and it is working now. – user13786857 Jun 21 '20 at 20:36
  • @Tom Brunberg. Tom Brunberg, I see that you closed my question judging by the fact that you thought it was similar to another post. The only similarity is the word "disable". The link you provided do not address my specific question and by no means answer my problem. Therefore, I would kindly ask you to reconsider your tag "duplicate" and re-open the question so as everybody can profit from other users precious opinions. – user13786857 Jun 22 '20 at 21:13