Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

dtfgator

macrumors newbie
Original poster
Oct 28, 2009
6
0
Hi!

I am trying to replicate the MIT MS-Dos "Cookie" virus. It displays text "I want cookies. give me cookies" and if the user types cookies, it disappears.

I dont have much yet. I need the applscpt to distinguish the entered text (cookie or else).

I am a script noobie so if anyone could add on to this it would be great.

Code:
display dialog "I want cookies.  Give me cookies." default answer "" buttons {"OK"} default button 1
if answer = "cookies" then beep 10

I need a way to define "answer" as the user response. Once I get this I can complete it.

Thanks!
 

chown33

Moderator
Staff member
Aug 9, 2009
10,706
8,346
A sea of green
Code:
set answer to text returned of (display dialog "I want cookies.  Give me cookies." default answer "" buttons {"OK"} default button 1)
if answer = "cookies" then beep 10
The text returned is one of the items in the dialog reply record that display dialog returns.

In Script Editor.app, choose Open Dictionary. Scroll down to Standard Additions and choose it. Under User Interaction is the display dialog command; click it. Notice what it returns: dialog reply; click its link.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.