September 20, 2021, 06:39:39

Author Topic: [bb] Disable Alt+Tab Easily by SebHoll [ 1+ years ago ]  (Read 1498 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
Title : Disable Alt+Tab Easily
Author : SebHoll
Posted : 1+ years ago

Description : This code disables Alt+Tab while the program is running by assigning the "Alt+Tab" sequence a HotKey property for your window. E.g. your window snatches the "Alt+Tab" key presses from the O/S. LOL.

Dead easy to use - just make sure that you use UnRegisterHotKey() once app has finished otherwise some users may not be able to regain "Alt+Tab" functionality when program closes.

Code: [Select]
.lib "user32.dll"
The "100" specified as ID for the hotkey could be anything I think but I know 100 works so best to stick with that.

I have tried to change this script to block the "Windows Key" also to no avail.

Hope this helps someone out there... [/i]

Code :
Code: BlitzBasic
  1. wndMain = CreateWindow("Hello",100,100,400,300,0,1)
  2. hwnd = QueryObject(wndMain,1)
  4. RegisterHotKey(hwnd,100,$1,$9)  ;Alt Tab
  6. Repeat
  8. event = WaitEvent()
  10. Select event
  12.         Case $803
  13.         UnregisterHotKey(hwnd,100)
  14.         End
  16. End Select
  18. Forever

Comments :

big10p(Posted 1+ years ago)

 What happens if my app crashes before it can execute UnRegisterHotKey?

SebHoll(Posted 1+ years ago)

 On my Win XP Pro computer it automatically removes the hot key but I thought that it was good practice to put it in as it may not do so on Win 98/NE etc. On my XP computer though, there's no problem!!!

big10p(Posted 1+ years ago)

 I've got a win98SE machine so I might give this a try, if I'm feeling brave. Just don't want to fubar my system, if I can help it. :) Thanks.

SebHoll(Posted 1+ years ago)

 OK - Thanks Chris. I think it should work and if not, restarting the system should remove all "HotKey" assignments.

big10p(Posted 1+ years ago)

 OK, I tried this on my win98SE machine in blitz3D using:
Code: [Select]
hwnd = SystemProperty("AppHWND")
RegisterHotKey(hwnd,100,$1,$9) ;Alt Tab


But it doesn't work. :( Disabling alt+tab on win98 machines seems to be a real pain, by all accounts.

Grey Alien(Posted 1+ years ago)

 Try BlackJumper's StickyKey.dll it does otherstuff AND removes Alt+Tab.

big10p(Posted 1+ years ago)

 I tested for BlackJumper in the past to try and get it to work on win98 - no joy. He's going to have another go at some point, though.

Perturbatio(Posted 1+ years ago)

 for win98: <a href="" target="_blank">[/url]

BlackJumper(Posted 1+ years ago)

 For a related thread on detecting Alt+TAB and other ways to lose focus see Eikon and Grey Alien's work on <a href="../Community/posts95e2-2.html?topic=52920" target="_blank">this thread[/url] [/i]


SimplePortal 2.3.6 © 2008-2014, SimplePortal