si je lance mon script vbs directement depuis la machine qui héberge
le script, les commande sendkeys focntionne parfaitement. le focus sur
bouton est OK (encadré pointillé) et mon script se déroule
parfaitement.
Si je lance le script depuis une machine distante vers le pc
hébergeant le script; le focus n'est plus présent (aucun encadré
pointillé sur les boutons) donc mes sendkeys ne sont plus valides!!
comment faire pour récupérer le focus et l'encadré pointillé?
===========
Let's have a look at your script!
You are likely to get more replies if you post your question
in English or if you post it in a French newsgroup.
Ok just do it!! i try
I have a script that uses IE to download files on the sites and many
actions (save as by dialog box, close box etc..)
If I run the script on the PC, it works perfectly. Buttons have the
focus and sendkeys work perfectly.
If I run the script from a remote PC, lauched by a software of "run
book automation", or a "scheduler", the script run and open web page,
but I lost focus on the button of the dialog box type "save as" when
a link is lanched ... all this actions are organised by sendkeys
commands in my script vbs.
for example in my code :
dim document
Set ie = CreateObject("InternetExplorer.application")
ie.Navigate "http://www.mysite"
ie.visible=true
Do While ie.Busy
wscript.sleep (20)
Loop
wscript.sleep (20)
'msgbox ie.document.links.length
zipfile = ie.document.links(5).tostring ' number of Link of my zip
file
dim oFSO, Fichier
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set file = oFSO.CreateTextFile("C:\test\urlzip.txt", True) ' write my
link in text file
file.write (zipfile)
ie.navigate (zipfile) ' open link for download zip file
wscript.sleep 30000
set WshShell1 = WScript.CreateObject("WScript.Shell")
WshShell1.AppActivate ("Téléchargement de fichier") ' ---> DIALOG BOX
here , not activate finally
wshShell1.SendKeys ("{ENTER}")
wscript.sleep 2000
wshShell1.SendKeys ("{TAB 2}")
wscript.sleep 2000
wshShell1.SendKeys("{ENTER}")
wscript.sleep 60000
wshShell1.SendKeys ("{TAB 3}")
wshShell1.SendKeys("{ENTER}")
wscript.quit
any ideas? many thanks
dim document
wscript.quit
======================
I found the AppActivate method to be quite unreliable. Take
the following example: Instead of coding
WshShell1.AppActivate("Téléchargement de fichier")
wscript.sleep(2000)
I often do this:
While Not WshShell1.AppActivate("Téléchargement de fichier")
WScript.Sleep(200)
Wend
But even then my script sometimes fails to work, e.g. because
the appliction is windowed instead of maximised or because
some unexpected pop-up dialog box (such as a virus scanner
notification) grabs the focus.
AutoIt (http://groups.yahoo.com/group/autoit) is a little more
reliable than the plain wscript.sendkeys method. However, if
you want a robust application then you must look for a
solution that does not involve AppActivate and keyboard
macros.
thanks, but in vbs, it is possible download file from IE ? other
methods? search but not found!
wget.exe http://SomeSite/SomeFolder/SomeFile.txt
If you prefer to do it in VB Script then you can, of course
use the Exec or the Run method of the Wscript.Shell object.
Or possibly use something like this ...
' Source Michael Harris & Alex K. Angelopoulos
' modified by TGL May 2003
' http://groups.google.com/groups?selm=OxJBkB8xCHA.2120%40TK2MSFTNGP11
&
' http://www.google.com/groups?selm=%23v1%23CmirAHA.2132%40tkmsftngp05
' FilePath is location to store retrieved web item
' sURL is location of web item
Sub DownBinFile(FilePath, sURL)
const adTypeBinary = 1
const adModeReadWrite = 3
const adSaveCreateOverwrite = 2
' Create an xmlhttp object:
set oXML = CreateObject("MSXML2.XMLHTTP")
oXML.open "GET", sURL, False
oXML.send
With CreateObject("ADODB.Stream")
.type = adTypeBinary
.mode = adModeReadWrite
.open
Do Until oXML.readyState = 4 : Wscript.Sleep 50 : loop
.write oXML.responseBody
.savetofile FilePath, adSaveCreateOverwrite
End With
End Sub
Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/
Yes Ok, many thanks for this tips, working by xml method
Sorry, it's working on Windows XP, but on windows 2000, not; because
object MSXML2.XMLHTTP or Microsoft.XMLHTTP??
my CPU usage increase to 100% and zipfile aren't downloaded?
have you already see that? thanks
hi,
if someone, kowns this problem?
-> on windows Xp = OK
-> on Windows server 2000 = NOK (Full CPU usage at 100% when adodb
stream is running) ??
many thanks