怎样用程序制作软键盘

怎样用程序制作软键盘,第1张

用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

c语言从键盘输入字符串的步骤如下:

1.首先我们新并纳建一个dev C++的项目。

2.接下来在项目中新建C语言程序文件。

3.然后在C语言文件中声明一个字节数组。

4.接下来我们慧或通过printf函数提示用户输入字符串,通过scanf接收用前蔽伍户输入的字符串。

5.接着在通过printf函数输出用户输入的内容。

6.最后运行C语言程序,我们输入内容以后就可以输出了。这样就解决了c语言从键盘输入字符串的问题了。

实现从键盘输入一个大写字母,改用小裂李写字母输出,可以使用下面的方法凳源谨:

#include<stdio.h>

int main(){

char a

scanf("%c",&a)

printf("%c"枣基,a+32)

}

执行效果如下:


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12409109.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-25
下一篇 2023-05-25

发表评论

登录后才能评论

评论列表(0条)

保存