#include <stdio.h>
#include <windows.h>
#include <Winuser.h>
#include <wincon.h>
#define WS_EX_LAYERED 0x00080000
BOOL WINAPI SetLayeredWindowAttributes(HWND hwnd,COLORREF crKey,BYTE bAlpha,DWORD dwFlags);
HWND WINAPI GetConsoleWindow(void);
LONGGetWindowLong(HWND hWnd,int nlndex);
int main(int args, char *argv[])
{
HWND handler = GetConsoleWindow();
HINSTANCE hInst = LoadLibrary("User32.DLL");
int temp = 0;
int a[4] = {255,190,2};
if (args > 4)
{
printf("参数错误!只能有三个参数!");
return -1;
}
for(temp =0; temp < args-1; temp++)
{
a[temp]=atoi(argv[temp+1]);
}
if(hInst)
{
typedef BOOL (WINAPI *ShowLayer)(HWND,COLORREF,BYTE,DWORD);
ShowLayer fun = NULL;
fun = (ShowLayer)GetProcAddress(hInst, "SetLayeredWindowAttributes");
SetWindowLong(handler, GWL_EXSTYLE, GetWindowLong(handler, GWL_EXSTYLE)|WS_EX_LAYERED);
if (fun)
fun(handler, (COLORREF)(a[0]),(BYTE)(a[1]), (DWORD)(a[2]));
FreeLibrary(hInst);
}
return 0;
}
命令行透明工具(Windows) 直接调用系统dll
Tran | 颜色偏向 | 透明程度(0~255) | 样式(1锁住|2变透明) |