Re: Looking for Scripts, Snippets, Ideas for Toggling Windows and Tabs of an App
Re: Looking for Scripts, Snippets, Ideas for Toggling Windows and Tabs of an App
- Subject: Re: Looking for Scripts, Snippets, Ideas for Toggling Windows and Tabs of an App
- From: David Gregg <email@hidden>
- Date: Thu, 30 Mar 2017 07:33:37 -0600
> On Mar 29, 2017, at 5:49 PM, Jim Underwood <email@hidden> wrote:
>
> David,
>
> Thank you very much.
> That script works perfectly with Script Editor and Evernote, and probably any other app with multiple windows.
You are very welcome, and yes that should work in any app with multiple windows.
The tabbing solution is more difficult because there currently isn't a standard way for keeping track of the tab history. Even if there is a way to get the tab index it is generally just ordered in a left to right sequence (this is the case in both Safari and Script Debugger).
You already mentioned that you have methods for moving to the previous/next tab in a number of apps. Without the tab history it becomes an exercise in determining whether you should move left or right from the current tab. Furthermore, if the current and last tabs are not next to each other than how many times do you need to use the previous/next tab.
Solution 1 - the cop-out solution
========
While maybe not being as tidy/convenient there often are preferences to have an app work with separate windows rather than tabs, in these cases then the previously sent script would work.
Solution 2
========
To simplify the solution, if possible physically move the tabs so they are next to each other. Select the left-most tab and run a script to save off the name of the left most tab. Then a second script, the one you will be using for the toggling, can be run which uses that left tab name to choose the appropriate previous or next command.
Below is an example for Script Debugger using mostly System Events. A Keyboard Maestro variable is used to save off the name of the left-most tab.
Example for Script Debugger
======================
-- Script #1
on determineFirstTabName()
-- Assuming tabs are next to each other and currently selected
-- tab is the left of the two
tell application "Script Debugger"
activate
set firstTab to name of (current document of script window 1)
end tell
tell application "Keyboard Maestro Engine"
setvariable "FirstTab" to firstTab
end tell
end determineFirstTabName
-- Script #2
on toggleRecentTwoTabs(tabList)
tell application "Script Debugger"
set currentTab to name of (current document of script window 1)
end tell
tell application "Keyboard Maestro Engine"
set firstTab to getvariable "FirstTab"
end tell
if currentTab = firstTab then
my goToNextTab()
else
my goToPreviousTab()
end if
end toggleRecentTwoTabs
on goToNextTab()
tell application "System Events"
tell process "Script Debugger"
keystroke "]" using {command down, option down}
delay 0.5
end tell
end tell
end goToNextTab
on goToPreviousTab()
tell application "System Events"
tell process "Script Debugger"
keystroke "]" using {command down, option down}
delay 0.5
end tell
end tell
end goToPreviousTab
>
> Best Regards,
>
> Jim Underwood
> aka JMichaelTX
>
>
> From: David Gregg <email@hidden>
> Date: Wed, Mar 29, 2017 at 5:19 PM
> To: JMichael <email@hidden>
> Cc: "ASUL (AppleScript)" <email@hidden>
> Subject: Re: Looking for Scripts, Snippets, Ideas for Toggling Windows and Tabs of an App
>
> Jim,
>
> I believe this will handle the window toggling.
>
> tell application "System Events"
> set frontmostApp to name of first item of (processes whose frontmost is true)
> tell process frontmostApp
> set value of attribute "AXMain" of window 2 to true
> end tell
> end tell
>
> David
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> AppleScript-Users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> Archives: http://lists.apple.com/archives/applescript-users
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden