Jump to the post that solved this thread.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Utiity which will keep the system unlocked based on QTP launced status
#1
Solved: 11 Years, 3 Months, 3 Weeks ago
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:
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
Reply
#2
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi Guys,

Small update in the code.
Replace this line
objWSH.SendKeys "{CAPSLOCK}" 'Reset back the CAPSLock
to click on printscrn so that it does not impact any input data of your test.
Thanks,
SUpputuri
Reply
Jump to the post that solved this thread.


Possibly Related Threads…
Thread Author Replies Views Last Post
  ALM execution status Update patilnagarjuna92 1 3,086 03-18-2019, 08:09 PM
Last Post: Gurusamy
  How to avoid system lock while running Windows Based Application SaranKumarV 6 21,666 03-21-2018, 04:18 PM
Last Post: blr.moin@gmail.com
  System work slow with UFT 12.02 elyanivson 0 2,768 02-10-2015, 05:09 PM
Last Post: elyanivson
  Using OR created in one system, not able to execute the test script in another system priyaang 4 3,473 03-27-2014, 11:02 PM
Last Post: priyaang
  IE 10 Load status sram3003 0 2,142 01-17-2014, 12:46 PM
Last Post: sram3003

Forum Jump:


Users browsing this thread: 1 Guest(s)