找回密码
 加入
搜索
查看: 1660|回复: 2

[系统综合] 如何做个像系统自带那样的软键盘呢??打字区不失激活状态的

[复制链接]
发表于 2012-4-28 12:55:44 | 显示全部楼层 |阅读模式
论坛里搜索到一个官方虚拟键盘,但很有问题,而且工作流程是接受到触动按钮后,然后给目标区ctrl send或settext,而不能像系统自带或其他输入法自带的软键盘那样,能够保持打字区的激活状态,直接里面写字。。

AU3有法实现么?
发表于 2012-4-29 10:49:58 | 显示全部楼层
本帖最后由 zch11230 于 2012-4-29 11:05 编辑

这个是我查资料前自己想的 后台发送
查资料查到版主们也讨论过这个问题 而且解决了目标窗口失去焦点的问题 只能说版主都太强大了
http://www.autoitx.com/thread-17127-1-1.html

#include <WinAPI.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
Global $SendWinHwnd, $SendCrlHwnd
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 430, 50, @DesktopWidth - 440, @DesktopHeight - 120)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")

$Button1 = GUICtrlCreateButton("1", 10, 20, 60, 20)
GUICtrlSetOnEvent(-1, "Button1Click")
$Button2 = GUICtrlCreateButton("2", 80, 20, 60, 20)
GUICtrlSetOnEvent(-1, "Button2Click")
$Button3 = GUICtrlCreateButton("3", 150, 20, 60, 20)
GUICtrlSetOnEvent(-1, "Button3Click")
$Button4 = GUICtrlCreateButton("A", 220, 20, 60, 20)
GUICtrlSetOnEvent(-1, "Button4Click")
$Button5 = GUICtrlCreateButton("B", 290, 20, 60, 20)
GUICtrlSetOnEvent(-1, "Button5Click")
$Button6 = GUICtrlCreateButton("C", 360, 20, 60, 20)
GUICtrlSetOnEvent(-1, "Button6Click")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
WinSetOnTop(HWnd($Form1), "", 1)
While 1
        $FousHwnd = _WinAPI_GetForegroundWindow()
        If $FousHwnd <> $Form1 Then
;~                 $SendWinHwnd = $FousHwnd
                $SendCrlHwnd = ControlGetHandle(HWnd($FousHwnd), "", ControlGetFocus(HWnd($FousHwnd)))
        EndIf
;~         ConsoleWrite($SendCrlHwnd&@CRLF)
        Sleep(200)
WEnd

Func Button1Click()
;~         WinActivate(HWnd($SendWinHwnd))
        _WinAPI_PostMessage($SendCrlHwnd, $WM_KEYDOWN, 0x31, 0)
EndFunc 
Func Button2Click()
        _WinAPI_PostMessage($SendCrlHwnd, $WM_KEYDOWN, 0x32, 0)
EndFunc 
Func Button3Click()
        _WinAPI_PostMessage($SendCrlHwnd, $WM_KEYDOWN, 0x33, 0)
EndFunc  
Func Button4Click()
        _WinAPI_PostMessage($SendCrlHwnd, $WM_KEYDOWN, 0x41, 0)
EndFunc 
Func Button5Click()
        _WinAPI_PostMessage($SendCrlHwnd, $WM_KEYDOWN, 0x42, 0)
EndFunc 
Func Button6Click()
        _WinAPI_PostMessage($SendCrlHwnd, $WM_KEYDOWN, 0x43, 0)
EndFunc 

Func Form1Close()
        Exit
EndFunc 

发表于 2012-4-30 15:43:36 | 显示全部楼层
这个比较好玩~~
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-14 13:18 , Processed in 0.084366 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表