如何使用Visual Basic在操作系统中禁用功能键F5 [英] How to disable function key F5 in operating system using visual basic
本文介绍了如何使用Visual Basic在操作系统中禁用功能键F5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Visual Basic 6.0,并且想为操作系统禁用功能键F5.
Hi,
I am using visual basic 6.0 and I want to desable funtion key F5 for operating system.
Public Class WinControl
' This is the function used in order to block the keyboard and mouse:
Declare Function BlockInput Lib "User32" _
(ByVal fBlockIt As Boolean) As Boolean
' This function will block the keyboard and mouse untill a window with
' the specify caption will appear or the given time in seconds has
' past ( 0 seconds - wait forever).
' If the window with the caption appears than the given key is send
' to it and the input block is removed.
Public Shared Function Wait2Send(ByVal caption As String, _
ByVal keys As String, ByVal seconds As Integer)
' Indicates if the window with the given caption was found
Dim success As Boolean = False
' Start time of the function
Dim now As DateTime = DateTime.Now
' Begining of keyboard and mouse block
BlockInput(True)
While (success = False And (DateTime.Now.Subtract(now).Seconds _
< seconds Or seconds = 0))
Try
' Activating the window with desired function
' if the window is not found an exception is thrown.
AppActivate(caption)
' Sending desired key stroke to the application window
SendKeys.SendWait(keys)
' Indicates the window was found and keys sent
success = True
Catch
' Assuming window was not found and sleep for 100 miliseconds
System.Threading.Thread.Sleep(100)
End Try
End While
' Release the keyboard block
BlockInput(False)
End Function
End Class
此代码有效,但同时禁用了鼠标和键盘.
我只需要停止使用F5.
请提供一些代码或想法.
在此先感谢
This code is working but it disables both mouse and keyboard.
I have to desable only F5.
Please give some code or idea.
Thanks in advance
推荐答案
使用BlockInput(),由于该键将阻止系统的所有输入事件,因此您无法对特定键进行处理.
看这里-> http://msdn.microsoft.com/en-US/library/ms646290.aspx [ ^ ]
如果您想暂停特定的键,请处理键盘事件
并在键盘输入处理程序中执行以下操作
Using BlockInput(), You can not diasable the specific key becouse it will block the all input events of the system.
Look Here -> http://msdn.microsoft.com/en-US/library/ms646290.aspx[^]
If you want suspress specific key then handle the events of keyboard
and do the following inside the keyboard input handler
If keyascii = vbKeyF5 then
keyascii = 0
end if
您应该提出这个问题BlockImput(Boolean)
函数的作者,因为他是世界上唯一可能知道答案的人.
You should direct this question to the author of the BlockImput(Boolean)
function, as he is the only person in the world who could potentially know the answer.
F5是一个刷新按钮,并将其禁用将使用户烦恼也会因为Internet浏览器而停止它.
但是,如果您仍然想要这样做,我将阅读此链接
如何禁用功能键 [
F5 is a refresh button and disabling it WOULD annoy users as it would stop it for their Internet browsers also.
but if you still want to do it I would have a read of this link
How do you disable function key[^]
这篇关于如何使用Visual Basic在操作系统中禁用功能键F5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文