BLOQUEAR TECLA PRINT SCREEN

MMMX 08/06/2014 16:13:46
#438790
Prezados, preciso bloquear a tecla Print Screen. Alguém faz ideia de como conseguir isso? Já pesquisei bastante na internet e até aqui dei uma boa procurada. Observando que o código onde devo aplicar isso não é em VB6 mas em Word (VBA), portanto não tenho a facilidade dos eventos de detecção de tecla. Não sei se no Word é possível isso. Desde já obrigado a quem puder ajudar.
OCELOT 09/06/2014 09:31:57
#438796
Provavelmente você não vai conseguir, e print screen não é a única forma de se copiar a tela, existem diversos programinhas que fazem isso e não tem como ser detectados.
NAUTILUZ 11/06/2014 22:59:07
#438857
Use o codigo no macro do Word
E só fazer o macro chamar a função HookKeyboard() para ativar..


Private Declare Function SetWindowsHookEx _
Lib [Ô]user32[Ô] Alias [Ô]SetWindowsHookExA[Ô] ( _
ByVal idHook As Long, _
ByVal lpfn As Long, _
ByVal hmod As Long, _
ByVal dwThreadId As Long) As Long

Private Declare Function CallNextHookEx Lib [Ô]user32[Ô] ( _
ByVal hHook As Long, _
ByVal nCode As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long

Private Declare Function UnhookWindowsHookEx Lib [Ô]user32[Ô] ( _
ByVal hHook As Long) As Long

Private Declare Sub CopyMemory _
Lib [Ô]kernel32[Ô] Alias [Ô]RtlMoveMemory[Ô] ( _
pDest As Any, _
pSource As Any, _
ByVal cb As Long)

Private Type KBDLLHOOKSTRUCT
vkCode As Long
scanCode As Long
flags As Long
time As Long
dwExtraInfo As Long
End Type

Private Const HC_ACTION = 0
Private Const VK_SNAPSHOT = &H2C
Private Const WH_KEYBOARD_LL = 13&

Private hKeyb As Long

Public Function KeybCallback(ByVal Code As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Static udtHook As KBDLLHOOKSTRUCT

If (Code = HC_ACTION) Then
[ô]Copy the keyboard data out of the lParam (which is a pointer)
Call CopyMemory(udtHook, ByVal lParam, Len(udtHook))
If udtHook.vkCode = VK_SNAPSHOT Then
KeybCallback = 1
Exit Function
End If
End If
KeybCallback = CallNextHookEx(hKeyb, Code, wParam, lParam)
End Function

Public Sub HookKeyboard()
UnhookKeyboard
hKeyb = SetWindowsHookEx(WH_KEYBOARD_LL, AddressOf KeybCallback, App.hInstance, 0&)
End Sub

Public Sub UnhookKeyboard()
If hKeyb <> 0 Then
Call UnhookWindowsHookEx(hKeyb)
hKeyb = 0
End If
End Sub
NAUTILUZ 11/06/2014 23:05:22
#438858
Se der erro ten este codigo que e chamado do form, o codigo vai no modulo..

[ô]FORM
Private Sub Form_Load()
HookPrtSc Me.hWnd
End Sub

Private Sub Form_Unload(Cancel As Integer)
Unhook
End Sub

[ô]MODULO
Private Declare Function SetWindowLong _
Lib [Ô]user32[Ô] Alias [Ô]SetWindowLongA[Ô] ( _
ByVal hWnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long

Private Declare Function CallWindowProc _
Lib [Ô]user32[Ô] Alias [Ô]CallWindowProcA[Ô] ( _
ByVal lpPrevWndFunc As Long, _
ByVal hWnd As Long, _
ByVal Msg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long

Private Declare Function RegisterHotKey _
Lib [Ô]user32.dll[Ô] ( _
ByVal hWnd As Long, _
ByVal id As Long, _
ByVal fsModifiers As Long, _
ByVal vk As Long) As Long

Private Const WM_HOTKEY As Long = &H312
Private Const VK_SNAPSHOT As Long = &H2C
Private Const GWL_WNDPROC = (-4)
Private Const WM_DESTROY = &H2&
Private Const MOD_ALT As Long = &H1

Private hHandle As Long
Private hPrevWndProc As Long

Public Sub HookPrtSc(frmHandle As Long)
hHandle = frmHandle
[ô]Register both Alt+PrtSc and only PrtSc as hotkeys
RegisterHotKey hHandle, 1, MOD_ALT, VK_SNAPSHOT
RegisterHotKey hHandle, 2, 0, VK_SNAPSHOT
hPrevWndProc = SetWindowLong(hHandle, GWL_WNDPROC, AddressOf WinProc)
End Sub

Public Sub Unhook()
SetWindowLong hHandle, GWL_WNDPROC, hPrevWndProc
End Sub

Private Function WinProc(ByVal hWnd As Long, ByVal uMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
Dim sFile As String
Dim nSize As Long
Select Case uMsg
Case WM_HOTKEY
WinProc = 1
Exit Function
Case WM_DESTROY
Call Unhook
End Select
WinProc = CallWindowProc(hPrevWndProc, hWnd, uMsg, wParam, lParam)
End Function
Faça seu login para responder