Jump to content

Hide SaveAs Win when Downloading


Recommended Posts

I have an application here at work that DLs several files from a firm's website. It allows them to select the accounts they want to process and how, then it gets on the site and process what they specified and downloads the files.

I have been using BlockInput() during the windows "File Download" and "Save As", but this is annoying people here. I thought that I could do the following, but it's not doing the trick. Any ideas?

Local $winTitle = 'File Download'
WinWait($winTitle)
;Local $winHwd = WinGetHandle($winTitle)
WinSetState($winTitle,'',@SW_DISABLE)
WinSetState($winTitle,'',@SW_HIDE)
ControlClick($winTitle,'','Button2')
WinSetState($winTitle,'',@SW_DISABLE)
WinSetState($winTitle,'',@SW_HIDE)
    
Local $File = @MyDocumentsDir&'\~0TEST.cvs'; << just an example
FileDelete($File)
    
;Opt('WinTitleMatchMode',4)
;Local $winTitleClass= '#32770'
Local $winTitle = 'Save As'
WinWait($winTitle)
;Local $winHwd = WinGetHandle($winTitle)
Local $winText = '';
WinSetState($winTitle,$winText,@SW_DISABLE)
WinSetState($winTitle,$winText,@SW_HIDE)
ControlSetText($winTitle,$winText,'Edit1',$File)
ControlClick($winTitle,$winText,'Button2')
WinSetState($winTitle,$winText,@SW_DISABLE)
WinSetState($winTitle,$winText,@SW_HIDE)
A decision is a powerful thing
Link to comment
Share on other sites

By the way, the problem is I can't just use INetGet() or similar method because the file is generated on the site not just directly available.

I don't really care as much to hide it as much as to prevent the user from accidentally clicking something while there waiting for the files to download. What I mean is that the program does all the site processing and they'll usually do other things while it does that. I had it (like I said) notify them right before it did BlockInput(), but this would get annoying some times.

A decision is a powerful thing
Link to comment
Share on other sites

Perhaps you can be more explicity about "but it's not doing the trick".

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Perhaps you can be more explicity about "but it's not doing the trick".

Dale

My bad I thought I was :) and thank you

I mean it's not hiding or at least disabling the File Download and Save As windows. My code above attempts to hide and disable those windows (ie. "the trick" - my slang, which is confusing), but does not accomplish it. I just don't want them to accidentally click something in those windows or pull focus from where they are typing. The Hiding isn't important, just a nice effect. The program sets up all the Save As info for them, considering they do it in specific groupings.

I hope that clarifies

A decision is a powerful thing
Link to comment
Share on other sites

Local $oIE = ObjCreate('InternetExplorer.Application')
$oIE.visible=1
$oIE.Navigate('http://mozilla.isc.org/pub/mozilla.org/firefox/releases/2.0.0.7/win32/en-US/Firefox%20Setup%202.0.0.7.exe')

;Local $winHwd = WinGetHandle($winTitle)
Local $winTitle = 'File Download - Security Warning'
WinWait($winTitle)
WinSetState($winTitle,'',@SW_DISABLE)
WinSetState($winTitle,'',@SW_HIDE)
ControlClick($winTitle,'','Button2')
WinSetState($winTitle,'',@SW_DISABLE)
WinSetState($winTitle,'',@SW_HIDE)

Local $File = @MyDocumentsDir&'\~0TEST.EXE'
FileDelete($File)

;Opt('WinTitleMatchMode',4)
;Local $winTitleClass= '#32770'
Local $winTitle = 'Save As'
WinWait($winTitle)
;Local $winHwd = WinGetHandle($winTitle)
Local $winText = '';'Save &in:'&@LF&'Desktop'&@LF&'FolderView'&@LF&'File &name:'&@LF&'Firefox Setup 2.0.0.7.exe'&@LF&'Firefox Setup 2.0.0.7.exe'&@LF& _ 
;'Save as &type:'&@LF&'Application'&@LF&'&Save'&@LF&'Cancel'
WinSetState($winTitle,$winText,@SW_DISABLE)
;WinSetState($winTitle,$winText,@SW_HIDE)
Sleep(3000)
ControlSetText($winTitle,$winText,'Edit1',$File)
WinSetState($winTitle,$winText,@SW_DISABLE)
;WinSetState($winTitle,$winText,@SW_SHOW)
Sleep(5000)
ControlClick($winTitle,$winText,'Button2')
WinSetState($winTitle,$winText,@SW_DISABLE)
;WinSetState($winTitle,$winText,@SW_HIDE)

With the sleeps in there it seems to work. Obviously, this is a shortened form of what I'm doing, with this downloading an exe instead of a generated csv.

A decision is a powerful thing
Link to comment
Share on other sites

It seems to be closing the window before

Run('Notepad.exe')
Local $WinTitle = 'Untitled - Notepad'
WinWait($WinTitle)
Sleep(1*1000)
ControlSend($WinTitle,'','Edit1',"Start typing fast and don't stop. You'll notice that you some times will cancel the downloading process"&@CRLF)
Sleep(10*1000)

Local $oIE = ObjCreate('InternetExplorer.Application')
$oIE.visible=1
$oIE.Navigate('http://mozilla.isc.org/pub/mozilla.org/firefox/releases/2.0.0.7/win32/en-US/Firefox%20Setup%202.0.0.7.exe')

;Opt('WinTitleMatchMode',4)
Local $winTitle = '0% of ...Firefox%20Setup%202.0.0.7.exe from mozilla.isc.org Completed';<<<<<<< The first window
;Local $winTitle = '#32770'
WinWait($winTitle)
WinSetState($winTitle,'',@SW_DISABLE)

Opt('WinTitleMatchMode',1)
;Local $winHwd = WinGetHandle($winTitle)
Local $winTitle = 'File Download - Security Warning'
WinWait($winTitle)
WinSetState($winTitle,'',@SW_DISABLE)
;WinSetState($winTitle,'',@SW_HIDE)
ControlClick($winTitle,'','Button2')
WinSetState($winTitle,'',@SW_DISABLE)
;WinSetState($winTitle,'',@SW_HIDE)

Local $File = @MyDocumentsDir&'\~0TEST.EXE'
FileDelete($File)


;Opt('WinTitleMatchMode',4)
;Local $winTitleClass= '#32770'
Local $winTitle = 'Save As'
WinWait($winTitle)
;Local $winHwd = WinGetHandle($winTitle)
Local $winText = '';'Save &in:'&@LF&'Desktop'&@LF&'FolderView'&@LF&'File &name:'&@LF&'Firefox Setup 2.0.0.7.exe'&@LF&'Firefox Setup 2.0.0.7.exe'&@LF& _ 
;'Save as &type:'&@LF&'Application'&@LF&'&Save'&@LF&'Cancel'
WinSetState($winTitle,$winText,@SW_DISABLE)
;WinSetState($winTitle,$winText,@SW_HIDE)
Sleep(3*1000)
ControlSetText($winTitle,$winText,'Edit1',$File)
WinSetState($winTitle,$winText,@SW_DISABLE)
;WinSetState($winTitle,$winText,@SW_SHOW)
Sleep(5*1000)
ControlClick($winTitle,$winText,'Button2')
WinSetState($winTitle,$winText,@SW_DISABLE)
;WinSetState($winTitle,$winText,@SW_HIDE)

When you're typing in Notepad, hit enter a lot and it seems to hit the default button in the first window ('0% of ...Firefox%20Setup%202.0.0.7.exe from mozilla.isc.org Completed'), which is the cancel button.

:) Any ideas?

A decision is a powerful thing
Link to comment
Share on other sites

Here's my pseudo-working method, but it's messy and doesn't seem to work too well.

Any suggestions?

AdlibEnable('Watch',100)
Run('Notepad.exe')
Local $WinTitle = 'Untitled - Notepad'
WinWait($WinTitle)
Sleep(1*1000)
ControlSend($WinTitle,'','Edit1',"Start typing fast and don't stop. You'll notice that you some times will cancel the downloading process"&@CRLF)
Local $ActiveWinTitle = WinGetTitle("")
WinSetOnTop($ActiveWinTitle,'',1)
Sleep(2*1000)


Local $File = @MyDocumentsDir&'\~0TEST.EXE'
FileDelete($File)

Local $ActiveWinTitle = WinGetTitle("")
WinSetOnTop($ActiveWinTitle,'',1)
Local $oIE = ObjCreate('InternetExplorer.Application')
$oIE.visible=0
$oIE.Navigate('http://mozilla.isc.org/pub/mozilla.org/firefox/releases/2.0.0.7/win32/en-US/Firefox%20Setup%202.0.0.7.exe')

TrayTip('Test','User Input will be blocked for a moment',1)
BlockInput(1)
Local $winTitle = '0% of ...Firefox%20Setup%202.0.0.7.exe from mozilla.isc.org Completed'
WinWait($winTitle)
WinSetState($winTitle,'',@SW_DISABLE)
BlockInput(0)
TrayTip('','',0)

Local $ActiveWinTitle = WinGetTitle("")
WinSetOnTop($ActiveWinTitle,'',1)
Local $winTitle = 'File Download - Security Warning'
WinWait($winTitle)

WinSetState($winTitle,'',@SW_DISABLE)
WinSetState($winTitle,'',@SW_HIDE)
ControlClick($winTitle,'','Button2')
WinSetState($winTitle,'',@SW_DISABLE)
WinSetState($winTitle,'',@SW_HIDE)

Local $ActiveWinTitle = WinGetTitle("")
WinSetOnTop($ActiveWinTitle,'',1)
Local $winTitle = 'Save As'
WinWait($winTitle)
Local $winText = ''
WinSetState($winTitle,$winText,@SW_DISABLE)
WinSetState($winTitle,$winText,@SW_HIDE)
ControlSetText($winTitle,$winText,'Edit1',$File)
WinSetState($winTitle,$winText,@SW_DISABLE)
WinSetState($winTitle,$winText,@SW_SHOW)
ControlClick($winTitle,$winText,'Button2')
WinSetState($winTitle,$winText,@SW_DISABLE)
WinSetState($winTitle,$winText,@SW_HIDE)

WinSetOnTop($ActiveWinTitle,'',0)

While 1 
    Sleep(10)
WEnd
Func Watch()
    Opt('WinTitleMatchMode',1)
    If WinExists('Download complete') Then
        ControlClick('Download complete','','Button4')
        Exit
    Else
        Opt('WinTitleMatchMode',2)
        Local $partialWinTitle = '% of ...'
        WinSetState($partialWinTitle,'',@SW_DISABLE)
        WinSetState($partialWinTitle,'',@SW_HIDE)
    EndIf
    Local $winTitle = '0% of ...Firefox%20Setup%202.0.0.7.exe from mozilla.isc.org Completed'
    WinSetState($winTitle,'',@SW_DISABLE)
    WinSetState($winTitle,'',@SW_HIDE)
    Local $winTitle = 'File Download - Security Warning'
    WinSetState($winTitle,'',@SW_DISABLE)
    WinSetState($winTitle,'',@SW_HIDE)
    Local $winTitle = 'Save As'
    WinSetState($winTitle,'',@SW_DISABLE)
    WinSetState($winTitle,'',@SW_HIDE)
EndFunc
A decision is a powerful thing
Link to comment
Share on other sites

  • Moderators

Wasn't it you that had this issue when you very first joined the forum? I thought we had a working solution for it?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Wasn't it you that had this issue when you very first joined the forum? I thought we had a working solution for it?

Smoke_N, I may have asked a similar question in the past (which I could find just now), but it wasn't resolved (to my knowledge) in the sense that I had to use BlockInput(). Nonetheless, I don't remember asking this question before.

Edited by JohnBailey
A decision is a powerful thing
Link to comment
Share on other sites

  • Moderators

Smoke_N, I may have asked a similar question in the past (which I could find just now), but it wasn't resolved (to my knowledge) in the sense that I had to use BlockInput(). Nonetheless, I don't remember asking this question before.

Taking a stab in the dark... I remember helping someone with it.... but for the life of me, can't remember who or how long ago... Not even the function name (If I used one at all) to do an advanced search on.

I'm curious though... If you can browse it by browser, why can't you access it by FTP or InetGet? Is it a permission thing that your script isn't demonstrating?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Taking a stab in the dark... I remember helping someone with it.... but for the life of me, can't remember who or how long ago... Not even the function name (If I used one at all) to do an advanced search on.

I'm curious though... If you can browse it by browser, why can't you access it by FTP or InetGet? Is it a permission thing that your script isn't demonstrating?

First, I must thank you for trying to remind me if you had helped me in the past. I did search through my posts and could not find that I've discussed this in length and/or if was resolved (without using BlockInput).

For the browsing, the site is using ASP, so the csv is "generated" and requires a session logon :) (I'm not sure if that's the correct wording) I would totally post the url and all the access info for testing reasons if it wouldn't get me fired and harm a WHOLE lot of our clients. The company we get the data from is REALLY slow at doing anything and currently does not have FTP access or anything. It is intentionally not a direct link due to security reasons. Does that make any sense... I'm trying to explain why-in-the-world I'm bottled into having to use a navigation method.

A decision is a powerful thing
Link to comment
Share on other sites

  • Moderators

I must have misread what you wrote, it's not meant to disable it... It's mean to just download and save the file.

You could always use ControlHide()/ControlShow() or ControlDisable()/ControlEnable() with what I sent you the link to I suppose?

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

A second idea you may try is this:

Have the download window come up

right away hide it, and replace it with a window that has the controls you want.

Your controls would link to the download window, allowing what you want, but only that.

Indeed, however, the only reason I want to hide and disable the Download Window is prevent from the user accidentally clicking cancel or typing in the savetolocation edit area.

A decision is a powerful thing
Link to comment
Share on other sites

Drat ... We're just going to run this on a different machine. Thanks guys though for your help. The poor chaps that have to run it on their machine will just have to have their system lock periodically while it downloads each file. As for the bossman, he'll just run it on a different machine somewhere here.

thanks guys

If anyone comes up with an idea, I'd be very grateful! I can't believe MS has made this so difficult. Haha, I mean I can and understand basically why they have (thanks Dale for explaining that), but bummer you know.

A decision is a powerful thing
Link to comment
Share on other sites

IE.au3 has an undocumented function called __IELockSetForegroundWindow() that you may be able to use. You can use it to keep a new window from taking focus... a parameter of 1 will lock the window currently in focus, allow you to bring up a new window and then pass a value of 2 to return normal behavior.

Valik wrote this for IE.au3 so taht invisible instances of IE could be prevented from stealing focus when they started.

Give it a shot with some of the other techniques you have here and you should be able to avoid the BlockInput scenario.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...