Jump to content

tko13

Members
  • Posts

    2
  • Joined

  • Last visited

tko13's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Didn't figure out why this behavior occurs, but I did come up with a workaround and wanted to post it in case anyone else runs into this in the future. I am now using TSCON.EXE to convert my disconnected rdp session into the console session: tscon.exe 2 /dest:Console. I set the script up to trigger this command after several cycles of detecting a black bitmap through the DC. This way, the script doesn't subvert the normal rdp client behavior of auto-reconnect on a short network interruption. If this is triggered inadvertently in the future, I may go a step further and have it verify that the rdp session is disconnected before converting the session.
  2. Hi all, I created a script to take periodic screen shots of an inactive background window by using the PrintWindow command (via some code I found elsewhere on the forum). I run this script on my Windows 7 PC at home, but I am usually connected to it through Remote Desktop while at work or even while at home through my laptop. The script works well when I am connected, but the moment I disconnect (e.g. when I am headed home from the office) PrintWindow begins capturing an entirely black bitmap. I know the background app continues processing while in a disconnected state (just as the script does), so maybe it has something to do with the way the desktop window manager works? I've tried having the script reinitialize the DC/bitmap in the while loop upon detection of the black bitmap, but it didn't have any effect so I took it back out. I've enclosed the relevant snippets of code below. Normally if I didn't connect via remote desktop at all, the session would be just be a normal local PC session (console session) and would run without issue. Perhaps if there were a way my script could convert the disconnected session into a console session that would do the trick too, but I have no idea where to begin with that. Any help would be greatly appreciated. Thanks! #include <GDIPlus.au3> #include <WinAPI.au3> #include <ScreenCapture.au3> $loopcounter = 0 $hWnd = WinGetHandle("TestWindow") ;Initialize the DC/bitmap _GDIPlus_Startup() $iWidth = _WinAPI_GetWindowWidth($hWnd) $iHeight = _WinAPI_GetWindowHeight($hWnd) $hDDC = _WinAPI_GetDC($hWnd) $hCDC = _WinAPI_CreateCompatibleDC($hDDC) $hBMP = _WinAPI_CreateCompatibleBitmap($hDDC, $iWidth, $iHeight) _WinAPI_SelectObject($hCDC, $hBMP) While 1 $loopcounter+=1 DllCall("User32.dll", "int", "PrintWindow", "hwnd", $hWnd, "hwnd", $hCDC, "int", 0) _ScreenCapture_SaveImage("c:\testimage" & $loopcounter & ".jpg", $hBMP) Sleep(10000) WEnd _WinAPI_ReleaseDC($hWnd, $hDDC) _WinAPI_DeleteDC($hCDC) _WinAPI_DeleteObject($hBMP) _GDIPlus_ShutDown ()
×
×
  • Create New...