AU3可以给已经存在的窗口(第三方程式產生的)添加控件吗?
本帖最后由 kk_lee69 于 2012-9-3 01:16 编辑請教 如何在第三方 已經運行的軟件上 加個按鈕
例如 我已經運行WORDPAD我可以在上面加個按鈕嗎??
打算在第三方軟件上 加個按鈕 執行想要跑的程式.....可以實現嗎??
能舉個例子嗎?? 帮顶,好像不太可能! 帮顶,好像不太可能! 想不出办法 本帖最后由 xiehuahere 于 2012-9-4 11:38 编辑
回复 1# kk_lee69
wordpad工具栏上加个按钮,_GUICtrlButton_Create就可以。
#Include <GuiButton.au3>
#Include <Misc.au3>
_Singleton("test")
Opt("MouseCoordMode", 2)
Local $win = ""
Local $toolbar = ""
Local $pos, $margin = 2 ;按钮与工具栏的上下边距
Local $btnLeft, $btnTop, $btnWidth = 60, $btnHeight
Run(@ProgramFilesDir & '\Windows NT\Accessories\wordpad.exe')
If Not WinWait($win, "", 2) Then
MsgBox(48+262144, "Warning", "等待wordpad出现已超时!")
Exit
EndIf
If Not WinActivate($win) Then WinActivate($win)
$pos = ControlGetPos($win, "", $toolbar)
$btnLeft = $pos + $pos + 10
$btnTop = $pos + $margin
$btnHeight = $pos - $margin * 2
ConsoleWrite($btnLeft & ", " & $btnTop & ", " & $btnWidth & ", " & $btnHeight & @CRLF)
_GUICtrlButton_Create(WinGetHandle($win), "Test", $btnLeft, $btnTop, $btnWidth, $btnHeight)
HotKeySet("{ESC}", "_OnExit")
; Open DLL for _IsPressed
Local $dll = DllOpen("user32.dll")
While 1
If Not WinExists($win) Then _OnExit()
If WinActive($win) And _IsPressed("01", $dll) Then
$pos = MouseGetPos()
ConsoleWrite($pos & ", " & $pos & @CRLF)
If $pos > $btnLeft And $pos < $btnLeft + $btnWidth And $pos > $btnTop And $pos < $btnTop + $btnHeight Then
MsgBox(64+262144, "Result", "I'm clicked!", 0, WinGetHandle($win))
EndIf
; Wait until mouse released
While _IsPressed("01", $dll)
Sleep(10)
WEnd
EndIf
Sleep(10)
WEnd
Func _OnExit()
DllClose($dll)
Exit
EndFunc
此外还有一些工作要做:wordpad窗口最小化并还原后需要重建按钮;你还可以给按钮加上鼠标悬停效果,等。 回复 5# xiehuahere
好代碼非常感謝您的例子 可能性不大!他说的是工具栏!
页:
[1]