标题: [其他] 窗口信息收集工具 getwininfo.exe beta 1.0 [打印本页]
作者: pusofalse 时间: 2008-10-27 10:48 标题: 窗口信息收集工具 getwininfo.exe beta 1.0
http://bcn.bathome.net/s/tool/index.html?key=getwininfo
用Au3写了这么一个小程序,发来与大家分享,并希望各位测试其中的BUG告知本人,不胜感谢!。。。
-----------------------------------------------------------------------------------------------------------------------------------------
修改部分代码,使之能在cmd中显示。- GetWinInfo.au3 Beta 1.0 [Code By BBS.bathome.net Pusofalse]
- Usage: @ScriptName [option-1] [option-2] [...[option-6]] [/n] <Windowtitle>
- Options:
- /position 获取窗口位置[x y 宽度 高度]
- /handle 获取窗口内部句柄
- /text 获取窗口中的文本
- /integertitle 获取窗口的完整标题
- /process 获取窗口所关联的进程/PID
- /state 获取窗口状态
- Windowtitle: 窗口标题,可使用部分标题代替通配符,此参数必须指定。
- 注意:
- 若有多个窗口符合匹配条件,则只获取本程序匹配到的第一个窗口的信息。
- 标题区分大小写。
- 程序退出代码:0 成功、 1 参数错误、 2 未找到指定窗口
复制代码
au3代码:- #AutoIt3Wrapper_Change2CUI=y
- #cs
- GetWinInfo.au3 Beta 1.0 [Code By BBS.bathome.net Pusofalse]
- Usage: @ScriptName [option-1] [option-2] [...[option-6]] [/n] <Windowtitle>
- Options:
- /position 获取窗口位置[x y 宽度 高度]
- /handle 获取窗口内部句柄
- /text 获取窗口中的文本
- /integertitle 获取窗口的完整标题
- /process 获取窗口所关联的进程/PID
- /state 获取窗口状态
- Windowtitle: 窗口标题,可使用部分标题代替通配符,此参数必须指定。
- 注意: 若有多个窗口符合匹配条件,则只获取本程序匹配到的第一个窗口的信息。
- #ce
-
- $Usage = @CRLF & "===============================================================================" &@CRLF
- $Usage &=" " & @ScriptName & " Beta 1.0 [Code By BBS.bathome.net Pusofalse]" & @CRLF
- $Usage &="===============================================================================" & @CRLF
- $Usage &= @CRLF & " Usage: " &@ScriptName &" [option-1] [option-2] [...[option-6]] <Windowtitle>"&@CRLF&@CRLF
- $Usage &= " Options:"&@CRLF
- $Usage &= " /position Gets the window position with 4 elements-"
- $Usage &= " [X,Y,Width,Height]." & @CRLF
- $Usage &= " /handle Gets the window handle." & @CRLF
- $Usage &= " /text Gets the text in the window." & @CRLF
- $Usage &= " /integertitle Gets the complete title." & @CRLF
- $Usage &= " /process Gets the PID associated the window." & @CRLF
- $Usage &= " /state Gets the status of the window." & @CRLF & @CRLF
- $Usage &= " Windowtitle: Specifies a window-title, you can use a part of the title to instead of "
- $Usage &= " wildcard, this parameter must be specified!" & @CRLF & @CRLF
- $Usage &= "===============================================================================" & @CRLF
- $Usage &= " Note: "& @CRLF
- $Usage &= " 1. If many windows were matched, then only got the information of the first "
- $Usage &= " window been caught by this program."&@CRLF
- $Usage &= @CRLF & " 2. The window-title is case-sensitive,so 'System' is different from 'system'." & @CRLF
- $Usage &= @CRLF & " 3. Exit code:" & @CRLF
- $Usage &= " 0: Succeeded" &@CRLF
- $Usage &= " 1: Invalid parameters" &@CRLF
- $Usage &= " 2: Not found the specified window" & @CRLF
- $Usage &= "===============================================================================" & @CRLF
- If $CmdLine[0] < 2 Then
- ConsoleWrite ($Usage)
- Exit (1)
- Endif
- Global $var
- Global $po, $han, $tex, $inte, $proc, $stat
- $str = StringSplit ("position handle text integertitle process state n", " ")
- For $a = 1 to $str[0]
- Assign ($str[$a], "a",2)
- Next
- Global $Final = $CmdLine[0]
- If WinExists($CmdLine[$Final]) Then
- For $i = 1 to $CmdLine[0]-1
- $str = StringReplace($CmdLine[$i], "/", "")
- If Not IsDeclared($str) Then
- Beep(2000,200)
- ConsoleWrite(@CRLF & " Unkown parameter: " & $CmdLine[$i] & @CRLF)
- Exit (1)
- Else
- call ($str)
- EndIf
- Next
- Else
- Beep(1500,200)
- ConsoleWrite(@CRLF & " Specified window not be found." & @CRLF)
- Exit (2)
- Endif
- ConsoleWrite($var & @CRLF)
- Exit 0
- Func position()
- $posi = wingetpos($CmdLine[$Final])
- For $i = 0 to 3
- $po &= $posi[$i] & " "
- Next
- $var &= @CRLF & $CmdLine[$Final] & " -Position: "& $po
- EndFunc
-
- Func handle()
- $han = WinGetHandle($CmdLine[$Final])
- $var &= @CRLF & $CmdLine[$Final] & " -Handle: " & $han
- EndFunc
- Func text()
- $tex = WinGetText($CmdLine[$Final])
- $var &= @CRLF & $CmdLine[$Final] & " -Text: " & $tex
- EndFunc
- Func integertitle()
- $inte = WinGetTitle($CmdLine[$Final])
- $var &= @CRLF & $CmdLine[$Final] & " -IntegerTitle: " & $inte
- EndFunc
- Func process()
- $proc = WinGetProcess($CmdLine[$Final])
- $var &= @CRLF & $CmdLine[$Final] & " -Process: " &$proc
- EndFunc
- Func state()
- $stat = WinGetState($CmdLine[$Final])
- If BitAnd($stat, 1) Then
- $var &= @CRLF & $CmdLine[$Final] & " -State: Exists."
- EndIf
- If BitAnd($stat, 2) Then
- $var &= @CRLF & $CmdLine[$Final] & " -State: Visibel."
- EndIf
- If BitAnd($stat, 4) Then
- $var &= @CRLF & $CmdLine[$Final] & " -State: Enabled."
- EndIf
- If BitAnd($stat, 8) Then
- $var &= @CRLF & $CmdLine[$Final] & " -State: Activated."
- EndIf
- If BitAnd($stat, 16) Then
- $var &= @CRLF & $CmdLine[$Final] & " -State: Minimized."
- EndIf
- If BitAnd($stat, 32) Then
- $var &= @CRLF & $CmdLine[$Final] & " -State: Maximized."
- EndIf
- EndFunc
复制代码
批处理测试代码:- @echo off
- echo 匹配标题中含有字串"批处理之家"的窗口,并输出其位置、状态。
- getwininfo.exe /position /state "批处理之家"
- pause>nul&echo.
- echo 匹配标题中含有字串"QQ"的窗口,并输出其完整标题、PID
- echo 标题名区分 大小写。
- getwininfo /integertitle /process QQ
- pause>nul&echo.
- echo 输出此批处理中的文本、窗口状态,并记录此文本的PID。
- start /min notepad.exe "%~f0"
- for /f "tokens=1,2*" %%a in ('getwininfo /text /state /process "%~n0"') do (
- if /i "%%b" neq "-Process:" (
- echo.%%a %%b %%c
- ) else (
- set "pid=%%c"
- ))
- echo. & echo "notepad.exe %~n0" 的pid是%pid%
- pause>nul
复制代码
作者: jatqwgij 时间: 2015-9-18 12:26
下载连接失效
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |