Need to simulate screen-shooting a window

Hi there
I need to simulate a screenshot of a window of Safari. Basically: CMD+SHIFT+4+SPACE+click.
I have a script that works for a screenshot of the entire screen, but since my screen is only 1200x800 I need to take an SS of the window while it's resized and a part of it is not visible. If I do it manually it works like a charm, but I need a script because I need to do it a few hundred times.
I've tried using cliclick but I ran into some trouble and I'm stuck. The site loads, the window gets selected, the screen goes gray in anticipation of a click, but no clicking happens. Anyway, here's my script, hope you can help me.
p.s. I'm not sure if my CODE tags will wrap my code in code tags, I'm a bit daft today
[CODE]
set myURL to "X"
repeat with myPage from 1 to 325
          tell application "Safari"
                         set the URL of the front document to (myURL & myPage)
       activate
                         do shell script "/Users/macjohn/Desktop/cliclick d:400,100"
          end tell
  delay 5
          set myPath to ((POSIX path of (path to desktop)) & "screenshots/" & myPage & ".jpg") as string
          do shell script "screencapture -W " & quoted form of myPath
end repeat
[/CODE]

Hello
Here's a simple command line utility written in C to caputure specified window's image and save it as png. I first tried to do this in rubycocoa for convenience but in vain because the used function CGWindowListCreateImageFromArray() always returns nil in rubycocoa for some reason. So here's C version.
# Recipe.
A) To compile and test the C programme.
A1) Copy the code listed below as main.c into new document of text editor (e.g. TextEdit) and save it as plain text named "main.c" on desktop.
A2) In Terminal.app, run the following commands (type each line followed by return):
cd ~/Desktop
gcc -framework ApplicationServices -o windowcapture main.c
and it will create an executable file named "windowcapture" on desktop.
A3) For brief test, first in Ssfari, have a window open and then in Terminal.app, type the following satements (each followed by return):
wid=$(osascript -e 'tell application "Safari" to get id of window 1')
./windowcapture $wid out.png
This will capture the front window of Safari and save it as out.png on desktop.
B) To create an AppleScript wrapper to call this utility.
B1) Create a new AppleScript script with the following contents and save it as a script bundle or an application bundle:
tell application "Safari" to set wid to window 1's id
set p to (path to resource "windowcapture")'s POSIX path
do shell script "cmd=" & p's quoted form & "; wid=" & wid & "
out=~/Desktop/$(date +'%F %H.%M.%S.png')
\"$cmd\" \"$wid\" \"$out\""
B2) Show package contents (via contextual menu) of the saved bundle and put the executable file "windowcapture" loose in its Contents/Resources directory. Now you can run the script bundle or the application bundle to capture the front window of Safari and save it as a time-stamped png file on desktop.
# Notes.
• You need to have Developer Tools (Xcode and its command line tools) installed to build the programme.
• Tested under 10.6.8 but no warranties of any kind.
• This is free software you may use and modify as you like.
# File
main.c
    file
        main.c
    function
        capture image from window specified by window id (CGWindowID) and save it as png file.
    compile
        gcc -framework ApplicationServices -o windowcapture main.c
    usage e.g.
        ./windowcapture 251 outfile.png
#include <ApplicationServices/ApplicationServices.h>
#include <libgen.h>    // basename
int
main (int argc, char * argv[])
    if ( argc != 3 )
        fprintf(stderr, "Usage: %s <window ID> <outfile>\n", basename(argv[0]));
        return 1;
    CGWindowID wid = (CGWindowID) atoi(argv[1]);
    CFStringRef outfile = CFStringCreateWithCString(kCFAllocatorDefault, argv[2], kCFStringEncodingUTF8);
    CFURLRef url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, outfile, kCFURLPOSIXPathStyle, false);
    CFRelease(outfile);
    CGWindowID wids[] = { wid };
    CFArrayRef widarray = CFArrayCreate(kCFAllocatorDefault, (const void **)wids, 1, NULL);
    CGImageRef img = CGWindowListCreateImageFromArray(CGRectNull, widarray, kCGWindowImageDefault);
    CFRelease(widarray);
    if ( !img )
        fprintf(stderr, "Failed to create image from window id: %d\n", (int) wid);
        return 1;
    CGImageDestinationRef idst = CGImageDestinationCreateWithURL(url, CFSTR("public.png"), (size_t) 1, NULL);
    CFRelease(url);
    CGImageDestinationAddImage(idst, img, NULL);
    bool b = CGImageDestinationFinalize(idst);
    CFRelease(idst);
    return b ? 0 : 1;
Hope this may help,
H

Similar Messages

  • Bought a new monitor.. wide screen 23"... Firefox is not filling the full window. IE works fine but I prefer Firefox. What do I need to do to fill entire window, not just the way it was with the old monitor?

    Bought a new monitor.. wide screen 23"... Firefox is not filling the full window. IE works fine but I prefer Firefox. What do I need to do to fill entire window, not just the way it was with the old monitor? edit

    Most pages are defined to be a certain size, regardless of how large or small your monitor is. You can use Firefox's zoom feature (View menu) to enlarge the text and images (or just the text, if you prefer) on a page.
    In addition to making individual site adjustments, there are some add-ons that will default every site to a higher zoom level. For example, check out:
    * [https://addons.mozilla.org/en-US/firefox/addon/6965/ Default FullZoom Level]
    * [https://addons.mozilla.org/en-US/firefox/addon/2592/ NoSquint]
    Does that help?

  • What does OS10.5 use to screen share with Windows and Linux ?

    i have found screen sharing Mac to Mac is EASY
    but lets say i want to see the screen on my Windows XP computer
    OR my Linux Ubuntu or CentOS desktop Computers
    what do you reccomend and is there anything else i need to know
    thanks in advance

    First, I trust you have the firewalls open for the needed port(s), e.g. 5900, 5901, etc.
    Then, from what I've played with, the Leopard Screen Sharing app only connects to VNC servers that are configured for VNC Authentication (or no authentication) and that are using only Protocol 3.3.
    Depending upon the version and implementation of the VNC Server, you might have to pass startup commands like this:
    vncserver --SecurityTypes=VncAuth --Protocol3.3
    (and of course, have a VncAuth password set, e.g. with vncpasswd.)
    I'm not sure how, or if, these settings can be configured in Vino (the 'Remote Desktop' option in Gnome,) but if starting vncserver from an entry in /etc/sysconfig/vncservers, it might be like this:
    VNCSERVERS="1:username"
    VNCSERVERARGS[1]="-geometry 1420x790 -depth 24 --SecurityTypes=VncAuth --Protocol3.3"
    (and again, you'd need a vncpasswd set for the username starting the VNC server.)
    Now, only Vino does the automatic Bonjour RFB advertisement, which makes the VNC server show up in Finder (without which, you'll need to manually start Screen Sharing.)
    However, you can create the Bonjour advertisement in Linux by creating a file called /etc/avahi/service/rfb.service
    and filling it with the following text:
    <?xml version="1.0" standalone='no'?>
    <!DOCTYPE service-group SYSTEM "avahi-service.dtd">
    <service-group>
    <name replace-wildcards="yes">%h VNC Server</name>
    <service>
    <type>rfb.tcp</type>
    <port>5901</port>
    </service>
    </service-group>
    and then, doing a:
    sudo /etc/init.d/avahi-daemon restart
    In the Windows VNC Server (at least the one by RealVNC), there is an advanced button (or a Legacy tab) where you can find the option to set "Protocol 3.3" to true. And, on the security tab, make sure you have it set to "VNC Password Authentication" (configured with a password set) and NOT to "NT Logon Authentication". Unfortunately, I don't know how to set a Windows machine to make the necessary RFB service Bonjour advertisement to get it to show up in Finder. However, if you got a Bonjour/Rendezvous Proxy (e.g. http://ileech.sourceforge.net/index.php?content=RendezvousProxy-Download , for the Mac, I like the Java version, the native one is PPC.) and ran it on your Mac (or the Windows machine), you could simulate the adverstisment -- just create an proxy entry for a rfb.tcp service, pointing to port 5900 on the IP address of your Windows box.
    Finally, even once you connect to a 3rd party VNC server with the Screen Sharing app, every so often you'll get a 'no encryption' warning -- of course, because Apple doesn't talk RealVNC's encryption and vice-versa so it connects without encryption.
    Message was edited by: J. Everett

  • Blue Screen Error for Windows 7 Home Basic 64 Bit

    I have a Sony Vaio E Series with WINDOWS 7 64bit home basic preinstalled. It worked perfectly fine for 2 yrs until last month, I needed to replace the hard drive due to bad sectors. Now, after a month of replacing my hard drive fresh from
    Sony Center, I decided to do a dual boot (install another OS - Windows 8.1 pro) on a separate partition. Everything is averagely fine. But 2 nights ago, I encounter a blue screen error for WIN 7 (my pre installed one). It happened the second time, so I started
    it in safe mode and did a system restore. I don't know if it will prevent future occurence of blue screen, but to make sure, I reinstall my factory default drivers using Vaio CARE... Pls help.
    PS: I have not encountered BLUE SCREEN error in Windows 8.1 yet. Is it OS specific? Here's the error the second time, it happened on my Windows 7:
    Blue screen error for Windows 7 home basic
    Problem signature:
      Problem Event Name:    BlueScreen
      OS Version:    6.1.7601.2.1.0.768.2
      Locale ID:    13321
    Additional information about the problem:
      BCCode:    1000007e
      BCP1:    FFFFFFFFC0000005
      BCP2:    FFFFF80002EE6B80
      BCP3:    FFFFF880035F4DC8
      BCP4:    FFFFF880035F4620
      OS Version:    6_1_7601
      Service Pack:    1_0
      Product:    768_1
    Files that help describe the problem:
      C:\Windows\Minidump\083014-31964-01.dmp
      C:\Users\GARIBALDI\AppData\Local\Temp\WER-76456-0.sysdata.xml
    Read our privacy statement online:
      http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409
    If the online privacy statement is not available, please read our privacy statement offline:
      C:\Windows\system32\en-US\erofflps.txt

    Hi Garibaldi11,
    If you are not equipped to debug this problem, you should use some basic troubleshooting techniques.
    •Make sure you have enough disk space.
    •If a driver is identified in the bug check message, disable the driver or check with the manufacturer for driver updates.
    •Try changing video adapters.
    •Check with your hardware vendor for any BIOS updates.
    •Disable BIOS memory options such as caching or shadowing.
    Bug Check 0x7E: SYSTEM_THREAD_EXCEPTION_NOT_HANDLED
    http://msdn.microsoft.com/en-us/library/windows/hardware/ff559239(v=vs.85).aspx
    Bug check 0x1000007E has the same meaning and parameters as bug check 0x7E
    Alex Zhao
    TechNet Community Support

  • I5 17''MBP  gets blue screen during install windows 7 32 bit

    Hello all:
    I heard that quite many people get classic windows' "blue screen" during using windows , whatever Windows XP, Vista or 7. But now i face the "blue screen" during install Windows 7, which means I even can not complete installation.
    I bought my Macbook Pro i5 17'' one month ago, and I'm trying to install Windows 7 but I face the problem during the installation. After finishing first 4 steps the computer would restart and start to "finish installation", but at this time it gets "blue screen" and shows "error: 0x0000009c" and stuck there. I have to shut down the turn off button and interrupt the installation.
    I don't know if there's any one else face this unlucky situation. I searched on the net and it says the problem could be from memory, graphic card (too new), or even overlocking the cpu,whatever it must be the problem of hardware. I thought it might be the problem of compatible.
    If anyone knows how to deal with this problem??!! I do need to use some software under Windows system!

    It is good to see that it is indeed a USB2.
    The support software on the USB is used in the Pre-boot environment setup and provides drivers for Apple specific hardware, GPU, BT, Mouse, etc. You can verify that by looking at the USB contents. The DVD contains generic drivers when hardware is not recognized as defaults to use. Apple does enough 'secret sauce' to make them different. The following does not explicitly state the USB2 need when using the DVD Installer and mentions W8 (not W7).
    From Boot Camp: Creating an ISO image from a Windows installation DVD - Apple Support
    Insert a blank USB 2 flash drive that is a least 16GB in size into a USB port on the computer. Boot Camp Assistant uses this drive to store the Windows 8 install media and support drivers during installation of Windows.
    Note: This flash drive needs to be formatted for the FAT32 file system and must use the Master Boot Record partitioning scheme. Use Disk Utility to check the format of the flash drive before proceeding, and partition or erase the flash drive if necessary.
    I suspect the GPU is not getting the correct driver and the Installer fails. The Generic VGA should work. From the OS X side, can you see files in your BC volume? If yes, can you look for logs in the BC volume at the following locations.
    ./Windows/Inf/setupapi.dev.log
    ./Windows/Inf/setupapi.offline.log
    ./Windows/Inf/setupapi.setup.log
    ./Windows/Logs/SetupCleanupTask/setupact.log
    ./Windows/Logs/SetupCleanupTask/setuperr.log
    ./Windows/Panther/FastCleanup/setupact.log
    ./Windows/Panther/FastCleanup/setuperr.log
    ./Windows/Panther/setupact.log
    ./Windows/Panther/setuperr.log
    ./Windows/Panther/UnattendGC/setupact.log
    ./Windows/Panther/UnattendGC/setuperr.log
    ./Windows/setupact.log
    ./Windows/setuperr.log
    ./Windows/System32/Sysprep/Panther/IE/setupact.log
    ./Windows/System32/Sysprep/Panther/IE/setuperr.log

  • Screen on small window

    Hi All,
    I an requirement when I execute an 'Z' transaction it need to appear in small window. I have created the screen as Normal screen and made size small , But it is not working. Please Suggest.
    Thanks.
    Jeet.

    Hi Madhu,
    If M using like this it is working according to my requirement.
    SELECTION-SCREEN BEGIN OF SCREEN 9250 AS WINDOW TITLE text-002.
    SELECTION-SCREEN BEGIN OF BLOCK bl1 WITH FRAME TITLE text-001.
    *SELECT-OPTIONS   mtart FOR mara-mtart.
    SELECTION-SCREEN END OF BLOCK bl1.
    SELECTION-SCREEN END OF SCREEN 9250.
    CALL SELECTION-SCREEN '9250' STARTING AT 10 10.
    MODULE CALL_TRANSACTION INPUT.
    case ok_code.
    when 'CRET'.
      call TRANSACTION 'ZH_MSAL' AND SKIP FIRST SCREEN.
    endcase.
    ENDMODULE.
    when I execute this One the standard execute check save and cancel button should not come. I need to add Push Button according to my requirement.
    Can You Help.?
    Thanks and Regards.
    Jeet.

  • I was installing the new EFI software update on my macbook pro and I became stuck on the grey screen with the window that said "installing 2 items", its been on the same screen for 2 1/2 hours. does anyone know what I can do?

    As the title says.
    I was installing the new EFI software update on my macbook pro and I became stuck on the grey screen with the window that said "installing 2 items", its been on the same screen for 2 1/2 hours. does anyone know what I can do?
    I don't want to restart it because im scared that something might go wrong.
    operating lion

    LimitLess- wrote:
    Hi,
    I had the power supply connected when I attempted it previously but even so my problem occurred. My rom is different and so I still need to update it.
    Thanks
    I wanted to mark your answer helpful too but I didn't know that I could only put it for 2 answers. Sorry
    That was good advice by G-N and s/he is correct about it. Unfortunately, ASC allows only 2 "helpful" and 1 "correct" marks per thread.

  • Screen Capture on Windows

    Hi
    I need to capture some on screen video for a project i am working on. Unfortunately the site I am capturing- CMT.com's broadband LOADED runs Windows' DRM and does not work on a Mac. I have tried using SnagIt but it can only captture at 15fps and is an awkard application compared to SnapzPro. Can anyone recommend a way that i can do the screen capture on Windows?

    http://www.capture-screen.com/

  • Do you need a green screen to make a background transparent?

    I am going to be shooting a video of a speaker tomorrow and would like to know if i need a green screen to make a background translucent in imovie?

    Yes

  • Satellite C55-A5182 - Screen flickering after windows 10 upgrade.

    Satellite C55-A5182: screen flickers after windows 10 upgrade....help!!!

    Hi there ,  Thank you for visiting the HP Support Forums and Welcome! This is a great site to get answers and ask questions. I read your post on the HP Support Forums and I understand that you are having an issue with the Touchscreen on your HP Notebook - 15-ac020nr. You had mentioned that since your Windows 10 Upgrade, it no longer works.  Have you tried doing all updates (Windows, HP Support Assistant, BIOS)?Have you tried restarting the Notebook a couple of times?Have you tried to run the Windows Troubleshooter? Here is a link to the HP Support Assistant. Just download and run the application and it will help with the software and drivers on your system that need updating for Windows 10. The HP Support Assistant will also help find a proper driver for you to use.  Updated Windows 10 drivers will become available on the HP Drivers and Downloads Page for your product. They will be released as they become available to HP. I did find a troubleshooting document for you called Touch Screen Issues. Although it does say it is for Windows 8, it will still work for Windows 10.  Please follow the provided troubleshooting steps and re-post with the results.  Have a great day!

  • Cannot Adjust Screen Brightness after Windows 8.1 Update

    Cannot Adjust Screen Brightness after Windows 8.1 Update....i am using sony vaio laptop....i recently updated windows 8 to 8.1

    Hi:
    Most likely you need to install the graphics driver for W8.1 from your PC's support and driver page.

  • My MacBook has crashed and does not get started.Bright screen with a window showing ? Comes up

    My MacBook Air is less than a year old.Yesterday it crashed and when I switch it on,bright screen appears with window with? Flashing

    Make a "Genius" appointment at an Apple Store, or go to another authorized service provider.
    Back up all data on the internal drive(s) before you hand over your computer to anyone. There are ways to back up a computer that isn't fully functional — ask if you need guidance.
    If privacy is a concern, erase the data partition(s) with the option to write zeros* (do this only if you have at least two complete, independent backups, and you know how to restore to an empty drive from any of them.) Don’t erase the recovery partition, if present.
    Keeping your confidential data secure during hardware repair
    *An SSD doesn't need to be zeroed.

  • Need links to open in different window

    Please forgive my outrageous ignorance with respect to
    webpage design/development and especially Dreamweaver CS3. I
    created a very basic website in Microsoft Office Publisher 2003 and
    I have it up and running (www.ftembroidery.com). It is my very
    first attempt at making a website.
    The purpose of this page is not so much to make sales over
    the internet, although some of our repeat customers do contact us
    and order via the internet. The purpose of our page is to be able
    to talk with our customers on the telelphone and guide them to
    various products in the catalogs we have linked. Basically we're
    handing them a stack of "electronic" catalogs from a handfull of
    our suppliers so they can decide what to purchase.
    I would like these "catalogs" (links) to return to OUR
    website if the viewer closes the page. Currently, they do not. If
    you close the window of one of the catalogs, you shut down
    everything. I believe that means the catalog links need to open in
    a new window. If I am correct in that belief, how do I
    change/correct my webpage to do that?
    Once I have done that, I will have time to learn more about
    webpage design/development and how to use the Dreamweaver CS3 that
    I just purchased.
    Thanks in advance for your help, remembering please to be
    very clear and specific because of my lack of knowledge and
    experience.
    Nick

    Check out this site - WWW.ITKONG.COM.
    Focused solely on the community of IT specialists, web
    developers, technological experts, companies and individuals alike.
    Currently we are up and running in our beta phase, taking
    care of final minor bugs tightening loose screws and slowly getting
    the word out about our existence.
    I hope it is of some help and we welcome your feedback.
    Team ITkong

  • Do I need to format my iPod on Windows to use it as a hard drive on a PC?

    I use my iPod on a MacBook with my iTunes library, but now want to ALSO use it as a simple hard drive on my PC for files transfer.
    In the Windows explorer, I am told that it is not formatted and I am proposed to format it, which would erase all data on it.
    Do I need to format my iPod on Windows to use it as a hard drive on a PC?
    (I don not have iTunes installed on that PC currently)
    And if I have to format it, will all my music be gone, but can I simply then synch it again on my MacBook with my iTunes library?
    Thanks a lot in advance.

    To use the iPod Classic on both the Mac and Windows PC, you need to format it in FAT32 filesystem structure, which both OS can recognise.
    Yes, formatting it in FAT32, using iTunes, will erase all music and data in your iPod, but that is no problem if you have all the music in your Mac iTunes library.
    So to do this,
    Install the Latest iTunes in your windows PC, run itunes and check that all is in order (you can navigate, play some sample songs in itunes.)
    Connect your iPod to the Windows PC, USB 2.0 port (please dont use USB hub with iPod Classic, -my bad personal experience, freezing itunes and windows)
    iTunes will pop a windows asking you to reformat it in FAT32 and Restore
    Click ok. (HERE there maybe some problem, if your iPod hardisk is not in tiptop condition)
    When Restore is complete, eject the iPod
    Connect it to your Mac and sync iTunes library.
    If you want to use the iPod in Windows as an external hd, you have to set it in Disk Mode.  first then Windows will recognise it as a portable HD.
    Good luck! on this big undertaking.

  • Satellite A500-19x - Suddenly blue screen appears in Windows 7

    I have satellite a500-19x,
    There are one problem every time and every days when i working.
    Suddenly the windows stopped for several moments then blue screen and restart windows .

    hi,
    if you want to update your Bios, go to the Toshiba driver page and choose the appropriate Bios version for you model. Download it and run. Don't forget to close all the running programs, disable Antivirus, Firewall before running it. Then, you will be asked to restart the computer. Pray that Bios process would occur properly otherwise you will have blank screen on startup. In this case, you will have to contact TASP (Toshiba authorized service provider).
    To be honestly, I don't recommend you to flash the Bios, in your case it doesn't help your in audio crackling and BSOD. I updated my BIos but it didn't fix the problem. I think, it's graphic driver issue.You can go to the nvidia.com and download a new graphic card driver released recently. Install it and check. I also had audio crackling and the system freezing that gone after updating that driver. Note, that driver isn't pretested by Toshiba (not modified for overheating protection, anyway the users say this in the forum) but install it at my own risk and still have no problems.
    greets

Maybe you are looking for

  • Subcontracting P.O with Free Items Ticked.

    Hi Gurus, I have a requirement wherein we want that P.O to be sent to the subcontractor should have the Free Items checked automatically in P.O. We would be creating P.R's through an MPS run, and convert it into P.O through RM06BB20 Kindly note that

  • Problems with parameterized mapping in BPM

    Hi I am using an RFC lookup in a message mapping. I have declared the parameters/bindings in Message Mapping and Operations Mapping, but when I use the Operations Mapping in a transformation step in my BPM, I am asked for an "import" value. There are

  • Select-options and parameters

    hi, In How many ways we can define select-options and parameters.

  • RS480M2 - No boot after replacing RAM

    A pair of RAM sticks originally installed in the slot 1 and 2 were DDR400 2x256MB with 3-3-3-8. Then before installing Vistax86 a new pair being DDR400 2x512MB 2-2-2-6 were installed in the slot 3 and 4. Everything appeared working fine except cpu-z

  • Moved my laptop and now I can't connect to the router

    I'm a novice at this - but that didn't stop me from setting up a wireless network  - it was very easy, everything went fine and was working great for months.  I took the laptop out of the house and used it at another location.  When I brought the lap