Screenshots in Mac OS X

Kevin Walzer kw at codebykevin.com
Tue Oct 22 21:06:25 EDT 2013


On 10/22/13 8:19 PM, Pratik Mehta wrote:
> Hey Kevin,
>
> Thanks for reverting.
>
> I know about the "screencapture" function and the parameters available.
>
> But, how would I take the user input, as in, that is just command-line, as soon as I execute the program, it will take whatever kind of parameter is passed under screencapture.
>
> I want that, in the same program, if the user presses Shift+Command+3, whole screenshot should be taken.
>
> When, Shift + Command + 4 is pressed, a particular frame should be displayed to select the area / region.
>
> Also, I want to create my own command : Shift + Command + 5 ==> this is specially for web browser, whenever I press this key on any of the web-page, the whole web page should be grabbed along with its snapshot, and snapshot's filename should be web-page's url which I am currently on.
>
> Also, this process should be executing at the backend, so that, whenever these keys are pressed, it overrides the system's functionality and uses mine.
>

There are no simple answers to these questions.

With Tkinter, it's possible to code a basic UI and bind combinations of 
specific keys to trigger specific callbacks, which can fire specific 
sequences of arguments to the screencapture CLI tool. That's the quick 
and dirty way. I'm not going to write this code for you. Look at 
TkDocs.com and effbot's site for an introduction to Tkinter.

If you are not looking for a GUI app to do this, but some sort of 
system-level daemon, that requires a lower level of coding. You'll need 
to look at such system frameworks as CoreGraphics and Cocoa to find the 
API's you need. PyObjC (Python binding to Cocoa) can probably be helpful 
here. Frankly, I'm not sure Python is the best tool here, but if you go 
this route, you want a Python API that hews as closely to the 
system-level calls as possible, and PyObjC will likely be your best path 
here.

--Kevin

-- 
Kevin Walzer
Code by Kevin/Mobile Code by Kevin
http://www.codebykevin.com
http://www.wtmobilesoftware.com



More information about the Python-list mailing list