找回密码
 加入
搜索
查看: 2389|回复: 6

[图形处理] AU3可以给已经存在的窗口(第三方程式產生的)添加控件吗?

  [复制链接]
发表于 2012-9-3 01:04:25 | 显示全部楼层 |阅读模式
本帖最后由 kk_lee69 于 2012-9-3 01:16 编辑

請教 如何在第三方 已經運行的軟件上 加個按鈕
例如 我已經運行WORDPAD  我可以在上面加個按鈕嗎??

打算在第三方軟件上 加個按鈕 執行想要跑的程式.....  可以實現嗎??

能舉個例子嗎??
发表于 2012-9-3 20:57:51 | 显示全部楼层
帮顶,好像不太可能!
发表于 2012-9-3 20:57:59 | 显示全部楼层
帮顶,好像不太可能!
发表于 2012-9-3 21:15:44 | 显示全部楼层
想不出办法
发表于 2012-9-4 11:25:46 | 显示全部楼层
本帖最后由 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 = "[CLASS:WordPadClass]"
Local $toolbar = "[CLASSNN:ToolbarWindow322]"
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[0] + $pos[2] + 10
$btnTop = $pos[1] + $margin
$btnHeight = $pos[3] - $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[0] & ", " & $pos[1] & @CRLF)
                If $pos[0] > $btnLeft And $pos[0] < $btnLeft + $btnWidth And $pos[1] > $btnTop And $pos[1] < $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窗口最小化并还原后需要重建按钮;你还可以给按钮加上鼠标悬停效果,等。
 楼主| 发表于 2012-9-4 11:42:13 | 显示全部楼层
回复 5# xiehuahere

好代碼  非常感謝您的例子
发表于 2012-9-4 17:59:12 | 显示全部楼层
可能性不大!他说的是工具栏!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-6 17:18 , Processed in 0.086109 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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