Switching Focus between Windows

Article Tools

The SwitchToThisWindow function is called to switch focus to a specified window and bring it to the foreground.

API Syntax : VOID SwitchToThisWindow( HWND hWnd, BOOL fAltTab );

Parameters :

clip_image001 hwnd – Handle to the window being switched to.

fAltTab – A TRUE for this parameter indicates that the window is being switched to using the Alt/Ctl+Tab key sequence. This parameter should be FALSE otherwise.

Extern.Declare micInteger, "SwitchToThisWindow", "user32.dll", "SwitchToThisWindow", micHWnd, micInteger

SystemUtil.Run "iexplore.exe", "www.advancedqtp.com", "", "open"
SystemUtil.Run "firefox.exe", "www.advancedqtp.com", "C:\Program Files\Mozilla Firefox", "open"
Set ie = Description.Create()
ie( "micclass" ).Value = "Browser"
ie( "title" ).Value = "AdvancedQTP Home.*"
ie( "version" ).Value = "internet explorer 6"
Set fx = Description.Create()
fx( "micclass" ).Value = "Browser"
fx( "title" ).Value = "AdvancedQTP Home.*"
fx( "version" ).Value = "firefox 1.1"
hwndIE = Browser( ie ).GetROProperty( "hwnd" )
hwndFX = Browser( fx ).GetROProperty( "hwnd" )

Extern.Declare micInteger, "SwitchToThisWindow", "user32.dll", "SwitchToThisWindow", micHWnd, micInteger
retVal = Extern.SwitchToThisWindow( hwndIE, True )
Wait 1
retVal = Extern.SwitchToThisWindow( hwndFX, True )
Previous postDetermine whether a Window is Maximized Next postMinimizing a Window

Related Posts

Post Your Comment

You must be logged in to post a comment.