windows - Can task-switching keyboard shortcuts be disabled in W7 using Delphi? -
my application has had mode years customer can 'disable access os'. feature goes against grain (at least far windows concerned) there installations app program should ever visibile machine operator amd in case such feature useful.
the technigue used built several 'layers':
- hide taskbar , button.
- disable task-switching.
- disable main form system icons.
to disable taskbar used:
// handle taskbar , button.. taskbar := findwindow('shell_traywnd', nil); startbutton := findwindow('button', nil); // hide taskbar , button if taskbar <> 0 showwindow( taskbar, sw_hide ); if startbutton <> 0 showwindow( startbutton, sw_hide ); // set work area whole screen r := rect( 0,0,screen.width,screen.height ); systemparametersinfo( spi_setworkarea, 0, @r, 0 );
this worked , still seems fine on w7. researching how disable task-switching years ago turned technique of 'pretending' app screen saver (other terrible things renaming app 'explorer.exe' , booting etc):
procedure enabletaskswitching( astate : boolean ); // enables / disables task switching begin systemparametersinfo( spi_screensaverrunning, cardinal( not astate), nil, 0 ); end;
not surprisingly seems have no effect in w7 (i think works in xp etc). know of another, better, way of enabling / disabling alt-tab (and other special windows keys) working?
if found solution:
function lowlevelkeyboardproc(ncode: integer; wparam: wparam; lparam: lparam): lresult; stdcall; type pkbdllhookstruct = ^tkbdllhookstruct; tkbdllhookstruct = record vkcode: cardinal; scancode: cardinal; flags: cardinal; time: cardinal; dwextrainfo: cardinal; end; pkeyboardlowlevelhookstruct = ^tkeyboardlowlevelhookstruct; tkeyboardlowlevelhookstruct = tkbdllhookstruct; const llkhf_altdown = $20; var hs: pkeyboardlowlevelhookstruct; ctrldown: boolean; begin if ncode = hc_action begin hs := pkeyboardlowlevelhookstruct(lparam); ctrldown := getasynckeystate(vk_control) , $8000 <> 0; if (hs^.vkcode = vk_escape) , ctrldown exit(1); if (hs^.vkcode = vk_tab) , ((hs^.flags , llkhf_altdown) <> 0) exit(1); if (hs^.vkcode = vk_escape) , ((hs^.flags , llkhf_altdown) <> 0) exit(1); if (hs^.vkcode = vk_lwin) or (hs^.vkcode = vk_rwin) exit(1); end; result := callnexthookex(0, ncode, wparam, lparam); end; procedure tform1.formshow(sender: tobject); begin setwindowshookex(wh_keyboard_ll, @lowlevelkeyboardproc, 0, 0); end;
this disables (as can see!)
- ctrl+esc (show start menu)
- alt+tab (task switch)
- alt+esc (task switch)
- win (show start menu)
- win+tab (3d task switch)
- win+d, win+m, win+space, win+arrows, win+p, win+u, win+e, win+f, win+digit, ...
- almost combination including windows key (but not all, e.g. win+l)
Comments
Post a Comment