Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Re: automation of Windows Explorer search window

Reply
 
Old 05-28-2008   #1 (permalink)
Todd Vargo


 
 

Re: automation of Windows Explorer search window

Marceepoo wrote:
Quote:

> The vbscript below opens a Windows Explorer search window.
> The Windows Explorer search window has fields in which the user can insert
a
Quote:

> search String Filter, and a search path String.
> I can't figure out what code to use to insert:
> 1. A search filter string in the field entitled "All or part of the
file
Quote:

> name"; Or
> 2. A search path string in the field entitled: "Look in:"
>
> I tried using Sendkeys,
> (Alt-L = "Lookin in:" field)
> (Alt-O = Filename/filemask field, "All or part of the file name:")
> (Alt-R = "Search" button)
> But Sendkeys doesn't seem to trigger any action at all in the search
window.
Quote:

>
> Any suggestions would be much appreciated.
>
> Marceepoo
>
> Dim objShell
> Set objShell = WScript.CreateObject("Shell.Application")
> objShell.FindFiles
This should help...

Dim objShell, WshShell
Set objShell = WScript.CreateObject("Shell.Application")
set WshShell = WScript.CreateObject("WScript.Shell")
objShell.FindFiles
WScript.Sleep 500
WshShell.AppActivate "Find: All files"
WScript.Sleep 500
WshShell.SendKeys "foo{tab}bar{tab}"
WScript.Sleep 500
WshShell.SendKeys "c:\windows{enter}"

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)


My System SpecsSystem Spec
Old 05-29-2008   #2 (permalink)
Tom Lavedas


 
 

Re: automation of Windows Explorer search window

On May 28, 11:09 pm, "Todd Vargo" <tlva...@xxxxxx> wrote:
Quote:

> Marceepoo wrote:
Quote:

> > The vbscript below opens a Windows Explorer search window.
> > The Windows Explorer search window has fields in which the user can insert
> a
Quote:

> > search String Filter, and a search path String.
> > I can't figure out what code to use to insert:
> > 1. A search filter string in the field entitled "All or part of the
> file
Quote:

> > name"; Or
> > 2. A search path string in the field entitled: "Look in:"
>
Quote:

> > I tried using Sendkeys,
> > (Alt-L = "Lookin in:" field)
> > (Alt-O = Filename/filemask field, "All or part of the file name:")
> > (Alt-R = "Search" button)
> > But Sendkeys doesn't seem to trigger any action at all in the search
> window.
>
Quote:

> > Any suggestions would be much appreciated.
>
Quote:

> > Marceepoo
>
Quote:

> > Dim objShell
> > Set objShell = WScript.CreateObject("Shell.Application")
> > objShell.FindFiles
>
> This should help...
>
> Dim objShell, WshShell
> Set objShell = WScript.CreateObject("Shell.Application")
> set WshShell = WScript.CreateObject("WScript.Shell")
> objShell.FindFiles
> WScript.Sleep 500
> WshShell.AppActivate "Find: All files"
> WScript.Sleep 500
> WshShell.SendKeys "foo{tab}bar{tab}"
> WScript.Sleep 500
> WshShell.SendKeys "c:\windows{enter}"
>
> --
> Todd Vargo
> (Post questions to group only. Remove "z" to email personal messages)
Todd,

You use Win98, don't you? I ask because in XP, the FindFiles caption
is "Search Results" which points out one of the many problems with a
Sendkeys application.

The closest I could get to a usable (?) solution was something like
this ...

Dim objShell, WshShell
CreateObject("Shell.Application").FindFiles
with CreateObject("WScript.Shell")
do until .AppActivate("Find: All files") or _
.AppActivate("Search Results")
wsh.Sleep 500
Loop
wsh.Sleep 2000
if .AppActivate("Search Results") then _
.Sendkeys "{Tab 5}{enter}" : wsh.Sleep 200
.SendKeys "foo{tab}bar{tab}" : wsh.Sleep 200
.SendKeys "c:\windows"
end with

I still don't like it because of the open loop two second delay
required (on my machine) between confirming that the search screen was
open and the time the first keystroke could be sent reliably to it
(under XP). Without the delay, I kept opening the Internet search
function, instead.

This is a case where AutoIt (third party control - google search to
find a free copy) might be almost essential.

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/
My System SpecsSystem Spec
Old 05-29-2008   #3 (permalink)
Todd Vargo


 
 

Re: automation of Windows Explorer search window

Tom Lavedas wrote:
Quote:

> Todd Vargo wrote:
snip...
Quote:
Quote:

> > WshShell.AppActivate "Find: All files"
>
> Todd,
>
> You use Win98, don't you? I ask because in XP, the FindFiles caption
> is "Search Results" which points out one of the many problems with a
> Sendkeys application.
Thanks, I tend to forget to mention when code needs modified to suit an OPs
needs/OS. On the one hand, the code seems obvious (to me) so I forget, but
OTOH, SCRIPT56.CHM is available.

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

My System SpecsSystem Spec
Old 05-30-2008   #4 (permalink)
Keith Miller \(MVP\)


 
 

Re: automation of Windows Explorer search window

I just went to my XP machine & did a couple of searches, saved them, & then
examined the contents in notepad (hex editor would probably be better).

There is some binary gobbledygook but it seems to be constant -- and you
also see your search terms as both ascii & unicode strings.

You may be able to construct a saved search file with the terms you want &
then open that, avoiding the use of sendkeys.

--
Good Luck,

Keith
Microsoft MVP [Windows Shell/User]



"Tom Lavedas" <tglbatch@xxxxxx> wrote in message
news:dcea7a91-608e-4212-803c-6341cbc32d0e@xxxxxx
Quote:

> On May 28, 11:09 pm, "Todd Vargo" <tlva...@xxxxxx> wrote:
Quote:

>> Marceepoo wrote:
Quote:

>> > The vbscript below opens a Windows Explorer search window.
>> > The Windows Explorer search window has fields in which the user can
>> > insert
>> a
Quote:

>> > search String Filter, and a search path String.
>> > I can't figure out what code to use to insert:
>> > 1. A search filter string in the field entitled "All or part of the
>> file
Quote:

>> > name"; Or
>> > 2. A search path string in the field entitled: "Look in:"
>>
Quote:

>> > I tried using Sendkeys,
>> > (Alt-L = "Lookin in:" field)
>> > (Alt-O = Filename/filemask field, "All or part of the file name:")
>> > (Alt-R = "Search" button)
>> > But Sendkeys doesn't seem to trigger any action at all in the search
>> window.
>>
Quote:

>> > Any suggestions would be much appreciated.
>>
Quote:

>> > Marceepoo
>>
Quote:

>> > Dim objShell
>> > Set objShell = WScript.CreateObject("Shell.Application")
>> > objShell.FindFiles
>>
>> This should help...
>>
>> Dim objShell, WshShell
>> Set objShell = WScript.CreateObject("Shell.Application")
>> set WshShell = WScript.CreateObject("WScript.Shell")
>> objShell.FindFiles
>> WScript.Sleep 500
>> WshShell.AppActivate "Find: All files"
>> WScript.Sleep 500
>> WshShell.SendKeys "foo{tab}bar{tab}"
>> WScript.Sleep 500
>> WshShell.SendKeys "c:\windows{enter}"
>>
>> --
>> Todd Vargo
>> (Post questions to group only. Remove "z" to email personal messages)
>
> Todd,
>
> You use Win98, don't you? I ask because in XP, the FindFiles caption
> is "Search Results" which points out one of the many problems with a
> Sendkeys application.
>
> The closest I could get to a usable (?) solution was something like
> this ...
>
> Dim objShell, WshShell
> CreateObject("Shell.Application").FindFiles
> with CreateObject("WScript.Shell")
> do until .AppActivate("Find: All files") or _
> .AppActivate("Search Results")
> wsh.Sleep 500
> Loop
> wsh.Sleep 2000
> if .AppActivate("Search Results") then _
> .Sendkeys "{Tab 5}{enter}" : wsh.Sleep 200
> .SendKeys "foo{tab}bar{tab}" : wsh.Sleep 200
> .SendKeys "c:\windows"
> end with
>
> I still don't like it because of the open loop two second delay
> required (on my machine) between confirming that the search screen was
> open and the time the first keystroke could be sent reliably to it
> (under XP). Without the delay, I kept opening the Internet search
> function, instead.
>
> This is a case where AutoIt (third party control - google search to
> find a free copy) might be almost essential.
>
> Tom Lavedas
> ===========
> http://members.cox.net/tglbatch/wsh/
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
windows explorer has stopped working....window explorer restarting Vista General
Windows Explorer search parameters Vista General
Someone help me fix my Windows Explorer Search Please! Vista file management
Windows Explorer Search Vista General
Maddening Windows Explorer Search Window Opens on Mouse Movement Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46