c# - Screenshot non-active external application -


i need take screenshot of non-active external application, example, teamspeak or skype.

i have searched , didn't find much, know not possible screenshot minimised application, think should possible screenshot non-active application.

ps : want screenshot application, if application on top of 1 want, problem?

i have no code right now, have found user32 api can want forgot name..

thanks help.

the api you're after printwindow:

void example() {     intptr hwnd = findwindow(null, "example.txt - notepad2");     capturewindow(hwnd); }  [dllimport("user32.dll", setlasterror = true)] [return: marshalas(unmanagedtype.bool)] static extern bool printwindow(intptr hwnd, intptr hdc, uint nflags);  [dllimport("user32.dll")] static extern bool getwindowrect(intptr handle, ref rectangle rect);  [dllimport("user32.dll", setlasterror = true)] static extern intptr findwindow(string lpclassname, string lpwindowname);  public void capturewindow(intptr handle) {     // size of window capture     rectangle rect = new rectangle();     getwindowrect(handle, ref rect);      // getwindowrect returns top/left , bottom/right, fix     rect.width = rect.width - rect.x;     rect.height = rect.height - rect.y;      // create bitmap draw capture     using (bitmap bitmap = new bitmap(rect.width, rect.height))     {         // use printwindow draw window our bitmap         using (graphics g = graphics.fromimage(bitmap))         {             intptr hdc = g.gethdc();             if (!printwindow(handle, hdc, 0))             {                 int error = marshal.getlastwin32error();                 var exception = new system.componentmodel.win32exception(error);                 debug.writeline("error: " + error + ": " + exception.message);                 // todo: throw exception?             }             g.releasehdc(hdc);         }          // save .png demo         bitmap.save("example.png");     } } 

Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -