Sign in to follow this  
Followers 0
waskel

AutoIT can't see windows when screen saver enabled

2 posts in this topic

I've been playing with AutoIT for a few weeks, lurking here and picking up tips and tricks. I must say most all of my questions have been answered by searches - there seem to be some very helpful and knowledgeable folks here.

I have run into a problem I can't find any info on, so hopefully you can help me too.

My wife has an eBay business, and I'm developing a tracking and accounting system for her. I've written a couple scripts, one to login to ebay and paypal and refresh/request report downloads (at 3 am), and one to go back an hour later and fetch the reports.

Thanks to the information I've found here and the great help files in AutoIT the scripts work great. As long as I'm there to watch them, that is.

We share one computer, using windows fast user switching. If it is in screen saver (I'm logged in but not the active user) the script will launch, open the IE window and navigate to the login screen. Then it just sits there, as though it can't 'see' the window, even though it's active. When I log back in the IE window is there, on top, and the script is paused.

I've tried the following scenarios:

Setting a 'sleep' at the beginning (without the timers currently in the script), executing the script, then putting the pc into screen saver mode.

Compiling the script, executing the .EXE file, then putting the pc into screen saver mode.

Running the .EXE thru windows 'task scheduler' while in screen saver mode.

Running the .EXE as a service using the great script written by PTREX.

All had the same result - I go in later, the script is paused and there's an IE window sitting at the login page. ;)

Will AutoIT 'read' IE windows in this situation? Seems like it must, from what I've read, but I can't tell if I'm missing some crucial yet obscure command.

Here's the code for the script to fetch the reports (if some commands seem superfluous, they are there to deal with the vagaries of ebay programmers - they are nothing if not inconsistent...) .

CODE
#include <IE.au3>

Opt("WinDetectHiddenText",1)

Opt("WinTitleMatchMode",2)

Opt("WinTextMatchMode",1)

$iRunTime = "03:00"

$itesttime = $iRunTime

While 1

$mytime = @HOUR & ":" & @MIN

if $mytime = $iRunTime Then

;if $iRuntime = $itesttime Then

$oIE = _IECreate("http://k2b-bulk.ebay.com/ws/eBayISAPI.dll?SMProViewReport&viewType=1&viewMode=0&selectMonthId=19")

$oTitle = WinGetTitle("eBay")

$iGoodLink = ""

_IELoadWait($oIE)

sleep(2000)

If WinExists("Welcome to eBay") then

WinActivate("Welcome to eBay")

$iGoodLink = "Sign in"

else

$oLinks = _IELinkGetCollection ($oIE)

$oText1 = "Sign in"

$oText2 = "Sign out"

For $oLink In $oLinks

If StringInStr(String($oLink.innerText), $oText1) then

$iGoodLink = "Sign in"

_IEAction($oLink,"click")

ExitLoop

EndIf

If StringInStr(String($oLink.innerText), $oText2) then

$iGoodLink = "Sign out"

ExitLoop

EndIf

Next

EndIf

if $iGoodLink = "Sign in" then ebay_login_func()

;Sales Report

sleep(2000)

WinWait("My eBay Selling Manager Pro Reporting","100%")

If Not WinActive("My eBay Selling Manager Pro Reporting") Then WinActivate("My eBay Selling Manager Pro Reporting")

WinWaitActive("My eBay Selling Manager Pro Reporting")

; Check to make sure DOWNLOAD link exists - if not, the report is not ready

$oLinks = _IELinkGetCollection ($oIE)

$oText = "Download"

For $oLink In $oLinks

If StringInStr(String($oLink.innerText), $oText) then

_IELinkClickByText ($oIE, "Download")

WinWait("File Download","Do you want to open or save this file?")

If Not WinActive("File Download","Do you want to open or save this file?") Then WinActivate("File Download","Do you want to open or save this file?")

WinWaitActive("File Download","Do you want to open or save this file?")

Send("s")

WinWait("Save As","")

If Not WinActive("Save As","") Then WinActivate("Save As","")

WinWaitActive("Save As","")

sleep(500)

Send("C:\Documents and Settings\All Users\Documents\Ebay drop zone\SMProSalesReport.csv{ENTER}y")

exitloop

EndIf

Next

; Sales Report end

;Sold report

_IENavigate($oIE,"http://k2b-bulk.ebay.com/ws/eBayISAPI.dll?SMDownloadPickup")

WinWait("My eBay File Exchange","")

If Not WinActive("My eBay File Exchange","") Then WinActivate("My eBay File Exchange","")

WinWaitActive("My eBay File Exchange","")

_IELinkClickByText($oIE,"Download",0)

WinWait("File Download","")

If Not WinActive("File Download","") Then WinActivate("File Download","")

WinWaitActive("File Download","")

Send("s")

WinWait("Save As","")

If Not WinActive("Save As","") Then WinActivate("Save As","")

WinWaitActive("Save As","")

sleep(500)

Send("C:\Documents and Settings\All Users\Documents\Ebay drop zone\Sold.csv{ENTER}y")

sleep(500)

_IELinkClickByText($oIE,"Sign out",0)

sleep(5000)

Winclose("You've signed out")

sleep (60000)

Else

sleep (60000)

EndIf

wend

Func ebay_login_func()

if WinActive("Welcome to eBay") then

$o_form = _IEFormGetObjByName($oIE, "SignInForm")

$o_login = _IEFormElementGetObjByName($o_form, "userid")

$o_password = _IEFormElementGetObjByName($o_form, "pass")

; Set field values and submit the form

_IEFormElementSetValue($o_login, "USERID")

_IEFormElementSetValue($o_password, "PASSWORD")

sleep(2000)

_IEFormSubmit($o_form,0)

EndIf

EndFunc

Any help would be greatly appreciated - I can't afford to pull out any more hair. Just knowing whether or not this can be done would be a relief....

Thanks in advance!

Share this post


Link to post
Share on other sites



Nothing, hmmm... not even a "stupid noob, you just have to (fill in the blank)"...

Drat, I was hoping to get this fixed tonight.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0