Thursday, November 20, 2008

QTP Script 19 - How to minimize, maximize, restore, resize a notepad?

This simple script shows you different methods like minimize, maximize, restore, resize for a notepad.

Make sure QTP with a new test and a blank notepad is open. Write the below script in a new test and run it. Don't open the notepad in maximize mode, keep it for example as shown in the screen shot.



Dim h, w

Sub GetROProperty_Example()
h = Window("text:=Untitled - Notepad").GetROProperty("height")
w = Window("text:=Untitled - Notepad").GetROProperty("width")
msgbox h
msgbox w
End Sub

GetROProperty_Example


Sub Window_Maximize()
Window("text:=Untitled - Notepad").Maximize
End Sub

Window_Maximize


Sub Window_Minimize()
Window("text:=Untitled - Notepad").Minimize
End Sub

Window_Minimize


Sub Window_Restore()
Window("text:=Untitled - Notepad").Restore
End Sub

Window_Restore


Sub Window_Resize()
Window("text:=Untitled - Notepad").Resize w, h
End Sub

Window_Resize