Author Topic: Seamless RDP  (Read 1620 times)

0 Members and 1 Guest are viewing this topic.

Offline Netham45

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2103
  • Rating: +213/-4
  • *explodes*
    • View Profile
Seamless RDP
« on: June 24, 2011, 01:44:49 am »
Just made this nifty program that makes RDP somewhat more seamless to the host desktop. It's really small, and pretty much complete for what I'm going to do with it.

What I'm doing to make it work is this: Set the wallpaper on the client to 77,77,77 RGB, and set that as the RDP window's transparency key.

Known bugs: 77,77,77 RGB requires 24-bit color depth


Attached is the a bin.


Doesn't relate to calcs, but it's still nifty. :P

Edit: SCREENSHOT!

EDIT2: No need for the entire project. Here's the source in entirety (Set as multi-byte in project properties):
Code: [Select]
#include <windows.h>
#include <iostream>
#include <Psapi.h>

BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam);

//Defining these obviously local vars as global so they don't get re-defined every time. Trying to speed shit up.
COLORREF getColor = RGB(0,0,0);
COLORREF transKey = RGB(77,77,77);
unsigned char alpha = 0;
const unsigned char unfocused = 180;
const unsigned char focused = 255;
HWND hwndCurrent;
TCHAR WindowTitle[MAX_PATH] = "";

int main()
{
printf("Press CTRL+C to quit\n");
while(true)
{
EnumWindows(EnumWindowsProc, 0);
Sleep(20);
}
}

BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam) {

GetWindowText(hwnd, WindowTitle, sizeof(WindowTitle));
if (strstr(WindowTitle,"- Remote Desktop Connection"))
{
if (!GetLayeredWindowAttributes(hwnd,&getColor,&alpha,NULL)) SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED);

if (GetForegroundWindow() != hwnd)
{
if (alpha != unfocused) SetLayeredWindowAttributes(hwnd,transKey,unfocused,LWA_COLORKEY + LWA_ALPHA);
}
else if (alpha != focused) SetLayeredWindowAttributes(hwnd,transKey,focused,LWA_COLORKEY + LWA_ALPHA);

}
return true;
}

Edit3:
Here's a lite version. run it once on launch. Bin attached.
Code: [Select]
#include <windows.h>
#include <iostream>
#include <Psapi.h>
BOOL CALLBACK EnumWindowsProcess(HWND hwnd, LPARAM lParam);

const COLORREF transKey = RGB(77,77,77);

int main()
{
EnumWindows(EnumWindowsProcess, 0);
}

BOOL CALLBACK EnumWindowsProcess(HWND hwnd, LPARAM lParam)
{
TCHAR WindowTitle[MAX_PATH] = "";
GetWindowText(hwnd, WindowTitle, sizeof(WindowTitle));
if (strstr(WindowTitle,"- Remote Desktop Connection") && !GetLayeredWindowAttributes(hwnd,NULL,NULL,NULL))
{
SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED);
SetLayeredWindowAttributes(hwnd,transKey,255,LWA_COLORKEY + LWA_ALPHA);
}
return true;
}

Edit4:
Performance is awful when Aero is disabled on the host.
« Last Edit: June 24, 2011, 04:11:43 am by Netham45 »
Omnimaga Admin

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
Re: Seamless RDP
« Reply #1 on: June 24, 2011, 02:00:51 am »
Nifty indeed :D

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
THEGAME
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Seamless RDP
« Reply #2 on: June 24, 2011, 07:26:32 am »
This seems pretty awesome :D It's seemless to the point it's integrated in our desktop :)