Highlighted

Issue with Script UI Dialog button clicks causing previous application to load

Adobe Community Professional ,
May 15, 2020

Copy link to clipboard

Copied

Hi all - encountering a weird bug with a client. They are running Windows 10, and trying to execute a script that executes a variety of different dialogs. I'm using onClicks for the buttons. When they either use keystrokes or mouseclicks on the buttons, the script brings up the previously used application (ie, it makes Chrome the active application). I'm running these scripts on Mac Catalina, and not having this issue, nor did they have this issue running on InDesign CS6. It's only in their Windows 10 instance that's this happening. Has anyone experienced this before? Should I just use "1" and "2" results on the button clicks instead. Tough for me to test since I don't have Windows 10. Here's one sample dialog below. 

 

Thanks. 

 

 

 

var dialog = new Window("dialog"); 
	dialog.orientation = "column"; 
	dialog.alignChildren = ["center","top"]; 
	dialog.spacing = 10; 
	dialog.margins = 16; 
	dialog.text = "Test";

var statictext1 = dialog.add("statictext", undefined, undefined, {name: "statictext1"}); 
    statictext1.text = "Change cell contents to " + short_code + "?"; 

    // GROUP1
    // ======
    var group1 = dialog.add("group", undefined, {name: "group1"}); 
    group1.orientation = "row"; 
    group1.alignChildren = ["left","center"]; 
    group1.spacing = 10; 
    group1.margins = 0; 

	var button1 = group1.add("button", undefined, undefined, {name: "ok"}); 
							
		button1.text = cell_contents.contents.toUpperCase();
		button1.onClick = function() {
			dialog.close();
		}

	var button2 = group1.add("button", undefined, undefined, {name: "cancel"}); 
		button2.text = short_code;
		button2.onClick = function() {
		change_cell = true; 
	        dialog.close();
	}
							

	dialog.show();
	if (change_cell) {
	    the_cell.contents = short_code;
        }

 

 

 

TOPICS
Scripting

Views

1.1K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Issue with Script UI Dialog button clicks causing previous application to load

Adobe Community Professional ,
May 15, 2020

Copy link to clipboard

Copied

Hi all - encountering a weird bug with a client. They are running Windows 10, and trying to execute a script that executes a variety of different dialogs. I'm using onClicks for the buttons. When they either use keystrokes or mouseclicks on the buttons, the script brings up the previously used application (ie, it makes Chrome the active application). I'm running these scripts on Mac Catalina, and not having this issue, nor did they have this issue running on InDesign CS6. It's only in their Windows 10 instance that's this happening. Has anyone experienced this before? Should I just use "1" and "2" results on the button clicks instead. Tough for me to test since I don't have Windows 10. Here's one sample dialog below. 

 

Thanks. 

 

 

 

var dialog = new Window("dialog"); 
	dialog.orientation = "column"; 
	dialog.alignChildren = ["center","top"]; 
	dialog.spacing = 10; 
	dialog.margins = 16; 
	dialog.text = "Test";

var statictext1 = dialog.add("statictext", undefined, undefined, {name: "statictext1"}); 
    statictext1.text = "Change cell contents to " + short_code + "?"; 

    // GROUP1
    // ======
    var group1 = dialog.add("group", undefined, {name: "group1"}); 
    group1.orientation = "row"; 
    group1.alignChildren = ["left","center"]; 
    group1.spacing = 10; 
    group1.margins = 0; 

	var button1 = group1.add("button", undefined, undefined, {name: "ok"}); 
							
		button1.text = cell_contents.contents.toUpperCase();
		button1.onClick = function() {
			dialog.close();
		}

	var button2 = group1.add("button", undefined, undefined, {name: "cancel"}); 
		button2.text = short_code;
		button2.onClick = function() {
		change_cell = true; 
	        dialog.close();
	}
							

	dialog.show();
	if (change_cell) {
	    the_cell.contents = short_code;
        }

 

 

 

TOPICS
Scripting

Views

1.1K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
May 15, 2020 0
Adobe Community Professional ,
May 16, 2020

Copy link to clipboard

Copied

Your code work fine over here (on Windows 10). What your customer sees is probably a bug that was introduced in InDesign CC, where after a script that uses a ScriptUI dialog, after quitting the dialog, causes InDesign to lose focus, which brings the previous used application to the front. It's an INDesign thing, nothing to do with Windows

Some code changes may make a difference. If you test user response and change the code inside the dialog, things are easier (a bit more intuitive):

	var button1 = group1.add("button", undefined, undefined, {name: "cancel"}); 
		button1.text = cell_contents.contents.toUpperCase();

	var button2 = group1.add("button", undefined, undefined, {name: "ok"}); 
		button2.text = short_code;

	if (dialog.show() === 1) {
		the_cell.contents = short_code;
	}

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 16, 2020 0
Adobe Community Professional ,
May 18, 2020

Copy link to clipboard

Copied

Thanks, Peter. Switching to checking the result integer of dialog.show() didn't help, unfortunately. It's so strange that it only happens on certain computers (not on yours, not on mine). Have you ever thought up other workarounds? Having other apps closed? A VBA perhaps called to restore focus? 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 18, 2020 0
Adobe Community Professional ,
May 18, 2020

Copy link to clipboard

Copied

I don't know of any workaround. The VBA route looks too painful to me. Sorry.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 18, 2020 0
Advisor ,
May 18, 2020

Copy link to clipboard

Copied

Have you tried "app.activate();"  ?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 18, 2020 3
Adobe Community Professional ,
May 18, 2020

Copy link to clipboard

Copied

I have not. I was wondering if there was such a method in app. I started to look then got sidetracked. I'll give it a shot and report back. Thanks.  

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 18, 2020 0
Adobe Community Professional ,
May 19, 2020

Copy link to clipboard

Copied

For posterity, using app.activate() worked. The background application flickers, but then ID comes back. 

Also, I found out the client was using Windows Remote Desktop, which may have contributed to the problem. Also, if they minimized the other apps, they did not flicker. 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 19, 2020 1