#include <WinAPI.au3>
#include <Array.au3>
Global $oDict, $aNewWin[1][3] = [[0, 'Title', 'Class']]
$oDict = ObjCreate('Scripting.Dictionary')
If Not IsObj($oDict) Then Exit 1
_GetAllVisibleWindows(0)
__LoadKeyboardLayoutEngSelf()
HotKeySet('+z', '_GetNew');Shift+z
HotKeySet('{Esc}', '_Exit');Esc
While 1
Sleep(100)
WEnd
Func _GetNew()
HotKeySet('+z')
_GetAllVisibleWindows(1)
_ArrayDisplay($aNewWin, 'New Windows')
HotKeySet('+z', '_GetNew')
EndFunc ;==>_GetNew
Func _Exit()
Exit
EndFunc ;==>_Exit
Func _GetAllVisibleWindows($i_Flag)
Local $a_Win, $s_HexHWnd
If $i_Flag Then
ReDim $aNewWin[1][3]
$aNewWin[0][0] = 0
EndIf
$a_Win = WinList()
If $i_Flag Then ReDim $aNewWin[$a_Win[0][0] + 1][3]
For $i = 1 To $a_Win[0][0]
If Not BitAND(WinGetState($a_Win[$i][1]), 2) Then ContinueLoop
$s_HexHWnd = Hex($a_Win[$i][1], 8)
If $oDict.Exists($s_HexHWnd) Then ContinueLoop
$oDict.Add($s_HexHWnd, 0)
If Not $i_Flag Then ContinueLoop
$aNewWin[0][0] += 1
$aNewWin[$aNewWin[0][0]][0] = '0x' & $s_HexHWnd
$aNewWin[$aNewWin[0][0]][1] = WinGetTitle($a_Win[$i][1])
$aNewWin[$aNewWin[0][0]][2] = _WinAPI_GetClassName($a_Win[$i][1])
Next
If $i_Flag Then ReDim $aNewWin[$aNewWin[0][0] + 1][3]
EndFunc ;==>_GetAllVisibleWindows
Func __LoadKeyboardLayoutEngSelf()
Local Const $__KLF_ACTIVATE = 0x00000001, $__KLF_SETFORPROCESS = 0x00000100
Local $a_Res = DllCall('user32.dll', 'long', 'LoadKeyboardLayoutW', 'wstr', '00000409', 'uint', BitOR($__KLF_ACTIVATE, $__KLF_SETFORPROCESS))
If (@error) Or (Not $a_Res[0]) Or (Not StringInStr(Hex($a_Res[0]), '0409')) Then Return 0
Return 1
EndFunc ;==>__LoadKeyboardLayoutEngSelf