digitalmars.D.learn - How to get a screenshot?
- Konstantin Kutsevalov (3/3) Sep 21 2016 Hello everyone,
- Adam D. Ruppe (4/6) Sep 21 2016 simplest might be to just call out to `shellExec("import -window
- Konstantin Kutsevalov (3/9) Sep 21 2016 Hmm, that's good idea as fast solution. Thank you Adam.
- Antonio Corbi (18/28) Sep 22 2016 Hi Konstantin,
- Antonio Corbi (7/30) Sep 22 2016 Ok, took the time to translate it to D and created a github repo
- Konstantin Kutsevalov (3/10) Sep 22 2016 Thank you Antonio, I'll try :)
- Konstantin Kutsevalov (6/11) Sep 25 2016 Hey!
- Konstantin Kutsevalov (46/46) Sep 25 2016 This is example:
Hello everyone, do anybody know how to get screenshot (for now in Linux only)? May be some library , examples?
Sep 21 2016
On Wednesday, 21 September 2016 at 16:33:58 UTC, Konstantin Kutsevalov wrote:do anybody know how to get screenshot (for now in Linux only)? May be some library , examples?simplest might be to just call out to `shellExec("import -window root filename.png");` and it will write the file.
Sep 21 2016
On Wednesday, 21 September 2016 at 16:36:32 UTC, Adam D. Ruppe wrote:On Wednesday, 21 September 2016 at 16:33:58 UTC, Konstantin Kutsevalov wrote:Hmm, that's good idea as fast solution. Thank you Adam.do anybody know how to get screenshot (for now in Linux only)? May be some library , examples?simplest might be to just call out to `shellExec("import -window root filename.png");` and it will write the file.
Sep 21 2016
On Thursday, 22 September 2016 at 02:21:16 UTC, Konstantin Kutsevalov wrote:On Wednesday, 21 September 2016 at 16:36:32 UTC, Adam D. Ruppe wrote:Hi Konstantin, I've got a simple example in Vala language but it's very easy to rewrite it in D thank's to GtkD (and also thanks to Mike Wey for his work in GtkD!): // compile: valac --pkg gtk+-3.0 --pkg gdk-3.0 screenshot.vala int main (string[] args) { Gtk.init (ref args); int width, height; Gdk.Window win = Gdk.get_default_root_window(); width = win.get_width(); height = win.get_height(); Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, height); screenshot.save("screenshot.png","png"); return 0; }On Wednesday, 21 September 2016 at 16:33:58 UTC, Konstantin Kutsevalov wrote:Hmm, that's good idea as fast solution. Thank you Adam.do anybody know how to get screenshot (for now in Linux only)? May be some library , examples?simplest might be to just call out to `shellExec("import -window root filename.png");` and it will write the file.
Sep 22 2016
On Thursday, 22 September 2016 at 07:50:07 UTC, Antonio Corbi wrote:On Thursday, 22 September 2016 at 02:21:16 UTC, Konstantin Kutsevalov wrote:Ok, took the time to translate it to D and created a github repo to clone. You can download and try it from: https://github.com/antoniocorbibellot/dsshot Hope It helps you. AntonioOn Wednesday, 21 September 2016 at 16:36:32 UTC, Adam D. Ruppe wrote:Hi Konstantin, I've got a simple example in Vala language but it's very easy to rewrite it in D thank's to GtkD (and also thanks to Mike Wey for his work in GtkD!): // compile: valac --pkg gtk+-3.0 --pkg gdk-3.0 screenshot.vala int main (string[] args) { Gtk.init (ref args); int width, height; Gdk.Window win = Gdk.get_default_root_window(); width = win.get_width(); height = win.get_height(); Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, height); screenshot.save("screenshot.png","png"); return 0; }[...]Hmm, that's good idea as fast solution. Thank you Adam.
Sep 22 2016
On Thursday, 22 September 2016 at 16:09:23 UTC, Antonio Corbi wrote:On Thursday, 22 September 2016 at 07:50:07 UTC, Antonio Corbi wrote: Ok, took the time to translate it to D and created a github repo to clone. You can download and try it from: https://github.com/antoniocorbibellot/dsshot Hope It helps you. AntonioThank you Antonio, I'll try :)
Sep 22 2016
On Thursday, 22 September 2016 at 16:09:23 UTC, Antonio Corbi wrote:Ok, took the time to translate it to D and created a github repo to clone. You can download and try it from: https://github.com/antoniocorbibellot/dsshot Hope It helps you. AntonioHey! It really works! https://github.com/antoniocorbibellot/dsshot/blob/master/source/app.d Thank you!
Sep 25 2016
This is example: ``` import std.stdio; import gtk.Main; import gtk.MainWindow; import gtk.VBox, gtk.Label, gtk.Button; import gdk.Gdk; import gdk.Window; import gdk.Pixbuf; private import stdlib = core.stdc.stdlib : exit; int main(string[] args) { Main.init(args); new ApMainWindow(); Main.run(); return 0; } class ApMainWindow : MainWindow { this() { super("Screen Capture"); setTitle("Screen Capture Example"); setDefaultSize(250, 120); VBox box = new VBox(false, 2); box.add(new Button("ScreenShot", &screenSave)); box.add(new Button("Exit", &exitProg)); add(box); showAll(); } void screenSave(Button button) { Window win = Window.getDefaultRootWindow(); int width = win.getWidth; int height = win.getHeight; Pixbuf screenshot = getFromWindow(win, 0, 0, width, height); screenshot.savev("screenshot.png", "png", null, null); } void exitProg(Button button) { stdlib.exit(0); } } ```
Sep 25 2016