• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Keyboard shortcut to select book

Community Expert ,
May 02, 2022 May 02, 2022

Copy link to clipboard

Copied

Hi,

 

I do almost everything with keyboard shortcuts. When I have a book open and a file of the book and close this file, then the Welcome Screen is selected and not the book.

Is there a keyboard shortcut to select the book?

I could not find anything in the online help or in other forum posts.

 

Best regards

 

Winfried

Views

226

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
community guidelines

correct answers 1 Correct answer

Community Expert , May 02, 2022 May 02, 2022

These things are always more complicated than they look on the surface :-). Save this to a text file and put this in the startup folder and it should do the switching to the active book automatically when the last active document is closed. Any feedback is appreciated.

#target framemaker

var CP = CP || {};

CP.getAllOpenVisibleDocs = function () {
	
	var docs, doc;
	
	docs = [];
	
	doc = app.FirstOpenDoc;
	while (doc.ObjectValid () === 1) {
		if ((doc.IsOnScreen === 1) && (doc.Label !== "Struct
...

Votes

Translate

Translate
Community Expert ,
May 02, 2022 May 02, 2022

Copy link to clipboard

Copied

This code appears to work. What would you want to use for a keyboard shortcut?

#target framemaker

var doc, book;

// Test for an active document.
// The Welcome screen will not report as the active document.
doc = app.ActiveDoc;
if (doc.ObjectValid () === 0) {
	// No active document; see if a book is open.
	book = app.FirstOpenBook;
	if (book.ObjectValid () === 1) {
		// A book is open; make it active.
		app.ActiveBook = book;
	}

Votes

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
community guidelines
Community Expert ,
May 02, 2022 May 02, 2022

Copy link to clipboard

Copied

Hi Rick,

 

I would prefer a general shortcut. Isn't there anything to just switch between all open documents _and_ books?

With your script the book file would be automatically selected, when the last regular file would have been closed?

 

Best regards

 

Winfried

Votes

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
community guidelines
Community Expert ,
May 02, 2022 May 02, 2022

Copy link to clipboard

Copied

Yes, it would only switch to the open book if no other documents were open. But you are right, there may be a general shortcut to switch back and forth, which would be more useful. Let me look around and see if there is one.

Votes

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
community guidelines
Community Expert ,
May 02, 2022 May 02, 2022

Copy link to clipboard

Copied

I forgot to mention that I close the regular file with CTRL+F4 (or CTRL+W).

CTRL+Tab does not work.

ALT+Tab switches to other applications.

Votes

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
community guidelines
Community Expert ,
May 02, 2022 May 02, 2022

Copy link to clipboard

Copied

These things are always more complicated than they look on the surface :-). Save this to a text file and put this in the startup folder and it should do the switching to the active book automatically when the last active document is closed. Any feedback is appreciated.

#target framemaker

var CP = CP || {};

CP.getAllOpenVisibleDocs = function () {
	
	var docs, doc;
	
	docs = [];
	
	doc = app.FirstOpenDoc;
	while (doc.ObjectValid () === 1) {
		if ((doc.IsOnScreen === 1) && (doc.Label !== "Structure View")) {
			docs.push (doc);
		}
		doc = doc.NextOpenDocInSession;
	}
	
	return docs;	
};

Notification (Constants.FA_Note_PostQuitDoc, true);

function Notify (note, object, sparam, iparam) {
	
	var docs, book;
    
    switch (note) {
            
        case Constants.FA_Note_PostQuitDoc:
		
		// See how many documents are open and visible.
		// The Welcome screen will not report as the active document.
		docs = CP.getAllOpenVisibleDocs ();
		if (docs.length === 0) {
			// No active document; see if a book is open.
			book = app.FirstOpenBook;
			if (book.ObjectValid () === 1) {
				// A book is open; make it active.
				app.ActiveBook = book;
				book.IsInFront = 1;
			}
		}
		break;
    }
}

Votes

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
community guidelines
Community Expert ,
May 02, 2022 May 02, 2022

Copy link to clipboard

Copied

Hi Rick,

 

Thank you very much! This works perfectly!

I am sorry, when I caused you this extra work!

 

Best regards

 

Winfried

Votes

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
community guidelines
Community Expert ,
May 02, 2022 May 02, 2022

Copy link to clipboard

Copied

LATEST

No problem! I like a challenge :-). If the script is useful to you or anyone else, please consider donating to my Ride for Roswell Cancer Center charity ride. No pressure or obligation; just putting it out there:

http://give.roswellpark.org/goto/rickquatro

Votes

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
community guidelines