找回密码
 加入
搜索
查看: 3267|回复: 3

[GUI管理] [已解决]如何修改一个第三方窗口的控件状态?

[复制链接]
发表于 2011-4-3 18:28:46 | 显示全部楼层 |阅读模式
本帖最后由 boyhong 于 2011-4-3 21:01 编辑

如下,通过PID来获取窗口句柄,我下午闲来无事就在想,是不是接着可以来改这个窗口上的控件呢?
但几经试验,均无效,比如使用:GUICtrlSetData是不成功的。。。有办法来改么?我记得原来咱坛子上有人发过,但我在坛子上找了一个小时也没有找到。。。。
希望大家帮忙,感谢。


$iPid=Run("calc.exe",@SystemDir,@SW_MINIMIZE) ;似乎有些可以最小化运行,有些不行,比如画图程序就可以这样来最小化运行,但计算器不成
$iPid=_ProcessGetHWnd($iPid) ;通过PID来获取窗口句柄
WinSetTitle($iPid, "", "test")  ;修改目标窗口标题
WinSetState ($iPid, "",@SW_SHOW) 
;下边比如要将计算器窗口上的 “= ”键@SW_HIDE掉,或者改为其它任何字符。。。。谢谢


Func _ProcessGetHWnd($iPid, $iOption = 1, $sTitle = "", $iTimeout = 2000)
    Local $aReturn[1][1] = [[0]], $aWin, $hTimer = TimerInit()
    
    While 1
        
        ; Get list of windows
        $aWin = WinList($sTitle)
        
        ; Searches thru all windows
        For $i = 1 To $aWin[0][0]
            
            ; Found a window owned by the given PID
            If $iPid = WinGetProcess($aWin[$i][1]) Then
                
                ; Option 0 or 1 used
                If $iOption = 1 OR ($iOption = 0 And $aWin[$i][0] <> "") Then
                    Return $aWin[$i][1]
                
                ; Option 2 is used
                ElseIf $iOption = 2 Then
                    ReDim $aReturn[UBound($aReturn) + 1][2]
                    $aReturn[0][0] += 1
                    $aReturn[$aReturn[0][0]][0] = $aWin[$i][0]
                    $aReturn[$aReturn[0][0]][1] = $aWin[$i][1]
                EndIf
            EndIf
        Next
        
        ; If option 2 is used and there was matches then the list is returned
        If $iOption = 2 And $aReturn[0][0] > 0 Then Return $aReturn
        
        ; If timed out then give up
        If TimerDiff($hTimer) > $iTimeout Then ExitLoop
        
        ; Waits before new attempt
        Sleep(Opt("WinWaitDelay"))
    WEnd
    
    
    ; No matches
    SetError(1)
    Return 0
EndFunc   ;==>_ProcessGetHWnd

发表于 2011-4-3 18:31:54 | 显示全部楼层
本帖最后由 xxoojoeooxx 于 2011-4-3 21:35 编辑

去HELP索引中Control开头的都看一便

评分

参与人数 1贡献 +5 收起 理由
boyhong + 5 感谢您的热心

查看全部评分

 楼主| 发表于 2011-4-3 21:00:57 | 显示全部楼层
去HELP索引中Control开头的都看一变
xxoojoeooxx 发表于 2011-4-3 18:31


感谢您,已搞定这个控件隐藏,如下,但就是RUN这个计算器的时候,却不能最小化运行,所以出现窗口会闪一下,有点那个啥。。。能再帮忙看一下么?

$iPid=Run("calc.exe",@SystemDir,@SW_MINIMIZE) ;似乎有些可以最小化运行,有些不行,比如画图程序就可以这样来最小化运行,但计算器不成
$iPid=_ProcessGetHWnd($iPid) ;通过PID来获取窗口句柄
WinSetTitle($iPid, "", "test")  ;修改目标窗口标题
WinSetState ($iPid, "",@SW_SHOW) 
;下边比如要将计算器窗口上的 “= ”键@SW_HIDE掉,或者改为其它任何字符。。。。谢谢
ControlHide ($iPid, "",112)
ControlHide ($iPid, "",92)
 
Func _ProcessGetHWnd($iPid, $iOption = 1, $sTitle = "", $iTimeout = 2000)
    Local $aReturn[1][1] = [[0]], $aWin, $hTimer = TimerInit()
    
    While 1
        
        ; Get list of windows
        $aWin = WinList($sTitle)
        
        ; Searches thru all windows
        For $i = 1 To $aWin[0][0]
            
            ; Found a window owned by the given PID
            If $iPid = WinGetProcess($aWin[$i][1]) Then
                
                ; Option 0 or 1 used
                If $iOption = 1 OR ($iOption = 0 And $aWin[$i][0] <> "") Then
                    Return $aWin[$i][1]
                
                ; Option 2 is used
                ElseIf $iOption = 2 Then
                    ReDim $aReturn[UBound($aReturn) + 1][2]
                    $aReturn[0][0] += 1
                    $aReturn[$aReturn[0][0]][0] = $aWin[$i][0]
                    $aReturn[$aReturn[0][0]][1] = $aWin[$i][1]
                EndIf
            EndIf
        Next
        
        ; If option 2 is used and there was matches then the list is returned
        If $iOption = 2 And $aReturn[0][0] > 0 Then Return $aReturn
        
        ; If timed out then give up
        If TimerDiff($hTimer) > $iTimeout Then ExitLoop
        
        ; Waits before new attempt
        Sleep(Opt("WinWaitDelay"))
    WEnd
    
    
    ; No matches
    SetError(1)
    Return 0
EndFunc   ;==>_ProcessGetHWnd
发表于 2011-4-3 21:38:09 | 显示全部楼层
回复 3# boyhong


WinSetTrans 设透明度0 或 1
之後再WinSetState ($iPid, "",@SW_SHOW)
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-6-2 23:58 , Processed in 0.088765 second(s), 27 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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