Hi Terry,

I mangled things a bit and rearranged other bits ;-)
The example at the end demonstrates the Force command which can take 1 or 2
parameters.

AutoPilot: func [inpu][
    AutoPilot: read/lines to-file inpu
    AutoPilotCode: {Set WshShell = WScript.CreateObject("WScript.Shell")}
    AutoPilotA: {WshShell.AppActivate "###1"^/}
    AutoPilotR: {WshShell.Run "###1"^/}
    AutoPilotS: {WScript.Sleep "###1"^/}
    AutoPilotT: {WshShell.SendKeys "###1"^/}
;please note that some apps have 2 names - one for launch and 1 for
userspace
;Microsoft Word is one such example.  Winword to launch, Microsoft Word for
userspace.
    AutoPilotF: {
if not WshShell.AppActivate("###1") then
    WshShell.Run("###2")
    do while not WshShell.AppActivate("###1")
        WScript.sleep 10
    loop
end if
}
    rj: func [cmd srch dat][AutoPilotCode: join AutoPilotCode replace/all
copy cmd srch dat]
    foreach syl AutoPilot [
        syl: to-block syl
        switch length? syl [
            2 [
                com: to-string first syl
                att: second syl
                if com = "Activate" [rj AutoPilotA "###1" att]
                if com = "Launch" [rj AutoPilotR "###1" att]
                if com = "Wait" [rj AutoPilotS "###1" att]
                if com = "Type" [rj AutoPilotT "###1" att]
                if com = "Force" [replace rj AutoPilotF "###1" att "###2"
att]
            ]
            3 [
                com: to-string first syl
                att: second syl
                att2: third syl
                if com = "Force" [replace rj AutoPilotF "###1" att "###2"
att2]
            ]
        ]
    ]

    write %autopilot.vbs AutoPilotCode
    browse %autopilot.vbs ;call
    wait 3
    delete %autopilot.vbs
]
;----------------------------
;Below is a sample macro that will launch Word (if it exists) type
something, then launch notepad,
;wait 3 seconds, type "Hello World, wait 1 second and type "Again"

write %myMacrofile.txt {Force "Microsoft Word" "Winword"^/Type "This is
microsoft word!"^/Force "Notepad" ^/Type "^n" ^/Wait 3000 ^/Type "Hello
World" ^/Wait 1000 ^/Type " Again."^/}
Autopilot "myMacrofile.txt"

-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to