Is there a way to either disable or quickly clear the frequent items list when right clicking on Windows Explorer in my taskbar? If you just want to clear it for now uncheck under Privacy the bottom one which will take this off and the check it again and it will start to build the list again.
A better way to activate menu items from AppleScript | 25 comments | Create New Account
Click here to return to the 'A better way to activate menu items from AppleScript' hint |
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Thanks for the great hint. I'm sure there is probably a good reason why, but why not include the 'tell application X to activate' line at the beginning of your helper function?
if he moved the activate into the helper, it wouldn't be 100% generic. it would just be a itunes script.
He passes the app name ('iTunes' in his example) to the helper function. What I was asking is why not use that function argument to tell the appropriate app to activate. Like the 'WHY NOT...' part below:
Yeah, that makes quite a bit of sense. I guess I never thought about it. One thing worth pondering is that I think some applications may do something if you activate them when they're already frontmost (applications can handle the activate message however they want AFAIK). So if we grab multiple menu items in a row, the app will end up being activated several times. Still, this probably a non-issue, so go ahead and add that line.
BTW you can go shorter and put it 'active application X' instead of 'tell application X to activate'
Its a pity that this really generic and clever function fails with non english menus.
I haven't seen a non-English OSX menu, but I'm thinking that, if it's like menus I saw in German PCs years ago, the position of the menu item doesn't change ... only its name changes.
Which might not be any help to know, but, *if* you can write a script that finds menu items to click by some index of their position on the menu, you might be able to craft a script that doesn't care what language the menu itself uses.
What do you think? Is it possible? Crazy?
Which might not be any help to know, but, *if* you can write a script that finds menu items to click by some index of their position on the menu, you might be able to craft a script that doesn't care what language the menu itself uses.
What do you think? Is it possible? Crazy?
Are you sure ? I just used it with Pages and french menus, and it worked perfectly.
I pasted the code in Script Editor then added these two lines :
tell application 'Pages' to activate
menu_click({'Pages', 'Insertion', 'Note de bas de page'})
And it worked (it inserts a footnote).
FG
I pasted the code in Script Editor then added these two lines :
tell application 'Pages' to activate
menu_click({'Pages', 'Insertion', 'Note de bas de page'})
And it worked (it inserts a footnote).
FG
Here's a fourth syntax you can use:
![Is there a way to clear multiple items in quickbooks for mac 2016 2018 Is there a way to clear multiple items in quickbooks for mac 2016 2018](http://www.quick-training.com/wp-content/uploads/2013/07/5.8.bmp)
(“of” and “in” are synonyms, in case you're wondering.)
Yeah, I know you can get child items in a bottom-up way rather than a top-down one, but it's less intuitive to me. I guess you do avoid all the
()
and 's
in there. I still like my way better ;) A better way to activate menu items from AppleScript
that looks great, how about a way to test if a menu item is available, so I can toggle on and off the visualizer!
What a great general pupose script! THANKS!
What a great general pupose script! THANKS!
A better way to activate menu items from AppleScript
Use a try/on error block to do what you want. If the error block is entered, the menu didn't exist.
A better way to activate menu items from AppleScript
Can any of this be used to select 'Login Window...' from the user menu? So far I haven't found a way to set a command key to switch immediately to the login window... (And I haven't found anything via a search of Mac OS X Hints...)
Thanks!
Thanks!
A better way to activate menu items from AppleScript
It doesn't use this function, but I script the 'Login Window' item this way:
This should work if you are using 10.4.x, use English as your system language, and have the FUS menu displayed in the menu bar. It works for me, at any rate.
A better way to activate menu items from AppleScript
I made a few changes to the script, and pasted it on the pastie pastebin. There are no functional changes, but the code is a bit nicer. One change in this version is the use of '
car
' and 'cdr
' instead of 'f
' and 'r
', mostly as a joke for the sake of hmelman, the author of the recent Quicksilver manual. Also, apparently it's possible to do items k through end of aList
instead of items k through (length of aList) of aList
. Nice!Let me finally put an obligatory plug for using TextMate to write AppleScripts. We've added some very handy snippets that will fill in quite a bit of your code for you. I'm going to try to get a screencast done sometime in the next few weeks showing how to use the bundle to best effect.
A better way to activate menu items from AppleScript
Any particular reason these scripts wouldn't work with Thunderbird?
I'm trying to make a shortcut that will activate the Thunderbird -> Tools -> Delete Mail Marked as Junk in Folder menu item.
I'm trying to make a shortcut that will activate the Thunderbird -> Tools -> Delete Mail Marked as Junk in Folder menu item.
A better way to activate menu items from AppleScript
Sorry, I subsequently used the cleaned up script from 'pastie' site and it now works fine.
A better way to activate menu items from AppleScript
Hi, is there any way to save your menu_click as a script,
then recall it when you make a new script
ie
%%%%%%%%%%%%%%%%%%%%%%
run script file '...:menu click1.scptd'
tell application 'Finder' to activate
menu_click({'Finder', 'View', 'Arrange By', 'Size'})
%%%%%%%%%%%%%%%%%%%%%%%%%
that would make it alot easier when creating new scripts that will use you menu click.
cheers, kdatt
then recall it when you make a new script
ie
%%%%%%%%%%%%%%%%%%%%%%
run script file '...:menu click1.scptd'
tell application 'Finder' to activate
menu_click({'Finder', 'View', 'Arrange By', 'Size'})
%%%%%%%%%%%%%%%%%%%%%%%%%
that would make it alot easier when creating new scripts that will use you menu click.
cheers, kdatt
![Is There A Way To Clear Multiple Items In Quickbooks For Mac 2016 Is There A Way To Clear Multiple Items In Quickbooks For Mac 2016](/uploads/1/2/6/2/126247720/172247257.png)
A better way to activate menu items from AppleScript
You've probably figured this out already as it's been some time since your post. But anyway...
I keep all my common code in a file called Common code.scpt and keep it in my Library/Scripts folder.
(*
PUT THE FOLLOWING LINE AT THE TOP OF ANY SCRIPT YOU LIKE
set commonScript to load script alias ((path to library folder from user domain as string) & 'Scripts:Common code.scpt')
AND THEN USE THIS LINE TO CLICK A MENU ITEM
menu_click('Finder', 'View', '...', '...') of commonScript
*)
---
Brought to you by S C Johnson, a family multinational conglomerate.
I keep all my common code in a file called Common code.scpt and keep it in my Library/Scripts folder.
(*
PUT THE FOLLOWING LINE AT THE TOP OF ANY SCRIPT YOU LIKE
set commonScript to load script alias ((path to library folder from user domain as string) & 'Scripts:Common code.scpt')
AND THEN USE THIS LINE TO CLICK A MENU ITEM
menu_click('Finder', 'View', '...', '...') of commonScript
*)
---
Brought to you by S C Johnson, a family multinational conglomerate.
A better way to activate menu items from AppleScript
I love this function, but the following
menu_click({'Mail', 'Message', 'Move To', 'Keep'})
Takes 4-10 seconds to execute on my mac. Other applescripts generally execute quickly. Any idea how to profile this to determine what's taking the time? I would love to use this and not struggle through menu expressions as before!
menu_click({'Mail', 'Message', 'Move To', 'Keep'})
Takes 4-10 seconds to execute on my mac. Other applescripts generally execute quickly. Any idea how to profile this to determine what's taking the time? I would love to use this and not struggle through menu expressions as before!
A better way to activate menu items from AppleScript
Wonderful hint.
How would you indicate the Finder's Apple menu? I've been looking for a way to engage the recent items for quite some time.
Also, when running
tell application 'Finder' to activate
tell application 'System Events'
click menu item 'Size' of ((process Finder)'s (menu bar 1)'s ¬
(menu bar item 'View')'s (menu 'View')'s ¬
(menu item 'Arrange By')'s (menu 'Arrange By'))
end tell
I get this error: The Variable 'Finder' is not defined. Should it be in Quotes?
Also, this code:
tell application 'System Events'
click menu item 'Size' ¬
in menu 'Arrange By' of menu item 'Arrange By' ¬
in menu 'View' of menu bar item 'View' ¬
in menu bar 1 of process 'Finder'
end tell
gives an error for ';'. Is this a typo?
How would you indicate the Finder's Apple menu? I've been looking for a way to engage the recent items for quite some time.
Also, when running
tell application 'Finder' to activate
tell application 'System Events'
click menu item 'Size' of ((process Finder)'s (menu bar 1)'s ¬
(menu bar item 'View')'s (menu 'View')'s ¬
(menu item 'Arrange By')'s (menu 'Arrange By'))
end tell
I get this error: The Variable 'Finder' is not defined. Should it be in Quotes?
Also, this code:
tell application 'System Events'
click menu item 'Size' ¬
in menu 'Arrange By' of menu item 'Arrange By' ¬
in menu 'View' of menu bar item 'View' ¬
in menu bar 1 of process 'Finder'
end tell
gives an error for ';'. Is this a typo?
A better way to activate menu items from AppleScript
Answer my own question:
¬ should be the end of line character (option-L; I don't know how to type it correctly in this forum).
¬ should be the end of line character (option-L; I don't know how to type it correctly in this forum).
A better way to activate menu items from AppleScript
Answer my other question--how to get the 'Apple' menu--(and figured out how to display code):
Thanks so much for this handy pair of functions. Works great even in Mac OS X 10.7.4.
A better way to activate menu items from AppleScript
This is still a brilliant helper function, but It does not work when I try to put it in a loop. What’s the problem with that. Sorry, I am not good in applescript.
I would like to make the same action for a couple of selected files in Adobe Acrobat. It works well for a single file but not with a selection.
Greetz,
PDXIII
[code]
-- `menu_click`, by Jacob Rus, September 2006
--
-- Accepts a list of form: `{'Finder', 'View', 'Arrange By', 'Date'}`
-- Execute the specified menu item. In this case, assuming the Finder
-- is the active application, arranging the frontmost folder by date.
on menu_click(mList)
local appName, topMenu, r
-- Validate our input
if mList's length < 3 then error 'Menu list is not long enough'
-- Set these variables for clarity and brevity later on
set {appName, topMenu} to (items 1 through 2 of mList)
set r to (items 3 through (mList's length) of mList)
-- This overly-long line calls the menu_recurse function with
-- two arguments: r, and a reference to the top-level menu
tell application 'System Events' to my menu_click_recurse(r, ((process appName)'s ¬
(menu bar 1)'s (menu bar item topMenu)'s (menu topMenu)))
end menu_click
on menu_click_recurse(mList, parentObject)
local f, r
-- `f` = first item, `r` = rest of items
set f to item 1 of mList
if mList's length > 1 then set r to (items 2 through (mList's length) of mList)
-- either actually click the menu item, or recurse again
tell application 'System Events'
if mList's length is 1 then
click parentObject's menu item f
else
my menu_click_recurse(r, (parentObject's (menu item f)'s (menu f)))
end if
end tell
end menu_click_recurse
-- main function below
tell application 'Finder'
try
repeat with currentFile in items of (get selection)
set filepath to currentFile as text
tell application 'Adobe Acrobat Pro'
open filepath
menu_click({'Acrobat', 'Datei', 'Speichern als...', 'PDF mit erweiterten Reader-Funktionen', 'Kommentieren und messen aktivieren...'})
end tell
end repeat
on error e
return e
end try
end tell
[/code]
I would like to make the same action for a couple of selected files in Adobe Acrobat. It works well for a single file but not with a selection.
Greetz,
PDXIII
[code]
-- `menu_click`, by Jacob Rus, September 2006
--
-- Accepts a list of form: `{'Finder', 'View', 'Arrange By', 'Date'}`
-- Execute the specified menu item. In this case, assuming the Finder
-- is the active application, arranging the frontmost folder by date.
on menu_click(mList)
local appName, topMenu, r
-- Validate our input
if mList's length < 3 then error 'Menu list is not long enough'
-- Set these variables for clarity and brevity later on
set {appName, topMenu} to (items 1 through 2 of mList)
set r to (items 3 through (mList's length) of mList)
-- This overly-long line calls the menu_recurse function with
-- two arguments: r, and a reference to the top-level menu
tell application 'System Events' to my menu_click_recurse(r, ((process appName)'s ¬
(menu bar 1)'s (menu bar item topMenu)'s (menu topMenu)))
end menu_click
on menu_click_recurse(mList, parentObject)
local f, r
-- `f` = first item, `r` = rest of items
set f to item 1 of mList
if mList's length > 1 then set r to (items 2 through (mList's length) of mList)
-- either actually click the menu item, or recurse again
tell application 'System Events'
if mList's length is 1 then
click parentObject's menu item f
else
my menu_click_recurse(r, (parentObject's (menu item f)'s (menu f)))
end if
end tell
end menu_click_recurse
-- main function below
tell application 'Finder'
try
repeat with currentFile in items of (get selection)
set filepath to currentFile as text
tell application 'Adobe Acrobat Pro'
open filepath
menu_click({'Acrobat', 'Datei', 'Speichern als...', 'PDF mit erweiterten Reader-Funktionen', 'Kommentieren und messen aktivieren...'})
end tell
end repeat
on error e
return e
end try
end tell
[/code]
Ask the Expert - Merging Invoices
Q - My procedures have been to invoice as soon as a part of the project is completed. I just found out that the owner of the company has been holding the invoices. He now wants me to issue one invoice even though currently there are several. There are pass thru expenses and many lines of time detail on each invoice. Is there any way to merge existing invoices together?
A - This situation has several ramifications, besides the obvious logistical issue you have already mentioned. My biggest concern is how old are the invoices? Are they more than a month, more than a quarter? If your Accountant has already issued the financial statements for the period in question, this can become an issue for them as well. My second concern deals with customer service. Specifically, when an invoice is issued, it begins aging. If the invoice becomes past due, typically a statement is sent. Has the customer been notified in any way of the invoice. I am assuming that they did not receive the invoice per your question, but have they received a statement? Is it going to be confusing to them if the invoice number and/or amount is changed? And finally, what can be done to remedy this situation in the future. For example, should the invoices be marked as pending until they are approved? Is there a way to generate a report from QuickBooks (such as an unbilled cost report, or a report that combines the time and costs such as the WIP add-on) that can be used for the approval process rather than an invoice?.
Now for your question: There are two issues, the first is the fact that if you delete in invoice, that does not make the time and expenses billable again. For that reason, you will not be able to use the time/cost button to just quickly re-create the invoices assuming that was the procedure the first time..
One alternative is to enter the information manually onto one of the invoices from the other. If the item is on the printed one and the description is primarily the same as the item, this may be a viable alternative.
If the descriptions are detailed and different than the item, creating a report (such as a journal report with the item and item description columns added) may be more efficient. This report can be opened in Excel to permit cutting and pasting the information without needing to switch back and forth between the two invoices in QuickBooks.
If there are a lot of detail lines, to automate the process a little, create a journal report in QuickBooks of the invoices adding the item column and anything else you will need as described above. Use the excel interface then cut and paste the additional detail lines as part of the same invoice in the Excel journal entry (make sure to delete the second A/R line and update the A/R total as appropriate). Then use the QuickBooks transaction copier to create an iif file of new invoices. Import it into QuickBooks and void the old ones to remove them from the data file. You can try it out with the free trial version of the tool.