Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
jaf jaf is offline
external usenet poster
 
Posts: 300
Default disable keyboard/mouse from vba for all programs?

Hi,
Sorry, the old DOS trick doesn't work anymore.

I found two other methods. The first uses API's.

Declare Function BlockInput Lib "USER32.dll" (ByVal fBlockIt As Long) As
Long
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Sub test() 'both keyboard and mouse blocked
BlockInput True 'off
' call sub:
'optional: Sleep 5000
BlockInput False 'on
End Sub

And the second from an MS Article mentioning Excel specifically. I haven't
test it so I don't know about other apps running.

' Macro to turn off keyboard entry.
Sub KeyboardOff()
' Sets CTRL+D to activate KeyboardOn.
Application.OnKey "^d", "KeyboardOn"
Application.DataEntryMode = True
End Sub

' Macro to restore keyboard entry.
Sub KeyboardOn()
Application.DataEntryMode = False
End Sub

--

John

johnf202 at hotmail dot com


"kk" wrote in message
om...
"jaf" wrote in message

...
Hi,
shell("mode con=off") to disable keyboard.
shell("mode con=on") to enable.

If your code crashes a hard reboot will be required. No keyboard, no
ctl-alt-del.

No idea on the mouse.


Thanks, but it doesn't work, i get error message "run time error 53;
file not found", and it stops at that line.

regards



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do I open a hyperlink with the keyboard only (not using mouse) NGRQ Excel Discussion (Misc queries) 5 November 8th 08 02:09 AM
disable right click on mouse jatman Excel Discussion (Misc queries) 2 June 5th 08 12:15 AM
Disable keyboard shortcuts Pegasus Excel Discussion (Misc queries) 21 July 1st 07 12:23 PM
How can I use the mouse or keyboard to zoom in Excel? Bill Excel Discussion (Misc queries) 6 June 19th 07 02:34 PM
How to disable Keyboard shortcut JON-JON Excel Programming 5 September 1st 03 10:24 AM


All times are GMT +1. The time now is 08:53 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"