recentpopularlog in

kme : applescript   79

GitHub - peterldowns/iterm2-finder-tools: Open iTerm2 from the Finder | https://github.com/
You need to change the (bundled) Automator app to open a new window rather than a tab, if that's what you want by default.

As of 2019-09-05, I had to remove the "try" block and leave behind just the 'set newWindow to (create window with default profile)' so it wasn't trying to open a tab (invisbly) using the drop-down hotkey window.
iterm  finder  automation  hotkey  applescript  filemanagement  fuckina  solution 
november 2017 by kme
Noodlesoft Forums • View topic - Applescripts are altered after Yosemite upgrade
Really weird, but putting it back to the way it was before El Capitan *does* fix the problem:

Applescripts are altered after Yosemite upgrade

Postby leebj7 » Sat May 16, 2015 7:42 am
Hi,

So before my Yosemite upgrade my applescript to add screenshots to evernote looked like this:

Code: Select all
tell application "Evernote"
activate
create note from file theFile notebook {"098 BKamp Images"} tags {"screenshot”}
end tell

but then it switched to this and it won't accept my above applescript:

Code: Select all
tell application "Evernote"
activate
«event EVRNcrnt» given «class kfil»:theFile, «class Ennb»:{"098 BKamp Images"}, «class Engg»:{"screenshot"}
end tell

What am I doing wrong?
solution  mac  osx  automation  applescript  evernote  weirdness  yosemite  elcapitan 
april 2016 by kme
Write-only language - Wikipedia, the free encyclopedia
A more rarely used term is read-only language, which refers to systems with so many boundary conditions that the code can only be written through constant experimentation and not from first principles. The resulting code is perfectly readable by other programmers, but any attempt to duplicate it in another context will fail. The canonical example of a read-only language is AppleScript.
programming  language  technology  humor  applescript 
january 2015 by kme
keyboard - Using applescript to lock screen - Ask Different
This also works (goes back to the "fast user switching" login screen):
/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend
applescript  mac  osx  lockscreen  maybesolution 
october 2014 by kme
osx - How do I change mouse settings instantaneously from Terminal? - Ask Different
tell application "System Preferences"
reveal pane "com.apple.preference.mouse"
end tell
tell application "System Events" to tell process "System Preferences"
tell checkbox 1 of window 1
click
end tell
end tell

See also: http://apple.stackexchange.com/questions/60877/toggle-natural-scrolling-from-command-line-with-reload

which has this alternate solution (which requires logout/back in):
defaults write ~/Library/Preferences/.GlobalPreferences com.apple.swipescrolldirection -bool
mac  osx  naturalscrolling  annoyance  applescript  commandline 
april 2014 by kme
The PHP Singularity - http://blog.codinghorror.com/
What's depressing is not that PHP is horribly designed. Does anyone even dispute that PHP is the worst designed mainstream "language" to blight our craft in decades? What's truly depressing is that so little has changed. Just one year ago, legendary hacker Jamie Zawinski had this to say about PHP:

I used to think that PHP was the biggest, stinkiest dump that the computer industry had taken on my life in a decade. Then I started needing to do things that could only be accomplished in AppleScript.
Is PHP so broken as to be unworkable? No. Clearly not. The great crime of PHP is its utter banality. Its continued propularity is living proof that quality is irrelevant; cheap and popular and everywhere always wins. PHP is the Nickelback of programming languages. And, yes, out of frustration with the status quo I may have recently referred to Rasmus Lerdorf, the father of PHP, as history's greatest monster. I've told myself a million times to stop exaggerating.
php  programming  language  webdevel  applescript 
march 2014 by kme
MacScripter / Trim [Remove Spaces]
on trim(someText)
repeat until someText does not start with " "
set someText to text 2 thru -1 of someText
end repeat

repeat until someText does not end with " "
set someText to text 1 thru -2 of someText
end repeat

return someText
end trim
applescript  whitespace  textprocessing  scripting  samplecode  solution 
january 2014 by kme
Changing "switch between spaces" shortcut key to option-tab? - MacRumors Forums
tell application "System Events" keystroke (ASCII character 29) using {option down} end tell
mac  osx  applescript  sendkeys  hotkey  samplecode 
january 2014 by kme
Answers: osx - Minimize other windows of an application
KeePassX doesn't respond to "set miniaturized of window 1 to false" but IT DOES respond to 'set value of attribute "AXMinimized" of window 1 to false' (I think that Universal Access might need to be enabled for this to work).

I tried this, in some form, before but I think the "value of" part was key. Here's the sample code from the forum answer:
tell application "System Events" to tell (process 1 where frontmost is true)
windows where value of attribute "AXMinimized" is false
--repeat with w in result
--try
--set value of attribute "AXMinimized" of w to true
--end try
--end repeat
end tell
applescript  mac  osx  keepassx  annoyance  samplecode  solution  fuckina 
january 2014 by kme
osx - Applescript - List all hidden Window in the dock - miniaturized - Stack Overflow
2 down vote


Here is a script that works on all applications, at least on my system.

Try this

set windowsInDock to {}
tell application "System Events"
repeat with this_app in (get processes whose background only is false and windows is not {}) --get applications with 1+ window
set windowsInDock to windowsInDock & (get windows of this_app whose value of its attribute "AXMinimized" is true)
end repeat
end tell
return windowsInDock
keepassx  applescript  mac  osx  windowmanagement  annoyance  needshelp 
january 2014 by kme
OnMyCommand
This was essential for the 'open iTerm Here,' and 'Copy POSIX path(s)' plugins which are part of the user-contributed repository.
mac  osx  automation  services  solution  applescript  contextmenu  finder  likewindows  sendtomenu  essential  movein 
january 2014 by kme
AppleScript
Checking if a file or folder exists

set p to (system attribute "HOME") & "/Desktop/test.txt"

tell application "Finder" to exists POSIX file p

tell application "System Events" to exists POSIX file p

try
POSIX file p as alias
true
on error
false
end try


SOLUTION: run script (POSIX file "/Users/me/Dropbox/Scripts/AppleScript/Run Chrome in Incognito.scpt" as alias)
applescript  scripting  fuckina  essential  mac  osx  reference  samplecode  solution 
january 2014 by kme
My little Contribution to the Public Domain
Move Off-Screen Windows to the Main Screen

Here is a little applescript that moves all windows that are almost or completely off-screen to a position on the screen (main display).
This can be very handy when you plug in your Mac laptop to different displays (such as projector and flat panel). Then, it often happens (to me, at least) that some windows get pushed to the very sides of the screen, so that only a few pixels of the windows remain on-screen.
I should mention that this version is based on the script provided by Jonathan Laliberte

Here is a little variation; the difference is: all windows that are more or less off-screen (no matter how much) are moved back so that they are completely on screen (if possible).
mac  osx  utility  software  windowmangement  applescript 
march 2013 by kme
OS X utility for wrapping text in HTML? - OSX autocomplete clipboards | Ask MetaFilter
Not sure how handy you are with scripty things, but here's enough to do what you described above. Paste this into a new document in the Script Editor application:

on process(input)
return "<a href=\"" & (the clipboard as Unicode text) & "\">" & input & "</a>"
end process

Save it somewhere, then open ThisService. Give it a name, select the script you saved, and select "Filter (both)." Select a shortcut if you'd like and you're good to go.
mac  osx  automation  textprocessing  service  automator  applescript  solution 
march 2013 by kme
Beckism.com: Wrap Selection In Link in any program on Mac OS 10.6
on run {input, parameters}
set linkDefault to (the clipboard as string)
set linkDefault to my switchText(linkDefault, "\\\"", "\"")
set targetLink to do shell script "echo \"" & linkDefault & "\"|sed -E \"s/(mailto:)?(.+@.+\\..+)/mailto:\\2/\""
if targetLink does not start with "mailto:" then
set targetLink to do shell script "echo \"" & linkDefault & "\"|sed -E \"s/^(([a-zA-Z0-9-]+\\.)*[a-zA-Z0-9-]+\\.[a-zA-Z]{2,4}(\\/.*)?)/http:\\/\\/\\1/\""
if targetLink does not start with "http" then
set targetLink to "http://"
end if
end if

return "<a href=\"" & targetLink & "\">" & input & "</a>"
end run

on switchText(fromText, targetText, replaceText)
set d to text item delimiters
set text item delimiters to replaceText
set fromText to fromText's text items
set text item delimiters to targetText
tell fromText to set fromText to item 1 & ({""} & rest)
set text item delimiters to d
return fromText
end switchText

And another nugget (solution #2):
You can, of course, add simple Service actions to surround text in other arbitrary HTML tags, as well. Simply use an Applescript similar to this instead:

on run {input, parameters}
return "<strong>" & input & "</strong>"
end run


NB: When I thought this wasn't working earlier, it was because symlinks to .workflow files in ~/Library/Services don't seem to work right (actually crash
com.apple.automator.xpc.workflowServiceRunner), even though they show up in the menu.
textprocessing  applescript  mac  osx  automation  webdevel  writeroom  solution 
march 2013 by kme
osx - How to enable Bluetooth in Mac with shortcut or command line? - Super User
tell application "System Events" tell process "SystemUIServer" tell (menu bar item 1 of menu bar 1 whose description is "bluetooth") click click menu 1's second menu item end tell end tell end tell

Alternatively, you can launch System Preferences and click the checkbox:

tell application "System Preferences"
set current pane to pane id "com.apple.preferences.bluetooth"
tell application "System Events"
tell process "System Preferences"
click checkbox "On" of window "Bluetooth"
end tell
end tell
quit
end tell
mac  osx  bluetooth  applescript  automation  solution 
february 2013 by kme
osx - Un-minimizing an app with Applescript - Stack Overflow
tell app (path to frontmost application as text)
try
set miniaturized of windows to false -- most apps
end try
try
set collapsed of windows to false -- Finder
end try
end tell

-- Save this to ~/Library/Scripts, then use Quicksilver to bind the "Run Script" action for this script file to a hotkey (I picked ⌥⌘M)
applescript  windowmanagement  mac  osx  solution  essential  annoyance 
november 2012 by kme
Use iTerm With OnMyCommand - Mac OS X Hints
The solution I'm using:
tell application "iTerm"
make new terminal
tell the first terminal
activate current session
launch session "Default Session"
tell the last session
write text "cd __OBJ_NAME__"
end tell
end tell
end tell
iterm2  applescript  iterm  terminal  scripting  mac  osx  automation  onmycommand  contextualmenu  plugin 
august 2012 by kme

Copy this bookmark:





to read