Hi gurus! With the help of the internet I have managed to get the below code to work for me; it disables the Print Screen button by registering it as a hotkey (so that people can't copy the data in a workbook). The below code disables the Print Screen button when it is pressed at the same time as Alt, Ctrl or Shift BUT when you press Ctrl+Alt+PrintScreen the print screen is not blocked.
Can anyone please shed some light on how to disable the printscreen when Ctrl+Alt+PrintScreen is pressed? Thank you in advance to everyone who takes a look! I'm stumped :/
Note I am using 64-bit excel (hence PtrSafe before Function).
![]()
Option Explicit Private Declare PtrSafe Function RegisterHotKey Lib "user32" _ (ByVal hWnd As Long, _ ByVal id As Long, _ ByVal fsModifiers As Long, _ ByVal vk As Long) As Long Private Declare PtrSafe Function UnregisterHotKey Lib "user32" _ (ByVal hWnd As Long, _ ByVal id As Long) As Long Private Const VK_SNAPSHOT = &H2C Private Const MOD_ALT = &H1 Private Const MOD_CONTROL = &H2 Private Const MOD_SHIFT = &H4 Private lPrint As Long Private lAltPrint As Long Private lCtrlPrint As Long Private lShiftPrint As Long Sub HookPrintKey() 'set the hotkeys IDs lPrint = 1 lAltPrint = 2 lCtrlPrint = 3 lShiftPrint = 4 'Register the hotkeys Call RegisterHotKey(0, lPrint, 0&, VK_SNAPSHOT) Call RegisterHotKey(0, lAltPrint, MOD_ALT, VK_SNAPSHOT) Call RegisterHotKey(0, lCtrlPrint, MOD_CONTROL, VK_SNAPSHOT) Call RegisterHotKey(0, lShiftPrint, MOD_SHIFT, VK_SNAPSHOT) End Sub Sub UnhookPrintKey() 'Unregister the hotkeys Call UnregisterHotKey(0, lPrint) Call UnregisterHotKey(0, lAltPrint) Call UnregisterHotKey(0, lCtrlPrint) Call UnregisterHotKey(0, lShiftPrint) End Sub











LinkBack URL
About LinkBacks
Register To Reply
Bookmarks