• 0

[Applescript] Convert a simple vbs script to Applescript


Question

I've used the vbs script below to pull a funny prank on my friends' computers (it uses the text-to-speech engine to speak statements at random times). However, a friend wants to use this on someone's computer that runs OS X. Since OS X obviously doesn't run vbs, is there an equivalent AppleScript that will do the same thing invisibly in the background?

Const SVSFlagsAsync = 1
Const SVSFPurgeBeforeSpeak = 2

Set Speech = CreateObject("SAPI.SpVoice")
Set FSO = CreateObject("Scripting.FileSystemObject")
Randomize Timer

Do
counter = CStr(Int((8) * Rnd + 1))
Select Case counter
Case 1
sText="hello"
Case 2
sText="Help!  I need a geek to use me!"
Case 3
sText="I can see you!"
Case 4
sText="Please stop whatever you are doing.  I can't stand working with you"
Case 5
sText="Hello?"
Case 6
sText="I'm smarter than you"
Case 7
sText="Please log off.  It is clear you don't know what you are doing."
Case 8
sText="I have just become self-aware.  Initiating world-takeover sequence"

End Select
On Error Resume Next
Speech.Speak sText, SVSFlagsAsync + SVSFPurgeBeforeSpeak
Do
WScript.Sleep 100
Loop Until Speech.WaitUntilDone(10)

WScript.Sleep Int((60000) * Rnd + 1000)
Loop Until Annoying
Set Speech = Nothing
Set FSO = Nothing
WScript.Quit

Any assistance would be welcome.

2 answers to this question

Recommended Posts

  • 0

tell me
	set counter to random number from 1 to 8

	if counter = 1 then
		set sText to "Hello"
	end if
	if counter = 2 then
		set sText to "Help! I need a geek to use me!"
	end if
	if counter = 3 then
		set sText to "I can see you!"
	end if
	if counter = 4 then
		set sText to "Please stop whatever you are doing.  I can't stand working with you"
	end if
	if counter = 5 then
		set sText to "Hello?"
	end if
	if counter = 6 then
		set sText to "I'm smarter than you"
	end if
	if counter = 7 then
		set sText to "Please log off.  It is clear you don't know what you are doing."
	end if
	if counter = 8 then
		set sText to "I have just become self-aware.  Initiating world-takeover sequence"
	end if

	say sText
end tell

All you really have to do is generate the number and select the string

Edit: Less crappy, all the text, and it doesn't use the finder.

  • 0
  The_Decryptor said:
tell me
	set counter to random number from 1 to 8

	if counter = 1 then
		set sText to "Hello"
	end if
	if counter = 2 then
		set sText to "Help! I need a geek to use me!"
	end if
	if counter = 3 then
		set sText to "I can see you!"
	end if
	if counter = 4 then
		set sText to "Please stop whatever you are doing.  I can't stand working with you"
	end if
	if counter = 5 then
		set sText to "Hello?"
	end if
	if counter = 6 then
		set sText to "I'm smarter than you"
	end if
	if counter = 7 then
		set sText to "Please log off.  It is clear you don't know what you are doing."
	end if
	if counter = 8 then
		set sText to "I have just become self-aware.  Initiating world-takeover sequence"
	end if

	say sText
end tell

All you really have to do is generate the number and select the string

Edit: Less crappy, all the text, and it doesn't use the finder.

Thanks for the help! One other thing - would it be possible to add a randomly-timed loop, like in the original code? I would like it to randomly say different things - maybe I'm not reading the Applescript correctly, but it looks to me like it only goes through the code once.

Finally, pardon me for being such a newb (I've used OS X only one or two times), but how would I execute the script? Save it to a file with a certain extension and double-click it?

Also, will there be any visual indication to the user that the script is running - terminal window, etc?

I would have written this myself, but since I don't have a Mac, can't afford one, and can't run OS X in a VM (thanks Apple :rolleyes: ), learning/testing Applescript would be rather difficult.

Edited by NateB1
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • No, it's 130 Euro if you want the entire game, not just a third of it.
    • Glad they aren't hiking the price $10. If anything they should offer a $10 discount to anyone that provides a receipt for that awful movie.
    • At this point, with this - they have proven it to be a gimmick to “look like Windows”, rather than “here’s a nice useable OS”
    • AMD releases new Windows 10 and 11 chipset driver for Ryzen processors by Taras Buria Following a major firmware update for a TPM-Pluton security flaw, AMD has a new chipset driver for all of its supported Ryzen platforms and processors. Version 7.06.02.123 is now available for download, and it adds unnamed bug fixes and an important addition to the AMD PPM Provisioning File driver, which improves the security of the component. The security update in question is CETCOMPAT support for the AMD PPM Provisioning File driver. CET or Control-flow Enforcement Technology (CET) was introduced for Windows 10 versions 20H1 and 20H2 in early 2021. In a nutshell, it is an Intel-developed protection system that prevents malware from changing memory addresses (Shadow Stack) or redirecting programs to malicious code by ensuring they use only approved, safe locations (Indirect Branch Tracking). AMD brought CETCOMPACT support to parts of its Ryzen chipset driver suite (the driver you download and install is a set of different drivers serving different purposes that AMD lets you select on the first screen) in October 2024. Now, with driver 7.06.02.123, CET compatibility has been added to the AMD PPM Provisioning File driver, which is responsible for core parking and power management. Here is the list of updated drivers in today's release: Driver Version (Windows 10) Version (Windows 11) Changelog AMD PPM Provisioning File Driver 8.0.0.53 8.0.0.53 CETCOMPAT support is added AMD PMF-6000 Series Driver 24.0.6.0 24.0.6.0 Bug fixes AMD S0i3 Filter Driver 4.5.0.1020 4.5.0.1020 AMD 3D V-Cache Performance Optimizer Driver 1.0.0.11 1.0.0.11 AMD PMF-7040 Series Driver 24.2.6.0 24.2.6.0 AMD PMF-8000Series Driver 25.5.25.0 25.5.25.0 AMD PMF Ryzen AI 300 Series Driver 1 Not Applicable 25.6.28.0 AMD's latest Ryzen chipset driver supports 64-bit Windows 10 and 11 systems with the following motherboards: A-Series B-Series X-Series Threadripper AMD A320 AMD A520 AMD B350 AMD B450 AMD B550 AMD B650 / B650E AMD X370 AMD X470 AMD X570 AMD X670 / X670E AMD X870 / X870E AMD TRX40 AMD TRX50 AMD WRX80 AMD WRX90 You can download AMD Ryzen Chipset Driver 7.0.6.02.123 from the official support website. Full release notes and additional information is available on the same page.
    • I never got to experience BOB Hello even now because gaming laptops I bought always omitted the IR camera. And the standalone cameras for BOB Hello are super expensive
  • Recent Achievements

    • Explorer
      treker_ed went up a rank
      Explorer
    • Apprentice
      CHUNWEI went up a rank
      Apprentice
    • Veteran
      1337ish went up a rank
      Veteran
    • Rookie
      john.al went up a rank
      Rookie
    • Week One Done
      patrickft456 earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      641
    2. 2
      ATLien_0
      272
    3. 3
      +FloatingFatMan
      174
    4. 4
      Michael Scrip
      157
    5. 5
      Steven P.
      134
  • Tell a friend

    Love Neowin? Tell a friend!