VB中利用shell調用系統的軟鍵盤
創新互聯建站自2013年起,先為七臺河等服務建站,七臺河等地企業,進行企業商務咨詢服務。為七臺河企業網站制作PC+手機+微官網三網同步一站式服務解決您的所有建站問題。
以XP SP3為例:
Shell "C:\WINDOWS\system32\osk.exe",1
我現在沒有現成的代碼給你,不過可以給你一些建議。如果你想在同一進程內實現屏幕鍵盤,則你只需要再F2打開的時候,將F1的當前焦點控件對象作為參數,傳遞給F2窗體,在F2點擊屏幕控件時,設置該“控件.Text = 鍵值” 即可,這種我稱之為假屏幕鍵盤。如果你想跨進程實現屏幕鍵盤,就比較難些了(比如:你想用你的F2窗體上的按鍵,實現QQ聊天內容的輸入、記事本內容的輸入)。這個需要用到 “鍵盤鉤子”技術,有關這方面的資料,你不妨自己找找。 另外,你提的F2焦點老處理不好,我認為F2根本不需要焦點控件(不要用按鈕做控件,而實用Label或圖片就可以了。)
既然你可以輸入英文,只要系統切換到中文輸入方式下,例如“谷歌拼音”,不就可以輸入中文了
用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
當前名稱:怎么給mysql添加縮印的簡單介紹
鏈接分享:http://m.newbst.com/article20/hsepco.html
成都網站建設公司_創新互聯,為您提供品牌網站制作、服務器托管、Google、ChatGPT、動態網站、網站營銷
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯