0
votes

I have a proprietary software that I use to download some confidential data from the internet, this software is the only way to access that data.

The software opens up with a screen and then I have to click on "download" and the download commences. I would like to download this data late-night (say 0200 Hrs) every night. The downside was that I had to sit in front of the laptop to "click" on the download button.

So, I wrote an AutoIt script to open the software, wait for 30 seconds so that the software finishes the initialisation routine and then "go to" a certain location (co-ordinates) on the screen and execute a "mouseclick()". I then created a "scheduled task" using windows task scheduler to run this autoit executable at 0200 Hrs. Every thing works fine, as expected.

Autoit executable runs well when the user is "active". But if the user is "locked" (i.e. lock screen) then it is stuck in "WinActivate()" waiting for the user to become "Active" and resumes from there on after the user becomes "active". This means the laptop has to be in unlocked mode overnight which is not advisable for security reasons. I then found out that I could use "ControlClick()" to do the same when the screen is locked.

My problem now is that when I use AutoIt Window Info tool, it does not show the CLASS or any info related to download button when I hover over the download button. So, may be the screen is a flash screen or something else that was intentionally made to make sure that button CLASS was not seen!

An option would be to take a screenshot, find the location and then send the coords to Mouseclick() but that could easily get way more complicated considering different screen resolution on different machines (in case this gets ported to another machine etc etc)

Any suggestions and solutions?

1
The Windows GUI behaves erratically when the workstation is locked. Perhaps you could run the software in a virtual machine, so you could lock only the physical computer and not the virtual one?Harry Johnston
@HarryJohnston, i had not thought of virtual machines. I will try that out. Would AutoIt scripts work seamlessly on VMs?user2979010
Some virtualization products might implicitly lock the virtual workstation if you close the virtual console. But otherwise, there shouldn't be any problems.Harry Johnston
Try the spy that comes with this library autoitscript.com/forum/topic/… If you can see controls with this, you'll have to use this library to automate the window. I've had many windows I could not automate with AutoIt but worked perfectly when I used this library. If it works let me know and I will add this comment as answer.Jos van Egmond
@JosvanEgmond, Will give that a try but I suspect my application screen is flash and its not easy to "see the controls". I will get back to this question/comment in 2-3 weeks time and will certainly update on its progress.user2979010

1 Answers

1
votes

WinActivate() will wait until the user is activated to activate the window and then return and it is a blocking function in this case so avoid it. Keep your VB application in the background, not minimized and remove WinActivate() function. ControlClick doesn't need the window to be active.

This should work with the right handle name and class name:

HotKeySet("!{s}", "_exit")
Local $count = 0
Local $handle

While $count < 3
    Sleep(5000)
    $handle = ControlGetHandle("name", "", "[CLASS:ThunderRT6FormDC]")   ;add name as well if there is one
    If $handle Then     ;check if handle exists
        ConsoleWrite("Handle exists" & @LF)
        ControlClick($handle, "", "[CLASS:Classhere]", "left", 1, 191, 115)   ;add a class if exists
    EndIf
    ConsoleWrite("Try: "  & $count & " times" & @LF)
    $count += 1
WEnd

Func _exit()
    ConsoleWrite("Exiting!" & @LF & "Tried: " & $count & @LF)
    Exit
EndFunc

The informations you gave me from the autoit info tool arent enough. Use some other tool to get more information. Spy++ is a great tool. Try it out and come back with more information about the windows handle name and classes.

And again you are giving a few informations about your code. This example should performe a control click but you may have other function besides winactivate that will block your script again

Edit: Added Tesseract OCR UDF: http://www.autoitscript.com/forum/topic/89542-tesseract-screen-ocr-udf/