Press F3 after 15 minutes VB script

I'm in need of a code which will do exactly the following:

If the file in the following location (c:\playlist.txt) has NOT been modified within the last 15 minutes, then press the F3 key , then 10 seconds later the F3 key is pressed a second time.

I need the code to then wait 1 minutes before looping.

I need it to be able to be written into a ".vbs" file which is double clicked to open.

Any help would be greatly appreciated.
kakashisharingunAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Daz_1234Commented:
Hi,

The script below does exactly what you asked.

Comment out the popups on lines 19 and 24 they are there for testing.

Regards,
Darren.


Option Explicit

Dim fso, wshShell, strFile, dtmLastModified

Set fso = CreateObject("Scripting.FileSystemObject")
Set wshShell = CreateObject("WScript.Shell")

strFile = "c:\playlist.txt"

If Not fso.FileExists(strFile) Then
    MsgBox "Error: File '" & strFile & "' cannot be found.", vbCritical + vbSystemModal, "File Not Found"
    WScript.Quit 1
End If

Do
    dtmLastModified = fso.GetFile(strFile).DateLastModified
    '# Check if file was modified in the last 15 minutes ...
    If DateDiff("n", dtmLastModified, Now()) > 15 Then
        wshShell.Popup "Sending first F3", 2
        '# Now send F3 ...
        wshShell.SendKeys "{F3}"
        '# Now wait 10 seconds ...
        WScript.Sleep 10000  '# 10 seconds
        wshShell.Popup "Sending second F3", 2
        '# Now send another F3 ...
        wshShell.SendKeys "{F3}"
    End If
    '# Wait 60 seconds before checking again ...
    WScript.Sleep 60000  '# 60 seconds
Loop Until fso.FileExists("c:\stop.txt") '# Will loop forever unless a c:\stop.txt exists or kill WScript.exe task to end

MsgBox "Found c:\stop.txt ... Exiting."

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kakashisharingunAuthor Commented:
absolutely perfect - thank you
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.