December 01, 2020, 02:43:41 PM

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

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Disable Alt+Tab Easily by SebHoll [ 1+ years ago ]
« on: June 29, 2017, 12:28:42 AM »
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"
RegisterHotKey%(hwnd%,id%,modifiers%,virtualkey%)
UnregisterHotKey%(hwnd%,id%)
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)
  3.  
  4. RegisterHotKey(hwnd,100,$1,$9)  ;Alt Tab
  5.  
  6. Repeat
  7.  
  8. event = WaitEvent()
  9.  
  10. Select event
  11.  
  12.         Case $803
  13.         UnregisterHotKey(hwnd,100)
  14.         End
  15.        
  16. End Select
  17.  
  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

.
.
.

UnregisterHotKey(hwnd,100)
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="http://support.microsoft.com/kb/226359/en-us/" target="_blank">http://support.microsoft.com/kb/226359/en-us/[/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