PDA

View Full Version : Applescript Dialog Box




dtfgator
Oct 31, 2009, 08:03 AM
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.

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
Oct 31, 2009, 02:08 PM
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.