Question about applescript and expose - objective-c

Using applescript, how can I get the "preview" of a window of an application? By preview I mean the preview window you see when you use expose on your mac. How can I get those video feeds using applescript, or if not applescript using cocoa framework?
Thanks!

You can't do it from AppleScript, but you can do it from C. See the Quartz Window Services functions and the Son of Grab example.

Related

How to show the NSUserNotification in command-line-tool program?

I want to write a command-line-tool program that only shows the NSUserNotification. I've found out, that in order to show the NSUserNotification I need to create a Cocoa App and is not what I want.
I want to run my program at log-in in background, so that my notification is always visible. How can I do that without creating a Cocoa App?
These are the options I found...
Trick Mac OS X into allowing a notification from a command-line tool.
Trigger the notification using Applescript or a helper application.
Create an Automator workflow & execute it using the automator command.
Automator provides a better experience than Applescript. Didn't try the helper.

Objective equivalent to AppleScript : Opening directory without bringing every finder window to from

There this AppleScript
tell application "Google Chrome" to set index of window 1 to 1
do shell script "open /Volumes"
Which opens a directory in Finder without bringing every onther Finder windows to the front.
Currently I'm using :
[[NSWorkspace sharedWorkspace] openURL:fileURL];
But it has the flaw to bring every Finder windows on the top of others.
Any idea how I could achieve the same behaviour as the AppleScript ?
You can always use NSAppleScript to run applescript code in Objective-C if Cocoa doesn't provide the functionality you want.
At a guess, -[NSWorkspace openURL:] also sends the application an activate event whereas the open process does not.
I'd recommend looking into the LaunchServices API. It's what both NSWorkspace and open use behind the scenes, but gives you more control than NSWorkspace's limited API.
--
p.s. If you do have to call out to open (or any other command line tool) from ObjC, you should use Cocoa's NSTask. (AppleScript's do shell script command is just its [crappy] equivalent of NSTask.)

possible to modifer the properties of windows in Objective C?

These are windows besides those that belong to the application. For example, how could I change the title of an open application, for example, TextEdit
You could use mach_inject and mach_override to load code into the target application and then simply use the Objective-C API's to access the window.
You could also try using applescript, but no idea if or how that is done.

What programming languages have access to the WinAPI?

I'm looking to start a new programming language and for my first task I want to overlay some text on another applications window, similar to the guy in this post:
Overlay text on some else's window - HUD
Clearly from that post, this can be done in VB.NET, and extrapolating from that, I can probably safely assume that C++\C# can also do this similarly.
My question is; are there any other languages that can do the same? Can Ruby do it? :)
I'm looking for the following capabilities:
Enumerate open windows to find the one I want to overlay on top of.
Overlay text on the 3rd party apps window. (Rich text is a bonus)
Detect window bounds so I can resize the text when the user resizes the window.
Allow click-through of my created text so it doesn't interfere with the 3rd party apps functionality.
Any ideas?
If you want to use Ruby, you have two options: IronRuby and "classic Ruby".
I guess IronRuby would be the preferred option on Windows as it runs on top of .NET and has access to full Windows API through that.
If .NET is too much for your needs and you need to do something simple, then classic Ruby might be a better fit.
For classic Ruby, check out these pages:
Ruby and Microsoft Windows
Microsoft Windows Support
Beware: argument packing and unpacking is not very convenient.

How to (programmatically) change slides in a running Keynote presentation?

I'm working on a Cocoa application I'd like to use to remotely (on the same machine, from a different process) control which slide is currently displayed in a running Apple iWork '09 Keynote presentation.
How should I approach this?
The Keynote Applescript dictionary has an advance command. Using:
Tell application "Keynote"
advance
end tell
seems to do what you require.
You can either use scripting bridge or NSApplescript to run this script from within a Cocoa application.