本帖最后由 奥斯丁 于 2010-7-28 10:29 编辑
小屏幕键盘,搞多天了,查了n多资料,无奈太菜,有请大虾完善,谢谢
#include <GUIConstantsEx.au3>
#Include <WinAPI.au3>
;~ _WinAPI_EnumWindows([$fVisible = True])
Opt('MustDeclareVars', 1)
Example()
Func Example()
Local $parent1, $ok1, $cancel1
Opt("GUICoordMode", 2)
Opt("GUIResizeMode", 1)
Opt("GUIOnEventMode", 1)
$parent1 = GUICreate("Parent1")
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents")
GUISetState()
;~ 置顶前先取到当前激活窗口,这个程序置顶以后再把原来的窗口激活。
$ok1 = GUICtrlCreateButton("1", 10, 30, 50)
GUICtrlSetOnEvent(-1, "OKPressed")
$cancel1 = GUICtrlCreateButton("2", 0, -1)
GUICtrlSetOnEvent(-1, "CancelPressed")
;~ GUISetState(@SW_SHOW)
WinSetOnTop($parent1, "", 1)
GUISetState(@SW_SHOWNOACTIVATE,$parent1)
; Just idle around
While 1
;~ _WinAPI_EnumWindows([$fVisible = True])
Sleep(100)
WEnd
EndFunc ;==>Example
Func OKPressed()
Send('1')
_WinAPI_GetForegroundWindow()
msgbox(0, '前台激活窗口标题:', WinGetTitle(_WinAPI_GetForegroundWindow()))
;~ MsgBox(0, "OK Pressed", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle & " CtrlHandle=" & @GUI_CtrlHandle,1)
EndFunc ;==>OKPressed
Func CancelPressed()
Send('2')
MsgBox(0, "Cancel Pressed", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle & " CtrlHandle=" & @GUI_CtrlHandle)
EndFunc ;==>CancelPressed
Func SpecialEvents()
Select
Case @GUI_CtrlId = $GUI_EVENT_CLOSE
MsgBox(0, "Close Pressed", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle)
Exit
Case @GUI_CtrlId = $GUI_EVENT_MINIMIZE
MsgBox(0, "Window Minimized", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle)
Case @GUI_CtrlId = $GUI_EVENT_RESTORE
MsgBox(0, "Window Restored", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle)
EndSelect
EndFunc ;==>SpecialEvents |