I'm building an app that needs to be able to take intermittent screen captures of a target window while running in the background. That is, it needs to be able to screenshot a specific window without user interaction.
Say for example I have Photoshop open, I'd like to capture a screenshot of my open Photoshop document every few minutes and save the capture to a file, essentially building a visual history of how the document has changed over time.
Currently I'm searching for a Unix/Mac solution but Window's suggestions are warmly welcomed.
Screencapture & Scrot both require mouse interaction to target a window & from what I've researched Imagemagick requires xwd to launch to get the id of the target window.
I'm looking for a lightweight solution (that I can bundle with my software) or ideally a solution already built into the OS to accomplish this.
Any suggestions would be very much appreciated. Cheers.
xwd utility can dump particular X11 window content. It accepts window ID to dump as an argument and can be used in non-interactive mode.
To capture the whole X-desktop on any unix/linux non-interactively you can call:
xwd -root > file
To display the dump:
xwud -in file
Related
I'm writing an application for Windows 10 to display and update text at specific locations in a Windows console window. The program is launched by a command in the console window. Upon launch, it erases the window's previous contents, then displays its output, updating as it goes, until completion. Upon exit, it should leave the displayed output in place, and a new command prompt should appear below. Launch, display, and subsequent command prompt all occur in the same console window. (Old school, I know, but that's the requirement.) The program is written in C and uses calls to the PDcurses library to control cursor placement and to output display text to the screen. The application is built with GCC/MinGW on a Windows 10 platform.
Everything works until the application exits, but then the display output disappears and the previous window contents (from before the app was launched) reappear. From what I can tell, this seems to be the default behavior for curses, possibly due to the way it handles screen buffering.
I'm looking for ways to override this behavior, but I'm not sure how to approach it. Can I direct PDcurses to write to the standard screen buffer rather than the alternate screen buffer (if that's what's going on)? If so, how? Should I copy the contents of the screen buffer before I call endwin(), then copy those contents back to the screen buffer afterward? Again, how? I'm sure this problem has already been solved, probably many times, but I haven't found any solutions that seem to apply to a C executable running in a Windows console, and I have only limited experience with PDcurses and the Windows API library. Any help would be appreciated.
The official way to do it is to set an environment variable: set PDC_RESTORE_SCREEN=0. You can combine this with set PDC_PRESERVE_SCREEN=Y to prevent PDCurses from clearing the screen at startup.
I'm trying to figure out how to prevent users of my app from snapping a screenshot of any of my app's windows. I'm mainly concerned with users automating screenshots using /usr/sbin/screencapture with cron. At first I thought there was no way to prevent it but then I discovered that there are some apps that are doing something that causes the screenshot to be all black or the color of the desktop. If I could pull that off I would be golden. I've seen other posts that touch on the subject but nothing that actually works in my situation. I'm running catalina. Any and all insights would be greatly appreciated.
Use NSWindowSharingNone of sharingType property on NSWindow
setSharingType: specifies whether the window content can be read
and/or written from another process. The default sharing type is
NSWindowSharingReadOnly, which means other processes can read the
window content (eg. for window capture) but cannot modify it. If you
set your window sharing type to NSWindowSharingNone, so that the
content cannot be captured, your window will also not be able to
participate in a number of system services, so this setting should be
used with caution. If you set your window sharing type to
NSWindowSharingReadWrite, other processes can both read and modify the
window content.
#property NSWindowSharingType sharingType API_AVAILABLE(macos(10.5));
I often have a need to grab a screen shot of something on my screen (Since I am using OSX, I use the Command+Control+Shift+4 combination, which puts the screenshot into the clipboard). This works well, and allows me to paste into MS Word and other programs.
At some point I had an issue pasting into MS One Note (still on OSX), (I was not able to, when doing Command+V, nothing would paste), which I was able to solve researching online, by changing the default image type for screenshots (I think it was from JPG to PNG, using a command in the OSX terminal).
While this worked for MS One Note, it never helped with pasting into Gmail in Safari (note that I have no issues doing this in Google Chrome).
Can anyone help with how to get pasting images from the clipboard into Gmail when using the Safari Browser? (note I am using the latest OSX and Safari versions available).
Thanks!
I have never tried using the Command+Control+Shift+4 combination but this is what I usually use and it works perfectly for me.
Task 1;
to copy the screen capture to the clipboard so you can use Command+V to paste in any program of your choice
Open your terminal
Type this "screencapture -c" in the terminal without the quotes e.g.: screencapture -c
open any program of your choice and press Command+V to paste.
Task 2;
To screen capture your computer screen and save the file directly to a png or jpg and later insert or attach it to any program of your choice
Open your terminal
type this "screencapture ./Location/filename.ext" in the terminal without the quotes e.g.: screencapture ./Desktop/myCapture.jpg This will save the capture file on the desktop with the jpg format.
to get more information about the command, type "screencapture --h" in your terminal without the quotes.
is there a way (on Windows XP+) to redirect the output of a window created by a process created with e.g. CreateProcess to a window of your own program?
I'd like to make a nicer GUI for ffplay.exe which is an open source video player. It is a command line tool, which opens a simple window in which it plays back the video. Can I "capture" this window and display the output in my own program somehow?
Thanks for any hints you can provide.
Start with this. Then set a timer. I realize that it isn't what you want, but I think that you need a kernel driver to accomplish seamless video capture. I suspect that people sell things for this. I think this (with a timer) is the best you will get in user space.
You are probably best off simply obtaining the HWND of the video output (use EnumWindows() and GetWindowThreadProcessId() to locate all of the HWNDs that belong to the ffplay.exe process your app is launching) and then re-position it within the confines of your own UI using SetWindowPos() or MoveWindow() as needed. You can't actually make the video HWND be a child of your UI's windows because of the process boundaries, but moving the video HWND around as your own UI moves around accomplishes almost the same effect.
I'd like to replace the bitmap on the logon screen of Windows 7 64-bit with one that is on disk. I have a program that periodically switches the background image of my desktop, and it has a configuration to run a program after it has changed it, which I thought I could use to also copy the same bitmap to the logon screen.
Does anyone know how to do that, or even if it is possible? If someone knows a handy command line utility to do it, that would of course be nice (but then I suspect this question should be migrated to superuser.com first), but if someone has some API commands that would help, that would be more than enough.
I found an article which detailed a dll and some resources I would have to replace. That sounds a bit too hackish for this.
I typed "change background image logon screen windows 7" into a search engine and the first link was: this which seems to show how to do it. Now you just need to figure out how to write a program to automate the steps.