Paste into Display Dialog

Since I installed Maverick I have been unable to past into the Display Dialog.

Is this a know problem or is there some way to fix it?

Thanks
Roger

This only happens with scripts run from the Scripts Menu, I believe. The solution is to wrap the calls like this:

tell application "SystemUIServer"
	display dialog "Try pasting now" default answer ""
end tell

Or better yet, use FastScripts instead of Apple’s Scripts Menu.

You are right in that the script runs in the editor properly. So I added your code but have another problem.

tell application “SystemUIServer”
set tempVar to display dialog item 2 of myRec & myMandatory & "Enter " & item 5 of myRec default answer myCit buttons {“Cancel”, item 9 of myRec} default button item 9 of myRec with title myCitType
set myCit to text returned of result
display dialog “Test1”

	end tell
	display dialog "Test2"

The code executes and displays the dialog box and when I press the button test1 is displayed. Once I press the OK button for Test1 I get a bouncing applescript editor button and if I click on it then the script displays test2 and completes the rest of my script.

It seems to hang on the end tell because if I move the end tell to the bottom of the routine it hangs there.

By the way how do I get the code to format like you did?

I appreciate your help
Roger

That’s telling you the app needs activating, so add an activate statement before the dialog. You have to do that if you are showing dialogs and changing applications.

As you write your reply, select the code and click on the button titled AppleScript.



tell application "SystemUIServer"
			activate
			set tempVar to display dialog item 2 of myRec & myMandatory & "Enter " & item 5 of myRec default answer myCit buttons {"Cancel", item 9 of myRec} default button item 9 of myRec with title myCitType
		end tell

I added the activate statement but the same problem

You need the activate when you want to change apps – that is, after you leave the SystemUIServer tell block.

I am still lost.

I tried to put the activate statement like this which did not work.

 tell application "SystemUIServer"
			
			set tempVar to display dialog item 2 of myRec & myMandatory & "Enter " & item 5 of myRec default answer myCit buttons {"Cancel", item 9 of myRec} default button item 9 of myRec with title myCitType
		end tell
		
		activate

Again thanks for your help
Roger

What comes after that code?

This is the complete section

on GetFormat(myRec)
	
	-- set fields
	set myCit to ""
	
	-- set display of mandatory field
	if item 8 of myRec = "Y" then
		set myMandatory to "(M) "
	else
		set myMandatory to ""
	end if
	
	set myCit to item 7 of myRec
	
	-- set up for date defalut
	if item 7 of myRec = "CDate" then
		--Format current date
		set myYear to get the (year of (current date)) as string
		set myMonth to get the (month of (current date)) as string
		set myDay to get the (day of (current date)) as string
		set myCit to myDay & " " & myMonth & " " & myYear
	end if
	
	-- save default
	set myCase to item 7 of myRec
	
	-- blank myCit if not needed
	if item 7 of myRec = "upper" then set myCit to ""
	if item 7 of myRec = "lower" then set myCit to ""
	if item 7 of myRec = "default" then set myCit to ""
	
	set myApp to name of (info for (path to frontmost application))
	
	
	-- repeat if option field is "Y" and field is blank
	repeat
		tell application "SystemUIServer"
		set tempVar to display dialog item 2 of myRec & myMandatory & "Enter " & item 5 of myRec default answer myCit buttons {"Cancel", item 9 of myRec} default button item 9 of myRec with title myCitType
		end tell
		activate
		
		set myCit to text returned of result
		
		-- change to upper case if requested
		if myCase = "upper" then
			set myCit to upperCase(myCit)
		end if
		-- change to lower case if requested
		if myCase = "lower" then
			set myCit to lowerCase(myCit)
		end if
		
		if myCit ≠ "" then
			set myCitation to myCitation & item 4 of myRec & myCit & item 6 of myRec
		end if
		
		-- check to see if option field is not "N" or if field has data
		if item 8 of myRec = "N" then exit repeat
		
		-- exit repeat if 
		if myCit ≠ "" then exit repeat
		
	end repeat
	
	
end GetFormat

Your code doesn’t compile. I suspect your problem has nothing to do with SystemUIServer, so remove that altogether for the time being, and just use a normal display dialog you can’t paste into. Type in your results for now, until everything else is working. Then wrap the dialog in the SystemUIServer tell block.

Adding those extra display dialogs for debugging is just confusing things while you use the SystemUIServer tell block.

And do yourself a favor and check out FastScripts. It’s so much better than the standard scripts menu.

One thing try activating the app before the dialog.

I have placed the activate before the tell block, after the start of the tell block, after the end of the tell, and all 3 places with no success. Some of the places caused different problems such as not being able to get anything entered into the dialog when I go the the web page and copy what I want then come back and the dialog is completely unresponsive. What I call unable to get focus.

This problem just started when I upgraded to Maverick.

The block I posted is just a small part of the complete script and I would not expect it to compile. When it is used with the rest of the script it compiles fine with no errors.

As far as FastScripts this script is fast enough. Most of the time is taken up entering data into the dialog.

Thanks for your help.

For now I have decided to give up on fixing it and just use it by keying in the data as there is only one field that I usually do a copy and past.

Thanks
Roger

This is how it should be. Works fine here except you haven’t defined what the myCitType variable is.

 tell application "SystemUIServer"
activate
       set tempVar to display dialog item 2 of myRec & myMandatory & "Enter " & item 5 of myRec default answer myCit buttons {"Cancel", item 9 of myRec} default button item 9 of myRec with title myCitType
       end tell

Thanks for the suggestion. What happens when I use the SystemUISderver in my script it displays the dialog. I then go to my browser and copy the text I want to enter then come back to the script it will not accept any input at all. No keyboard input or paste. It will allow me to cancel.

This is what I found that works: Why tell finder works and the tell systemUIserver dose not work I don’t know.

 			tell application "Finder"
			activate
			set tempVar to display dialog item 2 of myRec & myMandatory & "Enter " & item 5 of myRec default answer myCit buttons {"Cancel", item 9 of myRec} default button item 9 of myRec with title myCitType
		end tell

Thanks again for everyone’s help.
Roger

Coming back to this: it seems the original problem has been rectified in 10.9.2, so there should no longer be the need for workarounds.