问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

怎样用程序制作软键盘

发布网友 发布时间:2022-04-23 14:54

我来回答

2个回答

热心网友 时间:2023-08-02 02:16

用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

热心网友 时间:2023-08-02 02:17

看你要用哪种编程工具了,有些是自带有的,比如asp.net
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
华为手机删除qq聊天记录还能恢复吗 曙光英雄怎么登录以前的账号,曙光英雄曙光英雄客户端在哪里下载? 曙光英雄怎么注销账号 详细注销方法分享 曙光英雄怎么注销账号-账号注销方法介绍 六大茶类之青茶知识大科普 六大茶类香气类型之青茶(乌龙茶)茶香 六大茶类之青茶 简单认识六大茶类之青茶 一文带你全面认识六大茶类中的青茶,速来围观 识茶笔记:六大茶类之青茶篇 雪莲果是水果还是蔬菜,怎么吃? 如何用易语言写网络游戏最小化后 后台按键程序? 雪莲果含糖量是多少? 单片机C语言两个数码管按键计数程序 雪莲果什么时候吃最好? 如何用易语言制作游戏最小化后 后台按键程序。 什么季节吃雪莲果好值 51单片机最有效的按键处理程序 8月份吃雪莲果好吃吗 tcl xqb55f101t怎么设置洗衣按键流程 51单片机汇编语言按键如何编程? 雪莲果是什么季节的水果 一年四季都有吗 单片机按键延时,使用定时计数器消除按键延时,求操作流程 雪莲果一年四季都能吃吗 键盘按键程序 雪莲果是在什么季节成熟的 VB编写按键程序. 雪莲果什么时候吃? 单片机应用中,独立式按键操作的流程是什么? 雪莲果什么时候吃最好 雪莲果什么时候吃最好?求解。 求51单片机中断式独立按键的程序流程图,完整一点谢谢。 雪莲果可以天天吃吗,没次吃多少合适,吃多了对身体 VB一个简单的键盘按键响应程序 雪莲果的热量?每天都吃可以吗? 关于单片机温度控制系统C语言程序中的按键设置程序,请求详细的介绍下按键的输入过程。while(1) { if(KeyFl win7下怎么记录键盘按键过程,就是按过哪些按键 矩阵式键盘工作流程主要包括 三个步骤 单片机键盘自检程序 51单片机的4*4键盘程序 按键控制led灯的程序 单片机5个IO口扫描25个按键的程序,怎么只能扫描到下面5个键 有什么app可以把证件照背景颜色改了 请问有没有改变图片上的文字和背景颜色的手机app? 哪个app可以换照片底色 怎样制做微信二维码红包? 怎么让别人扫我的二维码收红包? 我想设置一个微信二维码,别人扫到就可以得到我发的红包,请问怎么办 唐诗三百首究竟是哪三百首 唐诗三百首是哪300首