Have a dialog display during a repeat

I want to have a repeat going while there is a dialog open. I want this to happen:


	repeat
		set visible of process "Chrome" to false
	end repeat

While this happens:


set passresult to the text returned of (display dialog "Password:" default answer "" with hidden answer)
if passresult is "thebiggs" then (do something that will end the above repeat)

How would I go about doing this?

Any script will wait while a dialog is open: you cannot ask for a password outside a repeat loop, and have the loop execute before you clicked the OK button of the dialog. You can ask for a password within the loop, and exit like so:

repeat
	set visible of process "Chrome" to false
	set passresult to the text returned of (display dialog "Password:" default answer "" with hidden answer)
	if passresult is "thebiggs" then exit repeat
end repeat

EDIT: Okay, now I’m doing this:

tell application "keepchromeclosed"
	activate
end tell
repeat
	set passresult to the text returned of (display dialog "Password:" default answer "" with hidden answer)
	if passresult is "thebiggs" then
		tell application "keepchromeclosed" to quit
		tell application "System Events"
			set visible of process "Chrome" to true
			exit repeat
		end tell
	end if
end repeat
tell application "keepchromeclosed"
	quit
end tell

But the dialog won’t open!

What are you actually trying to accomplish, i.e., what is your higher goal?

I’m trying to make it so Chrome stays hidden until you enter the right password.

That I got; what I meant was why? A user can just switch to another browser. Is it that you want a page left in place but don’t want others to know what it is? Couldn’t you just save the URL and close Chrome? Or put the machine to sleep with a password to awaken?

I have a solution - saving the URL and making a script that opens Chrome only when a password is given. It’s done now, no help needed/