| |
| |
| 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: 窗口标题,可使用部分标题代替通配符,此参数必须指定。 |
| 注意: 若有多个窗口符合匹配条件,则只获取本程序匹配到的第一个窗口的信息。 |
| |
| |
| $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 |
| EndFuncCOPY |