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 » 2013-12-28T14:56:13-07:00

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: 10870
Joined: 2003-05-31T11:32:55-07:00

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

Post by magick » 2013-12-28T18:08:43-07:00

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 » 2013-12-29T00:34:45-07:00

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 » 2014-04-23T00:51:42-07:00

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: 1514
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 » 2014-04-23T02:34:46-07:00

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 » 2014-04-23T04:55:20-07:00

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 » 2018-02-01T13:04:47-07:00

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: 10978
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 » 2018-02-01T13:22:36-07:00

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