06-03-2012, 01:57 AM
Hi Friends,
I have developed an utility which will keep the system unlocked until the QTP is launched (opened). This utility will also provide the ability for user to stop utility at any time, by default you can see the dialog with this option for every 2 minutes. You can configure this based on your needs.
When ever user clicks on "yes" button then the utility will stop it's execution.
Save the below code as "SystemUnlockBasedOnQTP.vbs" in the system where the scripts will be executed, and run the utility before start executing the script. Once you are done with script execution you can click on the "Yes" button on the popup window thrown by utility to stop the utility execution.
Note: Execute this utility on the machine where QTP is executing.
Code Snippet:
Please let me know if you need any further informaiton/suggestions.
I have developed an utility which will keep the system unlocked until the QTP is launched (opened). This utility will also provide the ability for user to stop utility at any time, by default you can see the dialog with this option for every 2 minutes. You can configure this based on your needs.
When ever user clicks on "yes" button then the utility will stop it's execution.
Save the below code as "SystemUnlockBasedOnQTP.vbs" in the system where the scripts will be executed, and run the utility before start executing the script. Once you are done with script execution you can click on the "Yes" button on the popup window thrown by utility to stop the utility execution.
Note: Execute this utility on the machine where QTP is executing.
Code Snippet:
Code:
Dim objWSH,objQTP
Set objQTP = CreateObject("QuickTest.Application") 'Create QTP object to check QTP launched status
Set objWSH = CreateObject("WScript.Shell") 'Create shell object to simulate keyboard event so that the system will not go to sleep/lock mode
objWSH.Popup "Utility has started successfully.",3,"Keep System Unlocked",0+64
'Check for Launched QTP, if QTP is not launched we won't execute this utility.
If objQTP.Launched = False Then
objWSH.Popup "This utility is stopped as the QTP is not opened.",10,"Keep System Unlocked",0+64
Else
boolQTP = True
Do While boolQTP = True
On Error Resume Next
If objQTP.Launched = False Then
On Error GoTo 0
boolQTP = False
objWSH.Popup "This utility is stopped as the QTP closed.",10,"Keep System Unlocked",0+64
End If
objWSH.SendKeys "{CAPSLOCK}" ' Click on CAPSLock
WScript.Sleep 100 'this is line is only useful to confirm that capslock event is fired while debuggin.commenting this line is optional.
objWSH.SendKeys "{CAPSLOCK}" 'Reset back the CAPSLock
WScript.Sleep 120000 ' wait for 120 seconds. Modify this wait time based on your system settings.
'popup message for user to decide whether want to continue with this utility.Utility will stop working if user click on "yes" button.
response = objWSH.Popup("This utility will keep your system unlocked while QTP is opened.Do you want to stop this utility?",3,"Keep System Unlocked",3+32)
'Stop utility based on user selection in the popup.
If response = 6 Then
Exit DO
End If
Loop
End If
'Clear the objects
Set objWSH = Nothing
Set objQTP = Nothing
Please let me know if you need any further informaiton/suggestions.
Thanks,
SUpputuri
SUpputuri