I found similar topic for other tool and I though it is a good idea to do it for QTP too.
It will be very nice to see the invaluable findings at one place.
May I urge other experts on this forum to contribute user define function
and the problem you faced and the tips to overcome.
Thanks ssvali for taking the initative.
Here is the first UDF from me.
This will close any running application from taskbar.
Code:
'***************************************************************************************************************************************************************
'Function : CloseProcess
'Author : Ankesh
'Reviewer :
'Version No :
'Date Created :
'Last Updated :
'Desc : Forecefully kills a process displayed on the task manager. StrProgramName should contain the process name with extension
'***************************************************************************************************************************************************************
Public Function CloseProcess(strProgramName)
Dim objShell
Set objShell = CreateObject("WScript.Shell")
objShell.Run "TASKKILL /F /IM " & strProgramName
Set objShell = Nothing
End Fun
'calling the function
Call CloseProcess("EXCEL.EXE") ''Closes excel
Call CloseProcess("Iexplore.EXE") ''Closes IE
'Similar way you can pass any application name running in taskmanager. Function will kill them all.
Regards,[/code]
Ankesh
Hi ,
Below is the function to capture screen shot of desktop
Code:
'***************************************************************************************************************************************************************
'Function : ScreenShot
'Author : ssvali
'Desc : It captures the screen shot of the desktop
'Parameter : ScrSht_Folder - Pass the path of the screenshot folder where u want save the screen shot
'***************************************************************************************************************************************************************
Function ScreenShot(ScrSht_Folder)
Dim sDateTimeNow, sFilePath
sDateTimeNow = Replace(Replace(now,"/","_")," ","_")
sFilePath = ScrSht_Folder &"\" &"ScreenShot_" &".png"
Desktop.CaptureBitmap sFilePath, True
ScreenShot = sFilePath
End Function
(06-08-2012, 06:28 PM)Ankesh Wrote: [ -> ]Thanks ssvali for taking the initative.
Here is the first UDF from me.
This will close any running application from taskbar.
Code:
'***************************************************************************************************************************************************************
'Function : CloseProcess
'Author : Ankesh
'Reviewer :
'Version No :
'Date Created :
'Last Updated :
'Desc : Forecefully kills a process displayed on the task manager. StrProgramName should contain the process name with extension
'***************************************************************************************************************************************************************
Public Function CloseProcess(strProgramName)
Dim objShell
Set objShell = CreateObject("WScript.Shell")
objShell.Run "TASKKILL /F /IM " & strProgramName
Set objShell = Nothing
End Fun
'calling the function
Call CloseProcess("EXCEL.EXE") ''Closes excel
Call CloseProcess("Iexplore.EXE") ''Closes IE
'Similar way you can pass any application name running in taskmanager. Function will kill them all.
Regards,[/code]
Ankesh