Get The Handle Of A Window

#1
Code:
::-----------------------------------------------------
:: WinGetHandle.btm
::
:: Demonstrates how to obtain the handle of a
::  window, using VBScript and the
::  AutoIt COM Interface
::
:: The AutoItX COM DLL can be downloaded from;
::  http://www.autoitscript.com/site/autoit/downloads/
::
:: Joe Caverly
:: 2012-12-08
::
::-----------------------------------------------------
@setlocal
@echo off
::-----------------------------------------------------
::
:: Create the WinGetHandle.vbs script
::
::-----------------------------------------------------
text > WinGetHandle.vbs
Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

handle = oAutoIt.WinGetHandle("[CLASS:Notepad]", "")
WScript.Echo handle
endtext
::-----------------------------------------------------
::
:: Run the WinGetHandle.vbs Script
::
::-----------------------------------------------------
set hWnd=%@execstr[cscript //nologo WinGetHandle.vbs]
::-----------------------------------------------------
::
:: The result was returned as hexadecimal
:: Convert it to decimal
::
::-----------------------------------------------------
set hWnd=%@convert[16,10,%hWnd]
::-----------------------------------------------------
::
:: Display the Window Handle
::
::-----------------------------------------------------
echo %hWnd
::-----------------------------------------------------
::
:: Delete the WinGetHandle.vbs script
::
::-----------------------------------------------------
if exist WinGetHandle.vbs del WinGetHandle.vbs > nul
endlocal
::-----------------------------------------------------
::
:: Using the AutoIt v3 Window Info tool, here are the
::  CLASS names for some apps on my system
::
:: Notepad++      CLASS:Notepad++
:: KeyNote 1.6.5  CLASS:GFKeyNote10
:: FireFox        CLASS:MozillaWindowClass
:: Calculator     CLASS:SciCalc
::
:: You can also use the partial or complete title of
::  a window, instead of the CLASS name;
::
:: handle = oAutoIt.WinGetHandle("Take Com","")
::
:: Refer to the AutoItX Help file for detailed info
::  on the WinGetHandle method
::
:: Another method, if you know the CLASS name for the
::  app, is to use the @WINAPI Variable Function
::  as follows;
::
:: findwindow=`%@winapi[user32,FindWindow,"%1",0]`
::
:: then;
::
:: echo %@findwindow[Notepad]
::
::-----------------------------------------------------