Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Focus bouton pointillé sur boite de dialogue

27 views
Skip to first unread message

Winston75

unread,
Apr 21, 2008, 6:21:28 AM4/21/08
to
Bonjour,

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é?

Pegasus (MVP)

unread,
Apr 21, 2008, 6:37:20 AM4/21/08
to

"Winston75" <baptist...@gmail.com> wrote in message
news:ad05d226-b430-4d2d...@24g2000hsh.googlegroups.com...
Bonjour,

===========

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.


Winston75

unread,
Apr 21, 2008, 7:43:52 AM4/21/08
to
On 21 avr, 12:37, "Pegasus \(MVP\)" <I....@fly.com.oz> wrote:
> "Winston75" <baptiste.fe...@gmail.com> wrote in message


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


Pegasus (MVP)

unread,
Apr 21, 2008, 8:39:08 AM4/21/08
to

"Winston75" <baptist...@gmail.com> wrote in message
news:ceed20e6-f5cd-46c7...@y22g2000prd.googlegroups.com...


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.


Winston75

unread,
Apr 21, 2008, 10:25:13 AM4/21/08
to
> macros.- Masquer le texte des messages précédents -
>
> - Afficher le texte des messages précédents -

thanks, but in vbs, it is possible download file from IE ? other
methods? search but not found!

Pegasus (MVP)

unread,
Apr 21, 2008, 10:33:36 AM4/21/08
to
thanks, but in vbs, it is possible download file from IE ? other
methods? search but not found!
============
The standard tool to download files from a web page is
wget.exe, e.g. like so:

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.


Tom Lavedas

unread,
Apr 21, 2008, 11:02:21 AM4/21/08
to
On Apr 21, 10:33 am, "Pegasus \(MVP\)" <I....@fly.com.oz> wrote:
> thanks, but in vbs, it is possible download file from IE ? other
> methods? search but not found!
> ============
> The standard tool to download files from a web page is
> wget.exe, e.g. like so:
>
> wget.exehttp://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/

Winston75

unread,
Apr 21, 2008, 11:30:51 AM4/21/08
to

Yes Ok, many thanks for this tips, working by xml method

Winston75

unread,
Apr 21, 2008, 1:01:40 PM4/21/08
to
> Yes Ok,  many thanks for  this tips, working by xml method- Masquer le texte des messages précédents -

>
> - Afficher le texte des messages précédents -

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

Winston75

unread,
Apr 22, 2008, 5:29:41 AM4/22/08
to
> have you already see that?  thanks- Masquer le texte des messages précédents -

>
> - Afficher le texte des messages précédents -

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

0 new messages