Pages

Friday, January 27

Run application using QTP, if not running already!!

Hello Friends,

Sometimes we need to check whether any particular application is running or not, and if not, then run it.

In this post we are going to do that through QTP!!

Here we will check and run Internet Explorer, if not running already..


Dim flag, AllProcess, AppToRun
AppToRun = "iexplore.exe"
Flag = Flase
Set AllProcess = GetObject("winmgmts:")

For Each Process In AllProcess.InstancesOf("Win32_process")
    If (Instr ((Process.Name), AppToRun) = 1) Then
        Print "Internet Explorer is running.."
        Flag = Ture
        Exit For
    End If
Next


If Flag = Flase Then
    Print "Internet Explorer not is running.."
    SystemUtil.Run AppToRun
End If


You can do the same for any process/application. You just need to change the value of AppToRun variable. :)

Tuesday, January 24

Copy text from clipboard (ctrl+c) and store into string

Hello friends,

Sometimes you need to retrieve and store text/data from MS clipboard. Here is the simple code to achieve that..

Dim objCB
Set objCB= CreateObject("Mercury.Clipboard")
str_1 = objCB.GetText
MsgBox str_1