How to create a screenshot of the currently active window ?

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
aaron_caffrey
Posts: 2
Joined: 2013-12-28T14:51:47-07:00
Authentication code: 6789

How to create a screenshot of the currently active window ?

Post by aaron_caffrey »

Hello everyone,

In imagemagick there is a command ( import -frame -window ) where I can specify which is the active window and create a screenshot, but I am unable to find any article about that for magick++.

Can you help me ?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: How to create a screenshot of the currently active windo

Post by magick »

Use the x: coder with a X window ID. For example, xwininfo reports a windows ID of 0x240003d. Use read("x: 0x240003d") in Magick++. To test, try
  • convert x:0x240003d x:
aaron_caffrey
Posts: 2
Joined: 2013-12-28T14:51:47-07:00
Authentication code: 6789

Re: How to create a screenshot of the currently active windo

Post by aaron_caffrey »

magick wrote:Use the x: coder with a X window ID. For example, xwininfo reports a windows ID of 0x240003d. Use read("x: 0x240003d") in Magick++. To test, try
  • convert x:0x240003d x:
Awesome, thank you so much ! Happy New Year :)
Dzhoko
Posts: 7
Joined: 2014-03-11T02:20:03-07:00
Authentication code: 6789

Re: How to create a screenshot of the currently active windo

Post by Dzhoko »

How can I create a screenshot of active window in windows 7 ? I can't find a "x window Id", xwininfo is just for Linux.
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: How to create a screenshot of the currently active windo

Post by dlemstra »

Under Windows you need should use the following file name: 'screenshot:' (This requires the latest version of ImageMagick). And if your computer has multiple monitors you can specify an index 'screenshot:[1]'.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
Dzhoko
Posts: 7
Joined: 2014-03-11T02:20:03-07:00
Authentication code: 6789

Re: How to create a screenshot of the currently active windo

Post by Dzhoko »

I have tried,

...
Image screen("screenshot:"); It's work.
...


but if I save the screen
....
screen.write("screen.jpg"); I become a error
...

how can i save a screenshot?
alpha_lsdljf
Posts: 1
Joined: 2018-02-01T12:59:13-07:00
Authentication code: 1152

Re: How to create a screenshot of the currently active window ?

Post by alpha_lsdljf »

Hi all

I am also trying to use `imagemagick` to capture the primary screen on my multi-monitor setup in _Windows10_

Did anybody try the

`convert 'screenshot:[1]` option that @dlemstra mentioned above?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to create a screenshot of the currently active window ?

Post by snibgo »

Yes, on Windows 8.1. It works. For my laptop, with a second screen, to capture them both:

Code: Select all

convert screenshot:[0] main.png

Code: Select all

convert screenshot:[1] second.png
snibgo's IM pages: im.snibgo.com
Post Reply