Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
- #AutoIt3Wrapper_Icon=Info (gray).ICO
- #AutoIt3Wrapper_Change2CUI=y
- #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
- #include <Array.au3>
- #include <WinAPISysWin.au3>
- ;~ chcp 65001
- Global $P1_hWnd = "TOP"
- If $CmdLine[0] > 0 Then $P1_hWnd = $CmdLine[1]
- If $CmdLine[0] > 1 Then Exit ConsoleWrite("!! Wrong Number of parameters" & @CRLF)
- If $P1_hWnd = "/?" Or $P1_hWnd = "/help" Then
- Local $sTxt = ""
- $sTxt &= "" & @CRLF
- $sTxt &= "************************************************************************************************************************" & @CRLF
- $sTxt &= " Name:" & @CRLF
- $sTxt &= " GetWinInfo " & @CRLF
- $sTxt &= "" & @CRLF
- $sTxt &= " Description: " & @CRLF
- $sTxt &= " Returns information about runing windows." & @CRLF
- $sTxt &= "" & @CRLF
- $sTxt &= " Syntax: " & @CRLF
- $sTxt &= " GetWinInfo [$hWnd]" & @CRLF
- $sTxt &= "" & @CRLF
- $sTxt &= " Parameters: $hWnd" & @CRLF
- $sTxt &= " ""TOP"" - Enumerates all top level windows. (Default)" & @CRLF
- $sTxt &= " ""ALL"" - Enumerates all windows." & @CRLF
- $sTxt &= " ""handle"" - specify a specific window by passing a handle as a string." & @CRLF
- $sTxt &= "" & @CRLF
- $sTxt &= " Return values: " & @CRLF
- $sTxt &= " The function returns an array with the following structure:" & @CRLF
- $sTxt &= "" & @CRLF
- $sTxt &= " Handle: ; PID: ; Class: ; Title:" & @CRLF
- $sTxt &= " Styles:" & @CRLF
- $sTxt &= " ExStyles:" & @CRLF
- $sTxt &= "" & @CRLF
- $sTxt &= " Notes: " & @CRLF
- $sTxt &= " his function uses the _WinAPI_EnumWindows() and _WinAPI_GetWindowText() functions to retrieve information about windows." & @CRLF
- $sTxt &= "" & @CRLF
- $sTxt &= "************************************************************************************************************************" & @CRLF
- ConsoleWrite($sTxt & @CRLF)
- Exit
- EndIf
- GetWinInfo($P1_hWnd)
- Exit
- ; #FUNCTION# --------------------------------------------------------------------------------------------------------------------
- ; Name...........: GetWinInfo($hWnd = "TOP")
- ; Description....: Returns information about runing windows.
- ; Syntax.........: GetWinInfo($hWnd = "TOP")
- ; Parameters.....: $hWnd - Handle of the window to get information for. (Default is "TOP")
- ; With "TOP" Enumerates all top level windows
- ; With "ALL" Enumerates all windows
- ; You can also specify a specific window handle by passing it as a string.
- ; Return values..: Handle: ; PID: ; Class: ; Title:
- ; Styles:
- ; ExStyles:
- ; Author ........:
- ; Notes .........: This function uses the _WinAPI_EnumWindows() and _WinAPI_GetWindowText() functions to retrieve information about windows.
- ; Link ..........: https://www.autoitscript.com/
- ; Dependencies...: #include <Array.au3>, #include <WinAPISysWin.au3>
- ;--------------------------------------------------------------------------------------------------------------------------------
- Func GetWinInfo($hWnd = "TOP")
- ;0=Handle; 1=Class; 2=Title; 3=PID; 4=Styles ;5=ExStyles
- Local $aWindows
- If $hWnd = "TOP" Then
- $aWindows = _WinAPI_EnumWindowsTop()
- Else
- $aWindows = _WinAPI_EnumWindows()
- EndIf
- Local $aResult[$aWindows[0][0]][6]
- For $i = 1 To $aWindows[0][0]
- $aResult[$i - 1][0] = $aWindows[$i][0]
- $aResult[$i - 1][1] = $aWindows[$i][1]
- Local $aTtl = StringSplit(WinGetTitle($aWindows[$i][0]), @CRLF)
- $aResult[$i - 1][2] = "'" & ($aTtl[0] = 1 ? $aTtl[1] : StringStripCR($aTtl[1]) & " ...") & "'"
- $aResult[$i - 1][3] = WinGetProcess($aWindows[$i][0])
- Local $aStyle = GetWindowStyleAndExStyle($aWindows[$i][0])
- $aResult[$i - 1][4] = $aStyle[1]
- $aResult[$i - 1][5] = $aStyle[2]
- Next
- ;_ArrayDisplay($aResult, "_WinAPI_EnumWindows", Default, Default, Default, "Handle|Class|Title|PID|Styles|ExStyles")
- Local $sOut = ""
- For $i = 0 To UBound($aResult) - 1
- If $hWnd = "TOP" Or $hWnd = "ALL" Then
- $sOut &= "Handle:" & $aResult[$i][0] & " ; "
- $sOut &= "PID:" & $aResult[$i][3] & " ; "
- $sOut &= "Class:" & $aResult[$i][1] & " ; "
- $sOut &= "Title:" & $aResult[$i][2] & @CRLF
- $sOut &= @TAB & "Styles:" & @CRLF
- $sOut &= $aResult[$i][4] & @CRLF
- $sOut &= @CRLF
- $sOut &= @TAB & "ExStyles:" & @CRLF
- $sOut &= $aResult[$i][5] & @CRLF
- $sOut &= @CRLF
- Else
- If $hWnd = $aResult[$i][0] Then
- $sOut &= "Handle:" & $aResult[$i][0] & " ; "
- $sOut &= "PID:" & $aResult[$i][3] & " ; "
- $sOut &= "Class:" & $aResult[$i][1] & " ; "
- $sOut &= "Title:" & $aResult[$i][2] & @CRLF
- $sOut &= @TAB & "Styles:" & @CRLF
- $sOut &= $aResult[$i][4] & @CRLF
- $sOut &= @CRLF
- $sOut &= @TAB & "ExStyles:" & @CRLF
- $sOut &= $aResult[$i][5] & @CRLF
- $sOut &= @CRLF
- EndIf
- EndIf
- Next
- ;~ ConsoleWrite($sOut)
- ConsoleWrite(BinaryToString(StringToBinary($sOut, 4), 1))
- EndFunc ;==>GetWinInfo
- ;--------------------------------------------------------------------------------------------------------------------------------
- ; Get the handle of the active window
- Func GetWindowStyleAndExStyle($hWnd)
- ; Get the window styles and extended styles using GetWindowLong
- Local $style = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE)
- Local $exStyle = _WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE)
- ; Array of window styles
- Local $aStyles[24][2] = [["WS_BORDER", 0x00800000], _
- ["WS_CAPTION", 0x00C00000], _
- ["WS_CHILD", 0x40000000], _
- ["WS_CHILDWINDOW", 0x40000000], _
- ["WS_CLIPCHILDREN", 0x02000000], _
- ["WS_CLIPSIBLINGS", 0x04000000], _
- ["WS_DISABLED", 0x08000000], _
- ["WS_DLGFRAME", 0x00400000], _
- ["WS_GROUP", 0x00020000], _
- ["WS_HSCROLL", 0x00100000], _
- ["WS_ICONIC", 0x20000000], _
- ["WS_MAXIMIZE", 0x01000000], _
- ["WS_MAXIMIZEBOX", 0x00010000], _
- ["WS_MINIMIZE", 0x20000000], _
- ["WS_MINIMIZEBOX", 0x00020000], _
- ["WS_OVERLAPPED", 0x00000000], _
- ["WS_POPUP", 0x80000000], _
- ["WS_SIZEBOX", 0x00040000], _
- ["WS_SYSMENU", 0x00080000], _
- ["WS_TABSTOP", 0x00010000], _
- ["WS_THICKFRAME", 0x00040000], _
- ["WS_TILED", 0x00000000], _
- ["WS_VISIBLE", 0x10000000], _
- ["WS_VSCROLL", 0x00200000]]
- ; Array of extended window styles
- Local $aExStyles[25][2] = [["WS_EX_ACCEPTFILES", 0x00000010], _
- ["WS_EX_APPWINDOW", 0x00040000], _
- ["WS_EX_CLIENTEDGE", 0x00000200], _
- ["WS_EX_COMPOSITED", 0x02000000], _
- ["WS_EX_CONTEXTHELP", 0x00000400], _
- ["WS_EX_CONTROLPARENT", 0x00010000], _
- ["WS_EX_DLGMODALFRAME", 0x00000001], _
- ["WS_EX_LAYERED", 0x00080000], _
- ["WS_EX_LAYOUTRTL", 0x00400000], _
- ["WS_EX_LEFT", 0x00000000], _
- ["WS_EX_LEFTSCROLLBAR", 0x00004000], _
- ["WS_EX_LTRREADING", 0x00000000], _
- ["WS_EX_MDICHILD", 0x00000040], _
- ["WS_EX_NOACTIVATE", 0x08000000], _
- ["WS_EX_NOINHERITLAYOUT", 0x00100000], _
- ["WS_EX_NOPARENTNOTIFY", 0x00000004], _
- ["WS_EX_NOREDIRECTIONBITMAP", 0x00200000], _
- ["WS_EX_RIGHT", 0x00001000], _
- ["WS_EX_RIGHTSCROLLBAR", 0x00000000], _
- ["WS_EX_RTLREADING", 0x00002000], _
- ["WS_EX_STATICEDGE", 0x00020000], _
- ["WS_EX_TOOLWINDOW", 0x00000080], _
- ["WS_EX_TOPMOST", 0x00000008], _
- ["WS_EX_TRANSPARENT", 0x00000020], _
- ["WS_EX_WINDOWEDGE", 0x00000100]]
- ; Get detailed styles and extended styles
- Local $styleDetails = GetStyleDetails($style, $aStyles)
- Local $exStyleDetails = GetStyleDetails($exStyle, $aExStyles)
- ; Return the results
- Local $result[3]
- $result[0] = $hWnd
- $result[1] = $styleDetails
- $result[2] = $exStyleDetails
- Return $result
- EndFunc ;==>GetWindowStyleAndExStyle
- ;--------------------------------------------------------------------------------------------------------------------------------
- ; Function to check if a specific style is present
- Func CheckStyle($styleValue, $constant, $constantName)
- If BitAND($styleValue, $constant) Then
- Return $constantName & " (0x" & Hex($constant, 8) & ")"
- EndIf
- Return ""
- EndFunc ;==>CheckStyle
- ;--------------------------------------------------------------------------------------------------------------------------------
- ; Function to get style details
- Func GetStyleDetails($styleValue, $aStyleArray)
- Local $result = ""
- For $i = 0 To UBound($aStyleArray) - 1
- Local $styleDetail = CheckStyle($styleValue, $aStyleArray[$i][1], $aStyleArray[$i][0])
- If $styleDetail <> "" Then
- $result &= @TAB & $styleDetail & @CRLF
- EndIf
- Next
- $result = StringTrimRight($result, 2)
- Return $result
- EndFunc ;==>GetStyleDetails
- ;--------------------------------------------------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement