Example Red Scripts

Script for Red Frogster game
;;;;  Again just for fun. You'll need all the image and sound files in the folder for it to work. 
;;;; 
T
he zip contains everything you need, including a  ready compiled exe.
;;;; Note: This one uses the keyboard. 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Red [needs: 'view author: Alan B. date: 06/06/2018] ;;;; play a sound effect ;;;; playIt: { Set objFileToRead = CreateObject("Scripting.FileSystemObject").OpenTextFile("effect.txt",1) FileText = objFileToRead.ReadAll() objFileToRead.Close Set objFileToRead = Nothing Set Sound = CreateObject("WMPlayer.OCX.7") Sound.URL = FileText Sound.Controls.play do while Sound.currentmedia.duration = 0 wscript.sleep 100 loop wscript.sleep (int(Sound.currentmedia.duration)+1)*1000 } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; load the assets ;;;; f1: load %f1.gif f2: load %f2.gif bush: load %bush.jpg car: load %c.gif car3: Load %c3.gif car4: load %c4.gif car2: load %c2.gif car5: load %c5.gif car6: load %c6.gif car7: load %c7.gif car8: load %c8.gif truck1: load %t1.gif truck2: load %t2.gif bush2: load %bush2.jpg splat2: load %splat2.gif L: 4 S: 0 rb: 0 rat1: 80 rat2: 60 rat3: 50 T: 2000 ;;;; collision detection and score update ;;;; collide: [write %effect.txt "splat2.mp3" write %playeffect.vbs playIt call "start playeffect.vbs"           lv/text: mold L: L - 1 frog/image: splat2 100x100 wait 2 rb: 0           frog/image: f1 30x30 frog/offset/y: 360 T: 2000           if L = 0 [T: 2000 rat1: 20 rat2: 40 rat3: 40 view/flags [ do timedout h1 "Game Over !" return           h4 "Try again ?" return button "Yes" [T: 2000 rb: 0 L: 4 lv/text: "4" unview ]           button "No" [delete %playeffect.vbs delete %effect.txt quit] ] ['modal 'no-border] ] ] ;;;; made it across ;;;; madeit: [ if frog/offset/y < 50 [ if frog/offset/y > 40 [T: 2000 sc/text: mold S: S + 500 T: 2000           view/flags [ do timedout h1 "Made it !" return           h4 "Another go ?" return button "Yes" [T: 2000 rb: 0 frog/offset/y: 360 unview ]           button "No" [delete %playeffect.vbs delete %effect.txt quit] ] ['modal 'no-border] ] ] ] ;;;; Timed out ;;;; timedout: [ if T < 2 [view/no-wait/flags [ h5 "Out of time !" ] ['modal 'no-border ] wait 4 delete %playeffect.vbs delete %effect.txt quit ] ] ;;;; main view ;;;; view/options/flags [ title " Frogster by Alan B. " backdrop black size 600x425                     at 0x0 image bush at 80x0 image bush at 160x0 image bush                     at 240x0 image bush at 320x0 image bush at 400x0 image bush                     at 480x0 image bush at 560x0 image bush                     at 0x350 image bush2 at 80x350 image bush2 at 160x350 image bush2                     at 240x350 image bush2 at 320x350 image bush2 at 400x350 image bush2                     at 480x350 image bush2 at 560x350 image bush2                     at 50x160 box linen 65x8 at 200x160 box linen 70x8                     at 350x160 box linen 70x8 at 500x160 box linen 65x8                     at 50x260 box linen 70x8 at 200x260 box linen 70x8                     at 350x260 box linen 70x8 at 500x260 box linen 65x8
at 5x5 h5 font-color red "Lives:" 45x25 at 50x5 lv: h5 font-color red "04" 25x25 ;;;; <-- lives at 120x5 h5 font-color red "Score:" 50x25 at 170x5 sc: h5 font-color red "0" 40x25 ;;;; <-- score at 240x5
h5 font-color red "Time:" 50x25 at 285x5 tt: h5 font-color red "1000" 40x25 ;;;; <-- time
;;;;; row one ;;;;     at 0x100 car: image car rate rat1 on-time [ tt/text: mold T: T - 1 do timedout car/offset/x: car/offset/x + 2 if car/offset/x = 600 [car/offset/x: -60] if overlap? frog car [do collide ] ] 60x30     at 150x100 van: image car3 rate rat1 on-time [van/offset/x: van/offset/x + 2 if van/offset/x = 600 [van/offset/x: -60] if overlap? frog van [do collide] ] 60x30     at 300x100 truck: image car7 rate rat1 on-time [truck/offset/x: truck/offset/x + 2 if truck/offset/x = 600 [truck/offset/x: -60] if overlap? frog truck [do collide] ] 80x30     at 450x100 bike: image car5 rate rat1 on-time [bike/offset/x: bike/offset/x + 2 if bike/offset/x = 600 [bike/offset/x: -60] if overlap? frog bike [do collide] ] 40x30     at 560x100 van6: image car7 rate rat1 on-time [van6/offset/x: van6/offset/x + 2 if van6/offset/x = 600 [van6/offset/x: -60] if overlap? frog van6 [do collide] ] 40x30     ;;;; row two ;;;;     at 0x200 car2: image car2 rate rat2 on-time [car2/offset/x: car2/offset/x - 2 if car2/offset/x = -50 [car2/offset/x: 600]if overlap? frog car2 [do collide] ] 60x30     at 150x200 van2: image car4 rate rat2 on-time [van2/offset/x: van2/offset/x - 2 if van2/offset/x = -50 [van2/offset/x: 600] if overlap? frog van2 [do collide] ] 60x30     at 300x200 truck2: image car6 rate rat2 on-time [truck2/offset/x: truck2/offset/x - 2 if truck2/offset/x = -50 [truck2/offset/x: 600]if overlap? frog truck2 [do collide] ] 80x30     at 450x200 bike2: image car8 rate rat2 on-time [bike2/offset/x: bike2/offset/x - 2 if bike2/offset/x = -50 [bike2/offset/x: 600] if overlap? frog bike2 [do collide] ] 40x30     at 560x200 bike3: image car4 rate rat2 on-time [bike3/offset/x: bike3/offset/x - 2 if bike3/offset/x = -50 [bike3/offset/x: 600] if overlap? frog bike3 [do collide] ] 40x30     ;;;;; row three ;;;;     at 0x300 truk: image truck1 rate rat3 on-time [truk/offset/x: truk/offset/x + 2 if truk/offset/x = 600 [truk/offset/x: -60] if overlap? frog truk [do collide] ] 80x30     at 150x300 van3: image car3 rate rat3 on-time [van3/offset/x: van3/offset/x + 2 if van3/offset/x = 600 [van3/offset/x: -60]if overlap? frog van3 [do collide] ] 60x30     at 300x300 car4: image car5 rate rat3 on-time [car4/offset/x: car4/offset/x + 2 if car4/offset/x = 600 [car4/offset/x: -60]if overlap? frog car4 [do collide] ] 60x30     at 450x300 van4: image car3 rate rat3 on-time [van4/offset/x: van4/offset/x + 2 if van4/offset/x = 600 [van4/offset/x: -60] if overlap? frog van4 [do collide] ] 60x30     at 560x300 van5: image car7 rate rat3 on-time [van5/offset/x: van5/offset/x + 2 if van5/offset/x = 600 [van5/offset/x: -60] if overlap? frog van5 [do collide] ] 40x30     at 300x360 frog: image f1 30x30 ;;;; the frog ] [     actors: context [ on-close: func [ face event][delete %playeffect.vbs delete %effect.txt ]         on-key: func [face event][             switch event/key [                 up [ if rb = 0 [write %effect.txt "hop3.mp3" write %playeffect.vbs playIt call "start playeffect.vbs" rb: 1]                     frog/offset/y: frog/offset/y - 5 either frog/image = f1 [frog/image: f2] [frog/image: f1 ] do madeit]                 down [if frog/offset/y < 370 [frog/offset/y: frog/offset/y + 5] ]                 left [frog/offset/x: frog/offset/x - 5]                 right [frog/offset/x: frog/offset/x + 5]             ]         ]     ] ]['modal 'no-min]




Gui Drag-N-Drop Layout
;;;; 
It allows you to drag and drop widgets to a layout grid, Then the 'Save it' button will save the
;;;; generated script,  the 'Try it' button will allow you to run the script, and the 'Clear it' button will 
;;;; clear the layout page.  There's a lot more that could be added to this one, A compiled exe is on
;;;; my 'Red Apps' page.

Red [needs: 'view author: Alan Brack date: 12/03/2018 ]
spec: copy [] btn-pos: 500x20 rad-pos: 500x50 chk-pos: 500x80 fld-pos: 500x110 ars-pos: 500x140 sdr-pos: 500x170 pgs-pos: 500x200 pnl-pos: 500x230 ddn-pos: 500x260 txt-pos: 500x290 n: 0 n1: 0 n2: 0 n3: 0 n4: 0 n5: 0 n6: 0 n7: 0 n8: 0 n9: 0 view/options/flags [title "GUI Drag-n-Drop Layout(ver. 1) by Alan B." size 600x500
;;;;;;;;;;;;;;; a bit of a grid thing ;;;;;;;;;;;;;;;; base transparent 480x480 draw [pen brown text 2x15 ". . . . . . . ." text 2x75 ". . . . . . . ." text 2x135 ". . . . . . . ." text 2x195 ". . . . . . . ." text 2x255 ". . . . . . . ." text 2x315 ". . . . . . . ." text 2x375 ". . . . . . . ." text 2x435 ". . . . . . . ."
                                ] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
at 490x10 box gray 100x480 ;;;;;;;;;;;;;;;;;;;;;Buttons;;;;;;;;;;;;;;;;;;;;; at btn-pos btn: button "Button" loose on-drop [ if btn/offset/x < 410 [ if btn/offset/x > 5 [ if btn/offset/y > 5 [ n: n + 1 name: append copy "Button " n p: face/offset repend spec ['at p 'button name []] repend face/parent/draw ['box p p + face/size 'text p + 4x5 name ] new-line find/last spec 'at on ;;;; print mold spec ] ] ] btn/offset: btn-pos ] 80 ;;;;;;;;;;;;;;;;;;;;;;;;Radios;;;;;;;;;;;;;;;;; at rad-pos rad: button "Radio" loose on-drop [ if rad/offset/x < 410 [ if rad/offset/x > 5 [ if rad/offset/y > 5 [ n1: n1 + 1 name: append copy "Radio" n1 p1: face/offset repend spec ['at p1 'radio name []] repend face/parent/draw ['box p1 p1 + face/size 'text p1 + 4x5 name] new-line find/last spec 'at on ;;;; print mold spec ] ] ] rad/offset: rad-pos ] 80 ;;;;;;;;;;;;;;;;;;;;;Check Boxes;;;;;;;;;;;;;;; at chk-pos chk: button "Check" loose on-drop [ if chk/offset/x < 410 [ if chk/offset/x > 5 [ if chk/offset/y > 5 [ n2: n2 + 1 name: append copy "Check " n2 p1: face/offset repend spec ['at p1 'check name []] repend face/parent/draw ['box p1 p1 + face/size 'text p1 + 4x5 name] new-line find/last spec 'at on ;;;; print mold spec ] ] ] chk/offset: chk-pos ] 80 ;;;;;;;;;;;;;;;;;;;;;;;Fields;;;;;;;;;;;;;;;;;; at fld-pos fld: button "Field" loose on-drop [ if fld/offset/x < 410 [ if fld/offset/x > 5 [ if fld/offset/y > 5 [ n3: n3 + 1 name: append copy "Field " n3 p1: face/offset repend spec ['at p1 'field name []] repend face/parent/draw ['box p1 p1 + face/size 'text p1 + 4x5 name] new-line find/last spec 'at on ;;;; print mold spec ] ] ] fld/offset: fld-pos ] 80 ;;;;;;;;;;;;;;;;;;;;;;;Areas;;;;;;;;;;;;;;;;;; at ars-pos ars: button "Area" loose on-drop [ if ars/offset/x < 410 [ if ars/offset/x > 5 [ if ars/offset/y > 5 [ n4: n4 + 1 name: append copy "Area " n4 p1: face/offset repend spec ['at p1 'area name []] repend face/parent/draw ['box p1 p1 + face/size 'text p1 + 4x5 name] new-line find/last spec 'at on ;;;; print mold spec ] ] ] ars/offset: ars-pos ] 80 ;;;;;;;;;;;;;;Slider;;;;;;;;;;;;;;;;;; at sdr-pos sdr: button "Slider" loose on-drop [ if sdr/offset/x < 410 [ if sdr/offset/x > 5 [ if sdr/offset/y > 5 [ n5: n5 + 1 name: append copy "Slider " n5 p1: face/offset repend spec ['at p1 'slider 10% []] repend face/parent/draw ['box p1 p1 + face/size 'text p1 + 4x5 name] new-line find/last spec 'at on ;;;; print mold spec ] ] ] sdr/offset: sdr-pos ] 80 ;;;;;;;;;;;;;;;Progress;;;;;;;;;;;;;; at pgs-pos pgs: button "Progress" loose on-drop [ if pgs/offset/x < 410 [ if pgs/offset/x > 5 [ if pgs/offset/y > 5 [ n6: n6 + 1 name: append copy "Progress " n6 p1: face/offset repend spec ['at p1 'progress 10% []] repend face/parent/draw ['box p1 p1 + face/size 'text p1 + 4x5 name] new-line find/last spec 'at on ;;;; print mold spec ] ] ] pgs/offset: pgs-pos ] 80 ;;;;;;;;;;;;;;;Panel;;;;;;;;;;;;;;;;;;;;;;;; at pnl-pos pnl: button "Panel" loose on-drop [ if pnl/offset/x < 410 [ if pnl/offset/x > 5 [ if pnl/offset/y > 5 [ n7: n7 + 1 name: append copy "Panel " n7 p1: face/offset repend spec ['at p1 'panel name yellow[ size 50x100 ]] repend face/parent/draw ['box p1 p1 + face/size 'text p1 + 4x5 name ] new-line find/last spec 'at on ;;;; print mold spec ] ] ] pnl/offset: pnl-pos ] 80 ;;;;;;;;;;;;;;;;Drop-Down;;;;;;;;;;;;;;;;;;;; at ddn-pos ddn: button "Drop-down" loose on-drop [ if ddn/offset/x < 410 [ if ddn/offset/x > 5 [ if ddn/offset/y > 5 [ n8: n8 + 1 name: append copy "Drop-down " n8 p1: face/offset repend spec ['at p1 'drop-down name []] repend face/parent/draw ['box p1 p1 + face/size 'text p1 + 4x5 name ] new-line find/last spec 'at on ;;;; print mold spec ] ] ] ddn/offset: ddn-pos ] 80 ;;;;;;;;;;;;;;;;;Text;;;;;;;;;;;;;;;;;;;; at txt-pos txt: button "Text" loose on-drop [ if txt/offset/x < 410 [ if txt/offset/x > 5 [ if txt/offset/y > 5 [ n9: n9 + 1 name: append copy "Some text " n9 p1: face/offset repend spec ['at p1 'text name []] repend face/parent/draw ['box p1 p1 + face/size 'text p1 + 4x5 name ] new-line find/last spec 'at on ;;;; print mold spec ] ] ] txt/offset: txt-pos ] 80 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; at 500x410 box khaki 80x75 at 510x420 button font-color red "'Try It'" [view/flags spec ['modal 'no-min] ] 60x15 at 510x440 button font-color red "'Clear It'" [ clear face/parent/draw clear spec n: 0 n1: 0 n2: 0 n3: 0 n4: 0 n5: 0 n6: 0 n7: 0 n8: 0
n9: 0 n10: 0] 60x15
at 510x460 button font-color red "'Save It'" [ if sf: request-file/save [unless suffix? sf [append sf %.red ] write sf rejoin [{Red [needs: 'view] view }] write/append sf spec ] ] 60x15 ][draw: []] ['modal 'no-min]





Sound Player Script
;;;; 
This one plays mp3 and wav files.
;;;; It just needs the player and some sound files.
;;;; Make sure you have some mp3  and/or  wav files in the folder.
;;;;  A compiled version is on my Apps page.
;;;;  Tested on Win 10.

Red [needs: 'view author: Alan Brack date: 03/10/2017] folder: read %. count: 0
;;;;;;;; a vbs script to handle mp3 and wav play ;;;;;;;;;;; playIt: { Set objFileToRead = CreateObject("Scripting.FileSystemObject").OpenTextFile("mysong.txt",1) FileText = objFileToRead.ReadAll() objFileToRead.Close Set objFileToRead = Nothing Set Sound = CreateObject("WMPlayer.OCX.7") Sound.URL = FileText Sound.Controls.play do while Sound.currentmedia.duration = 0 wscript.sleep 100 loop wscript.sleep (int(Sound.currentmedia.duration)+1)*1000 } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;; a vbs script to stop mp3 and wav play ;;;;;;;;;;;;;;;;;;; stopIt: { Option Explicit Dim WshShell Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.Run "taskkill /f /im Cscript.exe", 0 , True WshShell.Run "taskkill /f /im wscript.exe", 0 , True } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;; get the wav and mp3 files from folder ;;;;;;;;;;;;;; play: "" foreach file folder [ foreach ext [".mp3" ".wav"] [ if find file ext [i: copy form file count: count + 1 ;;;;probe i insert tail play i ] play: to-block play ] ] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; make it text-list friendly ;;;; attempt [form-all: func [blok][forall blok [blok/1: form blok/1] blok] form-all play list-chosen-text: func [ face "xxxx"] [t/text: pick face/data face/selected ] list-chosen-word: func [face "xxxx"] [to word! list-chosen-text face] ] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;; main view with buttons and text-list ;;;;;;;;;;; view/flags/options [backdrop khaki title "Red music player (ver. 2)" t: text italic "Choose from the list ->" 150x30 text-list gold data play [list-chosen-word face ] below ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; play mp3 or wav ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; at 10x50 button "Start track" 100x30 [if t/text <> "Choose from the list ->" [write %killplayer.vbs stopIt wait .5 call "start killplayer.vbs" wait .5 ;;delete %killplayer.vbs write %mysong.txt t/text wait .5 write %myplayer.vbs playIt wait .5 call "start myplayer.vbs" wait .5 delete %myplayer.vbs wait .5 delete %mysong.txt ] ] ;; <-- end if block and end button block ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;; stop mp3 or wav ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; at 10x100 button font-color red "Stop track" 100x30 [write %killplayer.vbs stopIt call "start killplayer.vbs" wait 1 delete %killplayer.vbs] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ]['modal 'no-min][actors: object [on-close: func [face event] [write %killplayer.vbs stopIt call "start killplayer.vbs" wait .5 delete %killplayer.vbs]]] ;;;;<- kill sound if a title bar quit is executed ;;;;;;;;;;;;;;
end of main view - flags and opts ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;





My Red Script Runner
;;;; This will list all the Red scripts in the folder and allow you to choose and run them.
;;;;  A compiled version is on my Apps page.
;;;;  Tested on Win 10.

Red [needs: 'view author: Alan Brack date: 08/11/2017] folder: read %. count: 0 ;;;;;;;;;;;; create a script list in folder ;;;;;;;;;;;;;;;;;;;;; write %sList.dat "" foreach file folder [ if find file ".red" [ i: copy form file count: count + 1 ;;;;probe i write/append/lines %sList.dat i ] ] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;; load script list into text-list ;;;;;;;;;;;; sData: load %sList.dat ;;;; make it text-list friendly ;;;; form-all: func [blok][forall blok [blok/1: form blok/1] blok] form-all sData list-chosen-text: func [ face "xxxx"] [t/text: pick face/data face/selected ] list-chosen-word: func [face "xxxx"] [to word! list-chosen-text face] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;; start main view with buttons and text-list ;;;;;;;;;;; view/flags [backdrop mint title "Red script runner (ver. 1)"
             t: text italic "Choose from the list ->" 150x30 text-list linen data sData [attempt [list-chosen-word face ] ] below ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Run Red script ;;;;;;;;;;;;;;;;; at 10x50 button "Run Script" 100x30 [if t/text <> "Choose from the list ->" [ runner: to-file t/text do runner ] ] ;; <-- end button block and end if block ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ]['modal 'no-min] ;; <-- end of main view and flags





My File and Folder Hider
;;;; This will hide the folder called 'FolderVault'
;;;; Even if you set Windows to show hidden files. It will stay hidden.
;;;; Simply copy any files and folders you want hidden into 'FolderVault'

;;;; Once you've created a folder called 'FolderVault' your all set.
;;;; Compile the script, then you can hide 'FolderVault' and move your 
;;;; compiled  exe to somewhere else.
;;;; Or check out my Apps page for a password protected version.
;;;; Tested on Win 10.

Red [needs: 'view  author: Alan Brack   date:  16/10/2017 ]

view/flags [ title "File/Folder Vault" 
t: h5 italic font-color purple "Hide 'FolderVault' and its contents ...." 300x30 return
               
button "Hide Folder"  [either exists?  %FolderVault [
     call "start/min  attrib FolderVault +s +h"  t/text: "'FolderVault' Hidden"
     write %rfresh.txt "cause folder to refresh"  wait .5   delete %rfresh.txt   ] [
      view/flags [ title "Warning !" h5 "A folder called 'FolderVault' MUST exist !"]['modal 'no-min ] ] ]

button "Un-Hide Folder"  [either exists?  %FolderVault [  
     call "start/min attrib  FolderVault -s -h"  t/text: "'FolderVault' Un-Hidden"] [
     view/flags [ title "Warning !" h5 "A folder called 'FolderVault' MUST exist !"]['modal 'no-min ] ] ]
     ] ['modal 'no-min]





My SendKeys App
;;;; Send one or more keystrokes to the active window as if they were typed at the keyboard.
;;;; This one's a bit controversial - SendKeys is supposed to be unreliable,That is Not So ,  it's all about ;;;; timing (i.e. WScript.Sleep 1000) get the wait times right for your device and there's no problem. 
;;;; This script writes a vbs file to your folder, executes it, and then deletes it. Clean and efficient.
;;;  I know it works on Win 8, Win 8.1 and Win 10.   Possible Win 7 ? 

Red [needs: 'view  Author: Alan B]
vbsScript: {                                               
         set WshShell = WScript.CreateObject("WScript.Shell")
         WshShell.Run "C:\Windows\system32\calc.exe"
         WScript.Sleep 500
         WshShell.AppActivate "Calculator"
         WScript.Sleep 2000
         WshShell.SendKeys "4{+}3"
         WScript.Sleep 500
         WshShell.SendKeys "="
         WScript.Sleep 1000
         WshShell.SendKeys "2*3"
         WScript.Sleep 500
         WshShell.SendKeys "="
         WScript.Sleep 1000
}   
   
view/flags  [title "Alans SendKeys ...." size 150x60 backdrop cyan
button "Send Keystrokes"  [write %sendKeys01.vbs vbsScript  wait 1
            call "start sendKeys01.vbs"  wait 1  
            delete  %sendKeys01.vbs] 
]['modal 'popup]





My livecode extention
;;;; An experiment based on Nenads Livecode script,  I did this just for fun.  
;;;; Was just messing about with it ....
;;;; It allows you to Save and Load the Livecode code (data). 
;;;; You can run the Livecode from within the editor as a full Gui script. Use the 'GoRed' button.
;;;; It can also save the Livecode with the Red header and View block added  ...........  
;;;; so it is ready for compilation in the traditional Red way. Use the 'RedSave' button. 
;;;; The main thing is to know what you're saving your work as,  a 'livecode' script or a full 'Red script'.
;;;; Anyway, just try it, as I said, just a bit of fun .....

;;;; An experiment based on Nenads Livecoding script ;;;;
Red [needs: 'view ]        ;; <-- Begin main view window ;;
view/flags [ title "Red Livecoding - Extended"   

    ;;;; Start the output panel ;;;;
    output: panel 400x500  
    below 
    h5 bold italic font-color red "Red [needs: 'view ]" h5 bold italic font-color red "View [" 

    across
    ;;;; start the area ;;;;
    source: area black font-color white 500x500  focus wrap font-name "Fixedsys" 
;;;; Put some livecode in area ;;;;
{                                               
below  
h2 font-color blue "Hello"  
field  
area  
radio

h5 "**** Tap spacebar to get started !! ****"

}          ;;;;<--  stop putting livecode in area ;;;;

          ;;;; alter on-key-up to on-change  to handle pasting script
          on-change [attempt [output/pane: layout/only load source/text] ]  
          below
          ;;;; Buttons ;;;;
          button font-color brown "Save" [if sf: request-file/save  [unless suffix? sf [append sf %.liv]  write sf source/text  tx/text: "Saved." ] ]
          button font-color brown "Load" [if Lf: request-file [source/text: read Lf  tx/text: "Loaded." ] attempt [output/pane: layout/only load source/text ] ]
          button font-color red "RedSave" [if sf: request-file/save  [unless suffix? sf [append sf %.red]  write sf 
          rejoin [{Red [ ] 
View [ } source/text {]}  ] source/text  tx/text: "Saved." ] ]
          button font-color red "GoRed" [go: rejoin [{Red [ ]  View/flags [ } source/text {] 'modal [actors: object [on-close: func [face event][unview]]]}  ]  
                   tx/text: ""  do go attempt [output/pane: layout/only load source/text] ] 
          button font-color brown "Clear" [source/text: clear  output/pane: clear  tx/text: ""] 

          ;;;; Help section ;;;;
          button font-color brown "Help" [tx/text: "" view/flags [title "Help window" below
text "Remember, this is 'livecode' so if you use 'save and load' be sure to only load 'Livecode' scripts - Not scripts saved using 'RedSave'."
h5 font-color brown "'Save'  .... Saves your code (adds a .liv suffix if none is used)"
h5 font-color brown "'RedSave' .... Saves code with Red header and View block (adds a .red suffix if none is used)"
h5 font-color brown"'GoRed'  .... Runs code with Red header and View block - Interprets as a Red script  "
h5 font-color brown "'Load' .... Loads your code - (Be sure to only load Livecode code - with .liv suffix)"
h5 font-color brown "'Clear' .... Clears the editor and output panel"
h5 font-color brown "'Help' .... This help window"
] 'modal       ;; <-- ;;;; End of Help section ;;

]                     ;; <-- ;;;; End of the area  ;;
                  tx: text ""
at 470x580 h5 bold italic font-color  red " ]"

                   ] 'no-min         ;; <--  ;;;; End of main view ;;





My Quiz App
;;;; This is a much simplified example of my Quiz App ....
;;;; Please make sure the 'questions.dat' is in the program folder .....

Red [title: "Quiz" 
        Author:  "Alan Brack"  
        needs: 'view] 

myScore: 0 count: 0 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;routine to seed the random generator;;;;;;;
sd: routine [ return: [integer!] /local address [pointer! [byte!]]][ address: allocate 4 free address
    return as integer! address]random/seed sd
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;no title bars and stay on top ;;;;;;;;;;;
flags: clear []
append flags 'modal
append flags 'no-title
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;; correct and incorrect views ;;;;;;;;;;
dd: layout [ size 300x300 below text "Correct Answer !!!!" bold button "Correct" [unview]]
ee: layout [ size 300x300 below text "Wrong Answer !!!!" bold button "Wrong" [unview]]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
questions: load/all %questions.dat   ;; load the questions.dat

;;;;;;; start first foreach loop ;;;;;;
foreach [quest] random questions [
qq: copy quest
;;;;;;; start foreach loop to read data block  ;;;;;
foreach [qst ans ans2 ans3 ans4 oks] qq [ count: count + 1  

;;;;;;;; open main view ;;;;;;;;
   view/flags [ size 800x600 title "My Quiz"
    below
    text " " 
    text font-size 16 qst     ;;;; display the question
  text " "
;; display the answer buttons and keep track of score ;;
button 600x80 ans [either oks = "a" [view/flags dd flags] [view/flags ee flags] unview]
button 600x80 ans2 [either oks = "b" [view/flags dd flags][view/flags ee flags]  unview]
button 600x80 ans3 [either oks = "c" [view/flags dd flags][view/flags ee flags]  unview]
button 600x80 ans4 [either oks = "d" [view/flags dd flags] [view/flags ee flags]  unview]
button 600x80 font-color red "Quit the quiz ?" [quit]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
] flags  ;;;;;; end of the main view ;;;;;;  
]   ;;;; end of the foreach loop  ;;;;;
]  ;;;; end of first foreach loop ;;;;

;; NOTE: 
;; I have used a routine to seed the random generator, so script will need to be compiled.
;; You could comment out the 'sd' routine, then the script will interpret.
;; Ensure this 'questions.dat' is in your working folder.






My Watch App
;;;;   This is the full script for my  Watch App ....
;;;;  The only difference here is the need to load the 'r6.png' image from your folder ....
;;;;   Ensure the image is in your Red script folder .... get it and this script here: watchScript
;;;;   you need to use the 'last automated build' for this one ....

Red [title: "The Watch" 
        Author:  "Alan B"  
        needs: 'view] 

h: 30    ;;<-- variable used to help control the hour hand

;;;;; stay on top with no maximise and no minimise ;;;;
 flags: clear []
 append flags 'modal
 append flags 'no-max
 append flags 'no-min 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;; open main view ;;;;;;;;
    view/flags [title "The Red 'SeaMariner'"
    backdrop grey
    image %r6.png        ;;;; ensure the graphic is in your script folder ....

  ;;;; draw hour, minute and second hands ;;;;
       at 30x80 base 200x200 rate 1 now transparent draw [
        scale 2 2
        line-cap round     ;;;; make the watch hands round at the ends
        hour: rotate 0 50x50 [line-width 5 pen #FFFFFF line 50x50 50x30 line-width 1 pen #202020 line 50x50 50x30]
        min:  rotate 0 50x50 [line-width 5 pen #FFFFFF line 50x50 50x20 circle 50x50 1 line-width 1 pen #202020 line 50x50 50x20]
        sec:  rotate 0 50x50 [line-width 1 pen #FF0000 line 50x50 50x18 circle 50x25 3]
    ] on-time [
        time: now/time
        either time/minute > 30 [h: 31][h: 30]      ;;<-- control the hour hand 
        hour/2: h * time/hour                                  
        min/2:  6  * time/minute      
        sec/2:  6  * time/second
    ]    
    ]flags      ;;;;;; end of the main view ;;;;;;  

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Note ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;  Here's a way to make the hour and minute hands move perfectly smoothly ;;;;
;;;;  just use these four lines in place of the equivalent five in my above example ;;;;
;;;; Many thanks to:  Rudolf Meijer   for sending me this excellent improvement ;;;;
time: now/time
hour/2: (30.0 * modulo time/hour 12) + (time/minute * 0.5)
min/2:  (6.0  * time/minute) + (time/second * 0.1)    
sec/2:  6.0  * time/second
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;