How Do I Move Script Document to New Window?

###How Do I Move Script Document to New Window?
Running Script Debugger 6.0.4 (6A198) on macOS 10.11.6.

I suppose this is very obvious to most of you, but after exploring the SD6 sdef and some trial and error, I do not see how to do this.

I have a script document in one of the tabs in a window.
Let’s say it is the active tab in the active window.
I want to move it from the tab to a new window.

Any help would be appreciated.

I suspect this is related to my “Where is ‘Merge all Windows’?” question in the “Scratch Buffer” thread, where @alldritt replied:

Interactively you can move a tab from one window to another by dragging the tab. This functionality is not exposed through Script Debugger’s scripting interface.

Could you please add it.

I’m guessing that will come when SD moves to the sierra API ?

No, not in this instance. Scripting interface improvements are feature requests we’ll consider for future versions of SD.

Hey Mark,

I’m not expecting answers to this. I’m just putting it out there as food-for-thought.

While it would be nice to be have full control over tabs in tabbed windows, the thing I want most is the ability to pull a tab out of one into its own window.

I don’t use tabs much in Script Debugger or most other apps, because tab management on macOS is very poor and mostly click-centric.

I wrote my own window/tab UI for Safari in AppleScript over 10 years ago, and things haven’t improved much.

Keystroke access to 9 tabs helps quite a bit here, but I had done that with AppleScript over 10 years ago too.

Serially moving through tabs is a good feature to have but a pain to use in practice – particularly when toggling between just 2 or 3 of them.

I have a Keyboard Maestro macro that opens the Window menu for any app that has one, and that lets me eyeball the window-list and type-select to pick one. It’s not an ideal UI, but it gets the job done expeditiously quite often.

As I mentioned in another thread, I have a Keyboard Maestro macro to toggle between windows 1 and 2 – and I get a tremendous amount of milage out of that.

I will think about changing my tab-movement keybindings to make them more useful for me, because I sometimes used tabbed-windows when working on related scripts.

Script Debugger has wonderful features for terminology discovery and debugging, but it also has niceties – something the app-store has put on the endangered species list.

Please don’t take any away, and please consider where you can add some more without breaking your back.

And keep in mind that you’re very much appreciated by more than a few of us out here in Mac-land.


Take Care,
Chris

1 Like

Since SD6 does not support scripting for this, I built this simple Keyboard Maestro Macro that gets the job done. I’m not posting the actual macro file yet since I’m still testing it, but if anyone wants it, just post here and I’ll share.

###KM Macro to Move SD6 Tab to New Window
It opens the tab in a new window on my other monitor, and then closes the original tab, and then sets focus to the new window.

1 Like

This seems like an easy fix though. The only reason you can’t assign a normal Sys Prefs keyboard shortcut to the File > Open in New Window menu item is because it contains a variable. If that menu item had a static title like ‘Open Current Tab in New Window’ there’d be no problem.

2 Likes

###Open File In New Window
Mark, what about opening a file in new window?
What is the best practice for this?

I have this script, which works, but seems convoluted and results in a blank tab document as well:

tell application "Script Debugger"
  set fileToOpen to POSIX path of (path to documents folder) & "Test/@TEST open window.scpt"
  
--- Creates New Window with Empty doc in Tab 1 ---
  set oDoc to (make new document)
  set newWin to script window 1 of oDoc
  
--- Opens File in Tab 2 ---
  open fileToOpen in window newWin

### I just want a new window with the file and nothing else.  How do I get it?
  
  ### THIS FAILS ###
  # open fileToOpen in new window
  # open fileToOpen in window (new window)
  # open fileToOpen in window (make new window)
    
  
end tell

Open File in New Window

OK, here’s my new improved version, that closes the blank, untitled, tab.

@alldritt, but why does SD6 spin for 5.00 seconds doing nothing AFTER the open statement?

use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

property curApp : current application


tell application "Script Debugger"
  set fileToOpen to POSIX path of (path to documents folder) & "Test/@TEST open window.scpt"
  
  set oDoc to (make new document)
  set newWin to script window 1 of oDoc
  
  
  set gTimerStartDate to curApp's NSDate's |date|()
  
  ### WHY DOES THIS TAKE 5.00 SECONDS? ###
  #  The file opens immediately, but then SD6 just spins
  
  open fileToOpen in window newWin
  set durationNum to -(gTimerStartDate's timeIntervalSinceNow())
  
  close (document 1 of newWin) saving no
  
  ### THIS FAILS ###
  # open fileToOpen in new window
  # open fileToOpen in window (new window)
  # open fileToOpen in new window (make new window)
  
  
end tell

I had similar issues with “open” with my attempt at creating a scratch window.

It’s a bug in Cocoa scripting – the command doesn’t return for 5 seconds. It should be fixed in the current beta version.

1 Like

Hey Phil,

Not so fast…

That command opens a second instance of the window in question.

-Chris

1 Like