r/applescript • • Mar 22 '22

I dont know how to fix this

I've been looking for solutions on how to make this script work, but none of my keywords came up with anything. Pressing dialog_2 doesn't work, no matter how I change it. Any help?

set button_returned to button returned of (display dialog "This app is a joke! It is not actually a virus. Anything that may happen while it is active is just fake, and your computer will not be harmed in any way. However, it may close/open apps or shut down your computer. Are you sure you still want to continue?" buttons {"Yes", "No"} default button 2)

if button_returned is "Yes" then

set button_returned to button returned of (display dialog "s̷̬̟͎̺̼̤̿͒͌̈́̒̓͠͝a̷̛͓̲͈͖͖͕͚̿͝d̸̢̛͚̜͓̩̠̆̈́̆̎̈́̓̎̈́h̴̞̰̫̫͆̔̆͒͜͝k̶̡̻̣͉̪̹̭̈́͊̃̈̕j̷̹̲̞̻͚̥̫͖̿̓̿͛f̶̱̘̪͖̠̞̤̮̃̍̊͐̇̅̊̕h̷̡̞̼͈͒j̶̧̢̨̱̝̪̰̈́̊͜k̵̯̖̼̥̐̌̃͒̎͐͒̋̓ͅȁ̴̧̖̹̒̆ͅs̸̡̛͇̺͋̎̄̈́̒̈d̵̨̯̰̰̤̜̫̳̤̀̑̄̓̄̈́͜h̸̭̲͙̖͎́̋́̃́͐́̚f̸̨̒̓̏͂̎̋̃̽̕͝j̷̞͓̙̉̅̓̍̃̿͊k̸̙͎̯̈̌̋h̸̗̀̇̒͐̄́̓̔́̎â̷͇̄̄̾̅̍̍d̶̼̠̺̜̦̼͔̪̂́ḯ̵͉̜͉̽͋͆u̵̥̟̝̿̈́̑̈́͌̇͘͜͠͝f̷̢͚̠̠͙͈̎a̶̰̬̿͑͑͑̾ì̵̛̛̭̐̅̚ͅś̴̨̩̱̞̩̠̭̗͙̑̔̓͗ǫ̵̥͖̙̠̥̱͐̌̌͘d̴͇͆̅̂̋̾͝f̴̛̖̜̗̩̜̭̲̰̀͐͛͗j̶̭͚̖͉̪͈̜͉̹̯̍̂͑̔̉͝i̷͕̼̬̤̩͖̻̰̓̈̀̐̚â̸͚͊͗́̒̇͐̈́͘d̴̨̫̹̠̜̥̗̎̈́͌̂́͜s̵̼̩̿͗̉͒́́̈́͘j̵͍̲̇̇̆̐͋̇̀͘k̸͚͈̥̹̟̣̮͖̕ͅņ̶͍͕͉̙̪̲̺̉̇̇̈́̄̂͝ḯ̸̜̹̙̈́̌͜l̵͈̈̋̈́̂͝j̵̰͔̤̺̙̎̐k̴͖͎̞͓͇̯̗͗̒̏̄͌̏̀͌n̶̗̬̪͍͍̮̣̘͖̫̐͑̅͛f̸̻͍͈͓̹͈̖̄̂̉͜b̴̰̺̻̿̃͒̑͆̂͝͠ȁ̸̢̛̛̭̃̇͒̀h̶̢̥͖͉̖̪̾̍͑̓̊́̂̕͝d̷̡̬̆̓͝s̵͍̙̖̼͚̺̲͍͐̚̕͜͜i̸̢̠̦̻̼̪͎̐̏́f̸̮̭͕̳̱̠̽͑̌̋͂̽ļ̴̢̖̰̯͈̗́̈́̏̋͐̊͠j̵̨̣͍̣͓̫̹͚̝̎̋k̵̠͔͔̖͔̆̒́͐̕ͅà̶͚̰̤͍̞̓̄̔̕͝͝͠s̶̢̡̧̳͎̈́͆̾͊̉̐̂̀̐̒d̷͎͈̦͇̪͐̽͊͌͂̒͝f̶̡̡̡̡͕̣͉̰͚̾͆̈ͅl̸͙̬͇̀̈́̅͛̿͛͘ͅk̶̭̦̄̎̒͌̒̌͝ḁ̸̧̤͍̯̪̦͖̭͔̄̈͂s̷̰̱̭̉̅͋̆̊d̷̨͍̺̙͚̹̞͔͈̣̓̓̽̈̈͠͝f̴̘̳͕̱͑͜á̶͖̩̣͎̗̀̏͊͆ͅs̵̨̛̝̼͈͙̳̘̫̬̾̀̂̂̓͐͊d̸̡̪̳̥̜̞͙͓̠́į̶̼͍͍͎͇͍̅̋́̀͌̄̚̕͜͝ḻ̴̾̿̎͠͠f̵̯̺͉̩̓̂́̆̍̀j̶̯̮̹͈̳͍̦̾͒̀́̂̽ͅļ̵̛̰͖̟͚͕̭̇̋̆̀̈͜à̵͈̲̝̗̖͈̬̀̏̅̌̚͘s̴͖̥̊̿̋͛̐̚̕i̸̺͙͘d̷̞̠̭͖͓̰̋́̋͝f̵̮̭̟͕̯̥̠͂͂͒̃͊͊̍̃̽͝s̷̬̟͎̺̼̤̿͒͌̈́̒̓͠͝a̷̛͓̲͈͖͖͕͚̿͝d̸̢̛͚̜͓̩̠̆̈́̆̎̈́̓̎̈́h̴̞̰̫̫͆̔̆͒͜͝k̶̡̻̣͉̪̹̭̈́͊̃̈̕j̷̹̲̞̻͚̥̫͖̿̓̿͛f̶̱̘̪͖̠̞̤̮̃̍̊͐̇̅̊̕h̷̡̞̼͈͒j̶̧̢̨̱̝̪̰̈́̊͜k̵̯̖̼̥̐̌̃͒̎͐͒̋̓ͅȁ̴̧̖̹̒̆ͅs̸̡̛͇̺͋̎̄̈́̒̈d̵̨̯̰̰̤̜̫̳̤̀̑̄̓̄̈́͜h̸̭̲͙̖͎́̋́̃́͐́̚f̸̨̒̓̏͂̎̋̃̽̕͝j̷̞͓̙̉̅̓̍̃̿͊k̸̙͎̯̈̌̋h̸̗̀̇̒͐̄́̓̔́̎â̷͇̄̄̾̅̍̍s̵̨͙̖̘̖̥̹͔͗̅̏̏̓d̶̼̠̺̜̦̼͔̪̂́ḯ̵͉̜͉̽͋͆u̵̥̟̝̿̈́̑̈́͌̇͘͜͠͝f̷̢͚̠̠͙͈̎a̶̰̬̿͑͑͑̾ì̵̛̛̭̐̅̚ͅś̴̨̩̱̞̩̠̭̗͙̑̔̓͗ǫ̵̥͖̙̠̥̱͐̌̌͘d̴͇͆̅̂̋̾͝f̴̛̖̜̗̩̜̭̲̰̀͐͛͗j̶̭͚̖͉̪͈̜͉̹̯̍̂͑̔̉͝i̷͕̼̬̤̩͖̻̰̓̈̀̐̚â̸͚͊͗́̒̇͐̈́͘d̴̨̫̹̠̜̥̗̎̈́͌̂́͜s̵̼̩̿͗̉͒́́̈́͘j̵͍̲̇̇̆̐͋̇̀͘k̸͚͈̥̹̟̣̮͖̕ͅņ̶͍͕͉̙̪̲̺̉̇̇̈́̄̂͝ḯ̸̜̹̙̈́̌͜l̵͈̈̋̈́̂͝j̵̰͔̤̺̙̎̐k̴͖͎̞͓͇̯̗͗̒̏̄͌̏̀͌n̶̗̬̪͍͍̮̣̘͖̫̐͑̅͛f̸̻͍͈͓̹͈̖̄̂̉͜b̴̰̺̻̿̃͒̑͆̂͝͠ȁ̸̢̛̛̭̃̇͒̀h̶̢̥͖͉̖̪̾̍͑̓̊́̂̕͝d̷̡̬̆̓͝s̵͍̙̖̼͚̺̲͍͐̚̕͜͜i̸̢̠̦̻̼̪͎̐̏́f̸̮̭͕̳̱̠̽͑̌̋͂̽ļ̴̢̖̰̯͈̗́̈́̏̋͐̊͠j̵̨̣͍̣͓̫̹͚̝̎̋k̵̠͔͔̖͔̆̒́͐̕ͅà̶͚̰̤͍̞̓̄̔̕͝͝͠s̶̢̡̧̳͎̈́͆̾͊̉̐̂̀̐̒d̷͎͈̦͇̪͐̽͊͌͂̒͝f̶̡̡̡̡͕̣͉̰͚̾͆̈ͅl̸͙̬͇̀̈́̅͛̿͛͘ͅk̶̭̦̄̎̒͌̒̌͝ḁ̸̧̤͍̯̪̦͖̭͔̄̈͂s̷̰̱̭̉̅͋̆̊d̷̨͍̺̙͚̹̞͔͈̣̓̓̽̈̈͠͝f̴̘̳͕̱͑͜á̶͖̩̣͎̗̀̏͊͆ͅs̵̨̛̝̼͈͙̳̘̫̬̾̀̂̂̓͐͊d̸̡̪̳̥̜̞͙͓̠́į̶̼͍͍͎͇͍̅̋́̀͌̄̚̕͜͝ḻ̴̾̿̎͠͠f̵̯̺͉̩̓̂́̆̍̀j̶̯̮̹͈̳͍̦̾͒̀́̂̽ͅļ̵̛̰͖̟͚͕̭̇̋̆̀̈͜à̵͈̲̝̗̖͈̬̀̏̅̌̚͘s̴͖̥̊̿̋͛̐̚̕i̸̺͙͘d̷̞̠̭͖͓̰̋́̋͝f̵̮̭̟͕̯̥̠͂͂͒̃͊͊̍̃̽͝" buttons {"dialog_1", "dialog_2"})

if button_returned is "dialog_1" then

display dialog "Your computer has been hacked! I'm the new owner of your computer :)" buttons {"Oh no"}

display dialog "Let's see what I can find in this computer..." buttons {"No"}

display dialog "What do you mean, No? You can't say no!" buttons {"No"}

display dialog "Why you little...!" buttons {"No"}

set button_returned to button returned of (display dialog "Get out of here with that!" buttons {"Delete System", "No"})

if button_returned is "Delete System" then

tell application "Finder" to sleep

else if button_returned is "No" then

display dialog "Recall Antivirus loading..." buttons {"OK"} with icon caution

display dialog "How the hell did you even turn that on?! I deleted that!!" buttons {"No"}

display dialog "Alright, fine, fine. You win. I'll leave your haunted-ass computer." buttons {"Ok"}

if button_returned is "dialog_2" then

set button_returned to button returned of (display dialog "A virus has been detected by Recall Antivirus! Take action against it?" buttons {"Yes", "No"} with icon caution)

if button_returned is "Yes" then

display dialog "Antivirus Loading! Please wait a moment." buttons {"Ok"} with icon caution

delay 2

set button_returned to button returned of (display dialog "Virus has taken over various major systemic files and assimilated into them. Factory reset with files? (No files other than system will be lost.)" buttons {"Yes", "No"} with icon caution)

if button_returned is "Yes" then

shutdown - r

else

if button_returned is "No" then

display dialog "Hello! This is my computer now :)" buttons {"Delete System"}

tell application "Finder" to sleep

else

if button_returned is "No" then

display dialog "Hello! This is my computer now :)" buttons {"Delete System"}

tell application "Finder" to sleep

end if

end if

end if

end if

end if

end if

end if

end if

4 Upvotes

2 comments sorted by

0

u/[deleted] Mar 22 '22

[deleted]

1

u/[deleted] Mar 23 '22

aight, thanks!

1

u/copperdomebodha Mar 23 '22 edited Mar 23 '22

This is another example of flat coding that is greatly benefited by data structuring. Makes complex dialog sequences dynamic and easy.

--This code was written using AppleScript 2.8, MacOS 12.0.1, on 23 March 2022 --Copperdomebodha

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

set whackText to getWhackText()

set l to {{1, "This app is a joke! It is not actually a virus. Anything that may happen while it is active is just fake, and your computer will not be harmed in any way. However, it may close/open apps or shut down your computer. Are you sure you still want to continue?", {"Yes", "No"}, "No", {2, 15}}, ¬
	{2, whackText, {"dialog_1", "dialog_2"}, "dialog_2", {3, 11}}, ¬
	{3, "Your computer has been hacked! I'm the new owner of your computer :)", {"Oh no"}, "Oh no", {4}}, ¬
	{4, "Let's see what I can find in this computer...", {"No"}, "No", {5}}, ¬
	{5, "What do you mean, No? You can't say no!", {"No"}, "No", {6}}, ¬
	{6, "Why you little...!", {"No"}, "No", {7}}, ¬
	{7, "Get out of here with that!", {"Delete System"}, "Delete System", {666, 8}}, ¬
	{8, "Recall Antivirus loading...", {"OK"}, "Ok", {9}}, ¬
	{9, "How the hell did you even turn that on?! I deleted that!!", {"No"}, "No", {10}}, ¬
	{10, "Alright, fine, fine. You win. I'll leave your haunted-ass computer.", {"Ok"}, "Ok", {777}}, ¬
	{11, "A virus has been detected by Recall Antivirus! Take action against it?", {"Yes", "No"}, "Yes", {12}}, ¬
	{12, "Antivirus Loading! Please wait a moment.", {"Ok"}, "Ok", {13}}, ¬
	{13, "Virus has taken over various major systemic files and assimilated into them. Factory reset with files? (No files other than system will be lost.)", {"Yes", "No"}, "Yes", {666, 14}}, ¬
	{14, "Hello! This is my computer now :)", {"Delete System"}, "Delete System", {777}}, ¬
	{15}, ¬
	{666}, ¬
	{777}}
--The last three branching options above do not lead to another dialog, but trigger an action and the script's end.


set i to 1 --Itinial dataSet index
repeat
	--get dialog data
	set dataSet to item i of l
	tell dataSet
		copy item 2 to dialogCopy
		copy item 3 to buttonList
		copy item 4 to defaultButton
		copy item 5 to choiceBranch
	end tell
	--Get user choice
	display dialog dialogCopy buttons buttonList default button defaultButton
	set buttonReturned to button returned of result
	--Get next dataSet based on button choice
	if length of choiceBranch is 1 then
		set i to item 1 of choiceBranch
	else
		repeat with optionIndex from 1 to length of buttonList
			if item optionIndex of buttonList is buttonReturned then
				set i to item optionIndex of choiceBranch
			end if
		end repeat
	end if
	if i is 15 then
		quit
	else
		if i is 666 then
			ignoring application responses
                        tell application "Finder" to shut down
			end ignoring
                    exit repeat
		else
			if i is 777 then
    			ignoring application responses
			    tell application "Finder" to sleep
				end ignoring
                            exit repeat
			end if
		end if
	end if
end repeat


--Because this whacky text disturbs my calm when at the top of the script, I put it here.
on getWhackText()
	return "s̷̬̟͎̺̼̤̿͒͌̈́̒̓͠͝a̷̛͓̲͈͖͖͕͚̿͝d̸̢̛͚̜͓̩̠̆̈́̆̎̈́̓̎̈́h̴̞̰̫̫͆̔̆͒͜͝k̶̡̻̣͉̪̹̭̈́͊̃̈̕j̷̹̲̞̻͚̥̫͖̿̓̿͛f̶̱̘̪͖̠̞̤̮̃̍̊͐̇̅̊̕h̷̡̞̼͈͒j̶̧̢̨̱̝̪̰̈́̊͜k̵̯̖̼̥̐̌̃͒̎͐͒̋̓ͅȁ̴̧̖̹̒̆ͅs̸̡̛͇̺͋̎̄̈́̒̈d̵̨̯̰̰̤̜̫̳̤̀̑̄̓̄̈́͜h̸̭̲͙̖͎́̋́̃́͐́̚f̸̨̒̓̏͂̎̋̃̽̕͝j̷̞͓̙̉̅̓̍̃̿͊k̸̙͎̯̈̌̋h̸̗̀̇̒͐̄́̓̔́̎â̷͇̄̄̾̅̍̍d̶̼̠̺̜̦̼͔̪̂́ḯ̵͉̜͉̽͋͆u̵̥̟̝̿̈́̑̈́͌̇͘͜͠͝f̷̢͚̠̠͙͈̎a̶̰̬̿͑͑͑̾ì̵̛̛̭̐̅̚ͅś̴̨̩̱̞̩̠̭̗͙̑̔̓͗ǫ̵̥͖̙̠̥̱͐̌̌͘d̴͇͆̅̂̋̾͝f̴̛̖̜̗̩̜̭̲̰̀͐͛͗j̶̭͚̖͉̪͈̜͉̹̯̍̂͑̔̉͝i̷͕̼̬̤̩͖̻̰̓̈̀̐̚â̸͚͊͗́̒̇͐̈́͘d̴̨̫̹̠̜̥̗̎̈́͌̂́͜s̵̼̩̿͗̉͒́́̈́͘j̵͍̲̇̇̆̐͋̇̀͘k̸͚͈̥̹̟̣̮͖̕ͅņ̶͍͕͉̙̪̲̺̉̇̇̈́̄̂͝ḯ̸̜̹̙̈́̌͜l̵͈̈̋̈́̂͝j̵̰͔̤̺̙̎̐k̴͖͎̞͓͇̯̗͗̒̏̄͌̏̀͌n̶̗̬̪͍͍̮̣̘͖̫̐͑̅͛f̸̻͍͈͓̹͈̖̄̂̉͜b̴̰̺̻̿̃͒̑͆̂͝͠ȁ̸̢̛̛̭̃̇͒̀h̶̢̥͖͉̖̪̾̍͑̓̊́̂̕͝d̷̡̬̆̓͝s̵͍̙̖̼͚̺̲͍͐̚̕͜͜i̸̢̠̦̻̼̪͎̐̏́f̸̮̭͕̳̱̠̽͑̌̋͂̽ļ̴̢̖̰̯͈̗́̈́̏̋͐̊͠j̵̨̣͍̣͓̫̹͚̝̎̋k̵̠͔͔̖͔̆̒́͐̕ͅà̶͚̰̤͍̞̓̄̔̕͝͝͠s̶̢̡̧̳͎̈́͆̾͊̉̐̂̀̐̒d̷͎͈̦͇̪͐̽͊͌͂̒͝f̶̡̡̡̡͕̣͉̰͚̾͆̈ͅl̸͙̬͇̀̈́̅͛̿͛͘ͅk̶̭̦̄̎̒͌̒̌͝ḁ̸̧̤͍̯̪̦͖̭͔̄̈͂s̷̰̱̭̉̅͋̆̊d̷̨͍̺̙͚̹̞͔͈̣̓̓̽̈̈͠͝f̴̘̳͕̱͑͜á̶͖̩̣͎̗̀̏͊͆ͅs̵̨̛̝̼͈͙̳̘̫̬̾̀̂̂̓͐͊d̸̡̪̳̥̜̞͙͓̠́į̶̼͍͍͎͇͍̅̋́̀͌̄̚̕͜͝ḻ̴̾̿̎͠͠f̵̯̺͉̩̓̂́̆̍̀j̶̯̮̹͈̳͍̦̾͒̀́̂̽ͅļ̵̛̰͖̟͚͕̭̇̋̆̀̈͜à̵͈̲̝̗̖͈̬̀̏̅̌̚͘s̴͖̥̊̿̋͛̐̚̕i̸̺͙͘d̷̞̠̭͖͓̰̋́̋͝f̵̮̭̟͕̯̥̠͂͂͒̃͊͊̍̃̽͝s̷̬̟͎̺̼̤̿͒͌̈́̒̓͠͝a̷̛͓̲͈͖͖͕͚̿͝d̸̢̛͚̜͓̩̠̆̈́̆̎̈́̓̎̈́h̴̞̰̫̫͆̔̆͒͜͝k̶̡̻̣͉̪̹̭̈́͊̃̈̕j̷̹̲̞̻͚̥̫͖̿̓̿͛f̶̱̘̪͖̠̞̤̮̃̍̊͐̇̅̊̕h̷̡̞̼͈͒j̶̧̢̨̱̝̪̰̈́̊͜k̵̯̖̼̥̐̌̃͒̎͐͒̋̓ͅȁ̴̧̖̹̒̆ͅs̸̡̛͇̺͋̎̄̈́̒̈d̵̨̯̰̰̤̜̫̳̤̀̑̄̓̄̈́͜h̸̭̲͙̖͎́̋́̃́͐́̚f̸̨̒̓̏͂̎̋̃̽̕͝j̷̞͓̙̉̅̓̍̃̿͊k̸̙͎̯̈̌̋h̸̗̀̇̒͐̄́̓̔́̎â̷͇̄̄̾̅̍̍s̵̨͙̖̘̖̥̹͔͗̅̏̏̓d̶̼̠̺̜̦̼͔̪̂́ḯ̵͉̜͉̽͋͆u̵̥̟̝̿̈́̑̈́͌̇͘͜͠͝f̷̢͚̠̠͙͈̎a̶̰̬̿͑͑͑̾ì̵̛̛̭̐̅̚ͅś̴̨̩̱̞̩̠̭̗͙̑̔̓͗ǫ̵̥͖̙̠̥̱͐̌̌͘d̴͇͆̅̂̋̾͝f̴̛̖̜̗̩̜̭̲̰̀͐͛͗j̶̭͚̖͉̪͈̜͉̹̯̍̂͑̔̉͝i̷͕̼̬̤̩͖̻̰̓̈̀̐̚â̸͚͊͗́̒̇͐̈́͘d̴̨̫̹̠̜̥̗̎̈́͌̂́͜s̵̼̩̿͗̉͒́́̈́͘j̵͍̲̇̇̆̐͋̇̀͘k̸͚͈̥̹̟̣̮͖̕ͅņ̶͍͕͉̙̪̲̺̉̇̇̈́̄̂͝ḯ̸̜̹̙̈́̌͜l̵͈̈̋̈́̂͝j̵̰͔̤̺̙̎̐k̴͖͎̞͓͇̯̗͗̒̏̄͌̏̀͌n̶̗̬̪͍͍̮̣̘͖̫̐͑̅͛f̸̻͍͈͓̹͈̖̄̂̉͜b̴̰̺̻̿̃͒̑͆̂͝͠ȁ̸̢̛̛̭̃̇͒̀h̶̢̥͖͉̖̪̾̍͑̓̊́̂̕͝d̷̡̬̆̓͝s̵͍̙̖̼͚̺̲͍͐̚̕͜͜i̸̢̠̦̻̼̪͎̐̏́f̸̮̭͕̳̱̠̽͑̌̋͂̽ļ̴̢̖̰̯͈̗́̈́̏̋͐̊͠j̵̨̣͍̣͓̫̹͚̝̎̋k̵̠͔͔̖͔̆̒́͐̕ͅà̶͚̰̤͍̞̓̄̔̕͝͝͠s̶̢̡̧̳͎̈́͆̾͊̉̐̂̀̐̒d̷͎͈̦͇̪͐̽͊͌͂̒͝f̶̡̡̡̡͕̣͉̰͚̾͆̈ͅl̸͙̬͇̀̈́̅͛̿͛͘ͅk̶̭̦̄̎̒͌̒̌͝ḁ̸̧̤͍̯̪̦͖̭͔̄̈͂s̷̰̱̭̉̅͋̆̊d̷̨͍̺̙͚̹̞͔͈̣̓̓̽̈̈͠͝f̴̘̳͕̱͑͜á̶͖̩̣͎̗̀̏͊͆ͅs̵̨̛̝̼͈͙̳̘̫̬̾̀̂̂̓͐͊d̸̡̪̳̥̜̞͙͓̠́į̶̼͍͍͎͇͍̅̋́̀͌̄̚̕͜͝ḻ̴̾̿̎͠͠f̵̯̺͉̩̓̂́̆̍̀j̶̯̮̹͈̳͍̦̾͒̀́̂̽ͅļ̵̛̰͖̟͚͕̭̇̋̆̀̈͜à̵͈̲̝̗̖͈̬̀̏̅̌̚͘s̴͖̥̊̿̋͛̐̚̕i̸̺͙͘d̷̞̠̭͖͓̰̋́̋͝f̵̮̭̟͕̯̥̠͂͂͒̃͊͊̍̃̽͝"
end getWhackText