Micro Focus QTP (UFT) Forums
problem withuploading files when windows is locked - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: problem withuploading files when windows is locked (/Thread-problem-withuploading-files-when-windows-is-locked)



problem withuploading files when windows is locked - caze - 12-16-2009

hi all ,

i have an application in which i have upload files functionality. i automated it and it works well until windows is not locked.But if windows is locked and scripts run, QTP can not upload files and throws an error "object not found..."
not only upload dialog box but also for other dialog boxes QTP gets struck.

i goggled for the solution and i got following code snippets ,just to close a dialog box when windows is locked:

Code:
Public Const WM_COMMAND=273
Extern.Declare micLong, "PostMessage", "user32.dll", "PostMessageA", micHwnd, micLong, micLong, micLong
windowTitle = "message from browser " 'change it for different dialog box
buttonCode = 1 ' 1- OK, 2 Cancel in this dialog. It is "window id" property of the Button that you need to click - use Object Spy
Hwnd = Window("regexpwndtitle:="&windowTitle).GetRoProperty("hwnd")
lResult = extern.PostMessage(Hwnd, WM_COMMAND, buttonCode, 0)


this really helped me a lot But i got struck once again when it was a time to 'choose a file'/'type a file name' in "CHOOSE FILE TO UPLOAD" dialog box.

could any one explore his/her ideas on this issue?


RE: problem withuploading files when windows is locked - satan - 12-16-2009

you can use caffeine tool to prevent your system from locking.
startup the caffeine tool from qtp when you begin execution of scripts like this:
Code:
InvokeApplication "{path of caffeine in your PC} -startoff"
wait(2)
InvokeApplication "{path of caffeine in your PC} -appon"

and when ur execution complete stop caffeine
InvokeApplication "{path of caffeine in your PC} -appexit"



RE: problem withuploading files when windows is locked - Saket - 12-17-2009

Hi Caze,
QTP can not perform operations when your system is locked. you should find out a way same as Satan suggested to prevent your system from locking.


RE: problem withuploading files when windows is locked - caze - 12-17-2009

hi @ saket,
i took help of descriptive programing and its working even if my system is locked.
what satan suggested is also a good and esay idea.
thanks satan,saket.
hi @ satan,

will caffeine work if i schedule a task at night 1'clk when window is locked?


RE: problem withuploading files when windows is locked - satan - 12-17-2009

caffeine is a tool which will prevent you from locking.
but it is of no use once system is locked.
there is a work around that u can implement.
like start caffeine and leave your system unlocked.
use your scheduler to call qtp at any point later on.