资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

vb.net软键盘设计 c# 软键盘

VB如何实现软键盘功能?

思路:

成都创新互联公司主要从事成都网站设计、成都网站制作、外贸网站建设、网页设计、企业做网站、公司建网站等业务。立足成都服务松江,十载网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:18980820575

假设在软键盘上建立26个字母键;

单击相应的键时模拟按键或直接输出到目标;

模拟按键时可行的,直接输出必须获得句柄才行,具体分析;

给你提供模拟按键代码:

Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal Scan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

Private Sub Timer1_Timer()

Call keybd_event(82, 0, 0, 0) '模拟按下"R"键

End Sub

码值对应表:

A 至 Z 键与 A – Z 字母的 ASCII 码相同:

值 描述

65 A 键

66 B 键

67 C 键

68 D 键

69 E 键

70 F 键

71 G 键

72 H 键

73 I 键

74 J 键

75 K 键

76 L 键

77 M 键

78 N 键

79 O 键

80 P 键

81 Q 键

82 R 键

83 S 键

84 T 键

85 U 键

86 V 键

87 W 键

88 X 键

89 Y 键

90 Z 键

0 至 9 键与数字 0 – 9 的 ASCII 码相同:

值 描述

48 0 键

49 1 键

50 2 键

51 3 键

52 4 键

53 5 键

54 6 键

55 7 键

56 8 键

57 9 键

下列常数代表数字键盘上的键:

值 描述

0x60 0 键

0x61 1 键

0x62 2 键

0x63 3 键

0x64 4 键

0x65 5 键

0x66 6 键

0x67 7 键

0x68 8 键

0x69 9 键

0x6A MULTIPLICATION SIGN (*) 键

0x6B PLUS SIGN (+) 键

0x6C ENTER 键

0x6D MINUS SIGN (–) 键

0x6E DECIMAL POINT (.) 键

0x6F DIVISION SIGN (/) 键

下列常数代表功能键:

值 描述

0x70 F1 键

0x71 F2 键

0x72 F3 键

0x73 F4 键

0x74 F5 键

0x75 F6 键

0x76 F7 键

0x77 F8 键

0x78 F9 键

0x79 F10 键

0x7A F11 键

0x7B F12 键

0x7C F13 键

0x7D F14 键

0x7E F15 键

0x7F F16 键

0 None

3 Cancel(Break)

8 Back

9 Tab

13 Return

16 ShiftKey

17 ControlKey

18 Menu

19 Pause

20 Capital(大小写)

27 Escape

32 Space

33 PageUp

34 Next(PageDonw)

35 End

36 Home

37 Left

38 Up

39 Right

40 Down

0-9 48-57

45 Insert

46 Delete

65-90 A-Z

91 LWin

93 Apps

96 105 NumPad0-

106 Multiply *

107 Add+

108

109 Subtract-

110 Decimal .

111 Divide /

112-123 F1-F12

VB.net 软键盘 制作

Public Class Form2

Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

AddHandler Label1.MouseEnter, AddressOf LabelMouseEnter

AddHandler Label2.MouseEnter, AddressOf LabelMouseEnter

AddHandler Label1.MouseLeave, AddressOf LabelMouseLeave

AddHandler Label2.MouseLeave, AddressOf LabelMouseLeave

AddHandler Label1.MouseDown, AddressOf LabelMouseDown

AddHandler Label2.MouseDown, AddressOf LabelMouseDown

End Sub

Private Sub LabelMouseEnter(ByVal sender As Object, ByVal e As System.EventArgs)

Dim c As Label = DirectCast(sender, Label)

c.BackColor = Color.DodgerBlue

End Sub

Private Sub LabelMouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)

Dim c As Label = DirectCast(sender, Label)

Form1.TextBox1.Text = c.Text

End Sub

Private Sub LabelMouseLeave(ByVal sender As Object, ByVal e As System.EventArgs)

Dim c As Label = DirectCast(sender, Label)

c.BackColor = SystemColors.Control

End Sub

End Class

VB实现软键盘输入

VB里面,有一个函数SendKeys,可以对有焦点的窗口发送按键来模拟输入。你先自己做一些按钮(可以使用控件数组),然后SendKeys 键值名称,这样就可以完成软键盘输入了。函数用法如下:SendKeys "{Enter}" �0�2 �0�2 �0�2 �0�2 �0�2'这样就表示发送回车键

VB制作软键盘

用API keybd_event来模拟按键过程,但是Ctrl+Alt+Del不能模拟,前面已经定义了各个按键的值,需要按什么键替换成对应的值就行了,由于是模拟键盘按键,所以按键发送的对象是当前激活的窗口。

Option Explicit

'

'Virtual Keys, Standard Set

'

Private Const VK_LBUTTON = H1

Private Const VK_RBUTTON = H2

Private Const VK_CANCEL = H3

Private Const VK_MBUTTON = H4 'NOT contiguous with L RBUTTON

Private Const VK_BACK = H8

Private Const VK_TAB = H9

Private Const VK_CLEAR = HC

Private Const VK_RETURN = HD

Private Const VK_SHIFT = H10

Private Const VK_CONTROL = H11

Private Const VK_MENU = H12

Private Const VK_PAUSE = H13

Private Const VK_CAPITAL = H14

Private Const VK_KANA = H15

Private Const VK_HANGEUL = H15 'old name - should be here for compatibility

Private Const VK_HANGUL = H15

Private Const VK_JUNJA = H17

Private Const VK_FINAL = H18

Private Const VK_HANJA = H19

Private Const VK_KANJI = H19

Private Const VK_ESCAPE = H1B

Private Const VK_CONVERT = H1C

Private Const VK_NONCONVERT = H1D

Private Const VK_ACCEPT = H1E

Private Const VK_MODECHANGE = H1F

Private Const VK_SPACE = H20

Private Const VK_PRIOR = H21

Private Const VK_NEXT = H22

Private Const VK_END = H23

Private Const VK_HOME = H24

Private Const VK_LEFT = H25

Private Const VK_UP = H26

Private Const VK_RIGHT = H27

Private Const VK_DOWN = H28

Private Const VK_SELECT = H29

Private Const VK_PRINT = H2A

Private Const VK_EXECUTE = H2B

Private Const VK_SNAPSHOT = H2C

Private Const VK_INSERT = H2D

Private Const VK_DELETE = H2E

Private Const VK_HELP = H2F

'VK_0 thru VK_9 are the same as ASCII '0' thru '9' (=H30 - =H39)

'VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' (=H41 - =H5A)

Private Const VK_LWIN = H5B

Private Const VK_RWIN = H5C

Private Const VK_APPS = H5D

Private Const VK_NUMPAD0 = H60

Private Const VK_NUMPAD1 = H61

Private Const VK_NUMPAD2 = H62

Private Const VK_NUMPAD3 = H63

Private Const VK_NUMPAD4 = H64

Private Const VK_NUMPAD5 = H65

Private Const VK_NUMPAD6 = H66

Private Const VK_NUMPAD7 = H67

Private Const VK_NUMPAD8 = H68

Private Const VK_NUMPAD9 = H69

Private Const VK_MULTIPLY = H6A

Private Const VK_ADD = H6B

Private Const VK_SEPARATOR = H6C

Private Const VK_SUBTRACT = H6D

Private Const VK_DECIMAL = H6E

Private Const VK_DIVIDE = H6F

Private Const VK_F1 = H70

Private Const VK_F2 = H71

Private Const VK_F3 = H72

Private Const VK_F4 = H73

Private Const VK_F5 = H74

Private Const VK_F6 = H75

Private Const VK_F7 = H76

Private Const VK_F8 = H77

Private Const VK_F9 = H78

Private Const VK_F10 = H79

Private Const VK_F11 = H7A

Private Const VK_F12 = H7B

Private Const VK_F13 = H7C

Private Const VK_F14 = H7D

Private Const VK_F15 = H7E

Private Const VK_F16 = H7F

Private Const VK_F17 = H80

Private Const VK_F18 = H81

Private Const VK_F19 = H82

Private Const VK_F20 = H83

Private Const VK_F21 = H84

Private Const VK_F22 = H85

Private Const VK_F23 = H86

Private Const VK_F24 = H87

Private Const VK_NUMLOCK = H90

Private Const VK_SCROLL = H91

'

'VK_L* VK_R* - left and right Alt, Ctrl and Shift virtual keys.

'Used only as parameters to GetAsyncKeyState() and GetKeyState().

'No other API or message will distinguish left and right keys in this way.

'

Private Const VK_LSHIFT = HA0

Private Const VK_RSHIFT = HA1

Private Const VK_LCONTROL = HA2

Private Const VK_RCONTROL = HA3

Private Const VK_LMENU = HA4

Private Const VK_RMENU = HA5

'dwFlags

Private Const KEYEVENTF_EXTENDEDKEY = H1

Private Const KEYEVENTF_KEYUP = H2

Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

Private Sub Command1_Click()

Call keybd_event(VK_MENU, 0, KEYEVENTF_EXTENDEDKEY, 0) '按下Alt键

Call keybd_event(VK_SNAPSHOT, 0, KEYEVENTF_EXTENDEDKEY, 0) '按下Print Screen键

Call keybd_event(VK_SNAPSHOT, 0, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0) '抬起Print Screen键

Call keybd_event(VK_MENU, 0, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0) '抬起Alt键

Call keybd_event(VK_LWIN, 0, KEYEVENTF_EXTENDEDKEY, 0) '按下Win键

Call keybd_event(VK_LWIN, 0, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0) '抬起Win键

Call keybd_event(VK_NUMLOCK, 0, KEYEVENTF_EXTENDEDKEY, 0) '按下Num Lock键

Call keybd_event(VK_NUMLOCK, 0, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0) '抬起Num Lock键

End Sub

VB.net做软键盘输入中文汉字,请问在VB.net不是VB6中.怎么做软键盘输入汉字.我现在能输入英文但是汉字不行

既然你可以输入英文,只要系统切换到中文输入方式下,例如“谷歌拼音”,不就可以输入中文了

求VB.net 制作的软键盘“屏幕键盘”

我现在没有现成的代码给你,不过可以给你一些建议。如果你想在同一进程内实现屏幕键盘,则你只需要再F2打开的时候,将F1的当前焦点控件对象作为参数,传递给F2窗体,在F2点击屏幕控件时,设置该“控件.Text = 键值” 即可,这种我称之为假屏幕键盘。如果你想跨进程实现屏幕键盘,就比较难些了(比如:你想用你的F2窗体上的按键,实现QQ聊天内容的输入、记事本内容的输入)。这个需要用到 “键盘钩子”技术,有关这方面的资料,你不妨自己找找。 另外,你提的F2焦点老处理不好,我认为F2根本不需要焦点控件(不要用按钮做控件,而实用Label或图片就可以了。)


标题名称:vb.net软键盘设计 c# 软键盘
网站路径:http://cdkjz.cn/article/hhhood.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220