What does applescript call a drop down menu? - applescript

This question concerns applescript syntax. What does applescript call a drop down menu? And what does applescript call an item on a drop down menu?

This works via 'System Events'. Let's say you want to click 'open file...' from the 'file' menu.
tell application "System Events" to tell process "Finder"
click menu item "Open file..." of menu 1 of menu bar item "File" of menu bar 1
end tell

I think the author was looking for the term "pop up button" or "combo box".

Related

how to edit gnome-terminal right click context menu items

I want to edit context menu in gnome-terminal,
could you tell how to edit gnome-terminal right click context menu items

Block commenting Haskell code in textwrangler

I am new to textwrangler and I am trying to figure out how to have a shortcut for commenting out blocks of haskell code. The available Un/Comment Block option from the menu doesn't seem to do anything.
I've used Prefix/suffix lines but that is just too awkward. Does anyone have any suggestions?
Thanks
I'm assuming you're using TextWrangler on OS X.
When you're running TextWrangler you should see a little scroll in the menu bar (the AppleScript button). Click it. Then choose the 'Open Script Editor' option. Go to your Desktop folder and click 'New Document'. Name the file something like 'comment_script'. Type the following text into the editor window that appears:
tell application "TextWrangler"
set my_selection to selection
set my_selection to "{-\n" & my_selection & "\n-}"
set selection to my_selection
end tell
Save it and quit the editor.
Once you're done with that, copy the comment_script file to the folder ~/Library/Application\ Support/TextWrangler/Scripts
Now you'll find comment_script in the script menu (the one with the scroll). Select some text in TextWrangler and then click on comment_script in the script menu to comment the selection.

How to select a secondary menu item as the focus of "Accessibility Inspector" in Mac OS?

Specifically, I'm trying to select iTunes' menu item "File > Library > Export Library" but it interprets clicking on "File" as locking AI's focus, rather than activating file. The NEXT click activates the File menu, but then I can't switch the focus to the menu item I'm really interested in?
Press optionspace after the first click on "File", then move the cursor through the menu, then optionspace again to lock on the element you want.

Disable Undo Delete/Move/Rename/Copy menu

I install TortoiseSVN. It add "update" menu item to right click menu. And this menu item 's
hotkey is "u". Unfortunately, the "undo XXX" menu item 's hotkey is "u", too.
Sometimes I right click on the desktop or inside a folder and press "u". It will trigger the "undo XXX" menu item when this menu item is enable, but I want to trigger "update" menu item. It's a great inconvenience to me.
How can I disable the "undo XXX" menu item, or change the hotkey of the "undo XXX" menu item, or fix it?
You can disable the accelerators on the context menu.
It's in the advanced settings page. Look for ShellMenuAccelerators.

Xcode — quickly open current file in external editor

Is it possible to set a keyboard shortcut (or maybe add some menu item somewhere) to open currently edited file in external editor?
(Obviously I may do [ (right click in file tree → Show in Finder) / (right click in window title → select containing directory) ] → right click on file → Open With → "the app" — but it's too much steps.)
Huh, I've found it.
Start Automator.app.
Select "Service".
Drag-n-drop "Run AppleScript" to workflow.
Set "service receives" to "no input", and application is Xcode.
Paste this code (replace MacVim with your editor)
tell application "Xcode"
set current_document to last source document
set current_document_path to path of current_document
end tell
tell application "MacVim"
activate
open current_document_path
end tell
Save workflow.
In System Preferences → Keyboard → Keyboard Shortcuts → Services → General, assign a shortcut.
You're done!
I've borrowed AppleScript code from this project: Uncrustify Automator Services for Xcode 4.
A better solution is to add a keyboard shortcut directly in the keyboard preferences pane:
open "System Preferences" → "Keyboard" → "Keyboard Shortcuts" → "Application Shortcuts"
click on the "+" plus sign
select "XCode" as Application and type "Open with External Editor" as Menu Title
set your shourcut (I'm using ⇧⌃E)
Because I use tabs, I was eager for a solution that wouldn't open a document from the first tab. I ended up with following:
Note: If Assistant editor is opened, the file from the Standard Editor (on the left side) is opened regardless which editor is active, but for me it's better than the first tab.
on run {input, parameters}
set current_document_path to ""
tell application "Xcode"
set last_word_in_main_window to (word -1 of (get name of window 1))
if (last_word_in_main_window is "Edited") then
display notification "Please save the current document and try again"
-- eventually we could automatically save the document when this becomes annoying
else
set current_document to document 1 whose name ends with last_word_in_main_window
set current_document_path to path of current_document
end if
end tell
tell application "MacVim"
if (current_document_path is not "") then
activate
open current_document_path
end if
end tell
return input
end run
I really liked the solution that Fjölnir made, so to expand on how to do that.
Choose the Menu: "Xcode" -> "Preferences..."
Click the "Key Bindings" Tab on the Preferences Window
In the "Filter" search box enter External
Double click on the "Key" column next to the "Open with External Editor (File Menu)" command.
If you are using MacVim for this, you can improve the load time for the external editor by configuring it to stay running after the last window closes.
Choose the Menu: "MacVim" -> "Preferences..."
In the "General" tab set "After last window closes" to "Hide MacVim"
Now when I press ⌥E the window pops open, I make my change, :q, and focus returns to Xcode.

Resources