获键盘鼠标vb.net,用鼠标点的键盘

vb.net 如何获取鼠标单击的控件名称

这个简单。

青白江ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联公司的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:18982081108(备注:SSL证书合作)期待与您的合作!

在VB.net中,每个事件都对应有两个参数:sender 和 e 。提取 sender 参数信息就可以获取控件名称。如果不理解其中机制,你直接 msgbox(sender) 将其输出,就能查看其中玄机。

获取控件名称代码:CType(sender, Control).Name。

辅助软件(不是读内存那种),就是获取画面,进行分析,然后模拟键鼠操作的那种,用VB.net写得出来吗?

获取画面这个很容易

分析画面这个很难

模拟鼠标键盘操作这个也很容易

VB.net能写

难点:分析画面的代码!这个是你的辅助软件能否做出来的核心技术点

vb.net 怎样获取鼠标单击点的坐标

通过窗体的MouseDown事件的e.X和e.Y属性获取。通过e.Location属性获取Point类型的坐标。

下面的代码示例使用 Location 属性跟踪鼠标左键单击,并绘制一系列直线段作为对用户输入的响应。如果隐藏窗体然后重新显示它,此示例不保留已绘制的线段,该代码为简单起见而被省略了。

Dim FirstPoint As Point

Dim HaveFirstPoint As Boolean = False

Sub Form1_MouseDownDrawing(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown

If HaveFirstPoint Then

Dim g As Graphics = Me.CreateGraphics()

g.DrawLine(Pens.Black, FirstPoint, e.Location)

HaveFirstPoint = False

Else

FirstPoint = e.Location

HaveFirstPoint = True

End If

End Sub

在VB.net中怎么获取 鼠标在屏幕中的坐标

Private Declare Function GetCursorPos Lib "user32" (ByRef lpPoint As POINTAPI) As Long '全屏坐标声明

Private Declare Function ScreenToClient Lib "user32.dll" (ByVal hwnd As Int32, ByRef lpPoint As POINTAPI) As Int32 '窗口坐标声明

Private Structure POINTAPI '声明坐标变量

Public x As Int32 '声明坐标变量为32位

Public y As Int32 '声明坐标变量为32位

End Structure

'以上是声明部分

'以下是窗口部分

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick '用时钟控件来取坐标,窗口上放个Timer组件,Enabled为允许,周期为10到100毫秒均可

Dim P As POINTAPI '声明坐标变量

Dim xx, yy '声明转换要用到的变量

GetCursorPos(P) '获取鼠标在屏幕中的位置

ScreenToClient(Me.Handle.ToInt32, P) '转换为本窗体的坐标

xx = P.x.ToString '把X转换成能显示到文本框的字符串格式

yy = P.y.ToString '把Y转换成能显示到文本框的字符串格式

TextBox1.Text = xx + "和" + yy '文本框的内容为X坐标和Y坐标

End Sub

VB中接收键盘鼠标的方法

添加一文本框;一定时器,interval=10或更小Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer

Dim tim As Long

Function GetKeyName(KeyCodes) As String

Select Case KeyCodes

Case 1: GetKeyName = "鼠标左键"

Case 2: GetKeyName = "鼠标右键"

Case 4: GetKeyName = "鼠标中键"

Case 8: GetKeyName = "Back Space"

Case 9: GetKeyName = "Tab"

Case 12: GetKeyName = "(5)"

Case 13: GetKeyName = "Enter"

Case 16: GetKeyName = "Shift"

Case 17: GetKeyName = "Ctrl"

Case 18: GetKeyName = "Alt"

Case 19: GetKeyName = "Pause Break"

Case 20: GetKeyName = "Caps Lock"

Case 27: GetKeyName = "Esc"

Case 32: GetKeyName = "Space"

Case 33: GetKeyName = "Page Up"

Case 34: GetKeyName = "Page Down"

Case 35: GetKeyName = "End"

Case 36: GetKeyName = "Home"

Case 37: GetKeyName = "Left"

Case 38: GetKeyName = "Up"

Case 39: GetKeyName = "Right"

Case 40: GetKeyName = "Down"

Case 44: GetKeyName = "Print Screen"

Case 45: GetKeyName = "Insert"

Case 46: GetKeyName = "Delete"

Case 48 To 57: GetKeyName = KeyCodes - 48

Case 65 To 90: GetKeyName = Chr(KeyCodes)

Case 91: GetKeyName = "左开始"

Case 92: GetKeyName = "右开始"

Case 93: GetKeyName = "属性"

Case 96 To 105: GetKeyName = KeyCodes - 96

Case 106: GetKeyName = "*"

Case 107: GetKeyName = "+"

Case 109: GetKeyName = "-"

Case 110: GetKeyName = "."

Case 111: GetKeyName = "/"

Case 112 To 123: GetKeyName = "F" (KeyCodes - 111)

Case 144: GetKeyName = "Num Lock"

Case 145: GetKeyName = "Scroll Lock"

Case 186: GetKeyName = ";"

Case 187: GetKeyName = "="

Case 188: GetKeyName = ","

Case 189: GetKeyName = "-"

Case 190: GetKeyName = "."

Case 191: GetKeyName = "/"

Case 192: GetKeyName = "`"

Case 219: GetKeyName = "["

Case 220: GetKeyName = ""

Case 221: GetKeyName = "]"

Case 222: GetKeyName = "'"

End Select

End FunctionPrivate Sub Timer1_Timer()

Dim Res As Long

Dim i As Integer

For i = 0 To 255

Res = GetAsyncKeyState(i)

If Res = -32767 Then

Text1.Text = Text1.Text GetKeyName(i) Space(15 - Len(GetKeyName(i))) "键值" i Space(10 - Len(Str(i))) Time Chr(13) Chr(10)

End If

Next i

End Sub

在vb.net 键盘事件 中 如何获取当前鼠标的位置。 比如我按下“enter”键,获取此时刻鼠标的位置。

控件中keyup属性记录键盘操作

比如:

Private Sub from1_KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyUp

if e.keycode = keys.Enter then

lable1.text =Cursor.Position.X

lable2.text = Cursor.Position.Y

end if

end sub


文章标题:获键盘鼠标vb.net,用鼠标点的键盘
转载来源:http://hbruida.cn/article/hcidog.html