如何做个像系统自带那样的软键盘呢??打字区不失激活状态的
论坛里搜索到一个官方虚拟键盘,但很有问题,而且工作流程是接受到触动按钮后,然后给目标区ctrl send或settext,而不能像系统自带或其他输入法自带的软键盘那样,能够保持打字区的激活状态,直接里面写字。。AU3有法实现么? 本帖最后由 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
这个比较好玩~~
页:
[1]