标题: 命令行 窗口透明度 设置工具 setA发布 [打印本页]
作者: happy886rr 时间: 2017-5-18 17:24 标题: 命令行 窗口透明度 设置工具 setA发布
setA是一个设置各类windows窗口透明度的工具,在多种windows系统上兼容,且支持多参数,也支持大多数版本的cmd.exe黑窗口透明度设置。修补同类工具各种缺陷,也是你能找到的最好的。源码做了宽窄字符和各类编译器兼容,VS、GCC通吃,另外还有一些隐藏功能,比如窗口锁请自行挖掘。(图片均为外链,随时失效)
SETA.EXE (CONSOLE SET WINDOW ALPHA TRANSPARENT TOOL, BY LEO, VERSION 1.0)
下载链接: https://pan.baidu.com/s/1V00ewoE3CyCyfgsS10semQ?pwd=eitp
摘要:
===================================
命令行下的 窗口透明度 设置工具,参数缺省可自动补全。
===================================
用法:(指定颜色需用R,G,B格式表示)
setA -t [窗口标题] -a [透明度] -r [指定颜色透明]
举例:- REM 设置标题为“1.txt - 记事本” 的窗口透明度为100,参数随意 ...
- setA -t"1.txt - 记事本" -r100,120,158
- setA -t"1.txt - 记事本" -r100,120,158
- setA -t"1.txt - 记事本" -a100
- setA -t"1.txt - 记事本" -r100,120,158
- setA -t"1.txt - 记事本" -a100 -r100,120,158
-
- REM 设置当前控制台窗口透明度;请自行发挥,参数随意 ...
- setA -a
- setA -r
- setA -a100
- setA -r255,230,187
- setA -a -r
复制代码
版本:
VERSION 1.0
源码:- /*
- CONSOLE SET WINDOW ALPHA TRANSPARENT TOOL, COPYRIGHT@2017~2019 BY LEO, VERSION 1.0
- SETA.EXE
- LINK KERNEL32 USER32
-
- UNICODE COMPILATION:
- ==> G++ setA.c -lkernel32 -luser32 -D _UNICODE -D UNICODE -municode -O2 -static
- ==> CL setA.c /O2 /Oy- /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /MD
-
- ANSI COMPILATION:
- ==> G++ setA.c -lkernel32 -luser32 -O2 -static
- ==> CL setA.c /O2 /Oy- /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /MD
- */
-
- #include <stdio.h>
- #include <windows.h>
- #include <tchar.h>
-
- #ifndef _UNICODE
- #define TCHARFORMAT CHAR
- #else
- #define TCHARFORMAT WCHAR
- #endif
-
- #if defined _MSC_VER
- #pragma comment(lib, "kernel32.lib")
- #pragma comment(lib, "user32.lib")
- #else
- //API函数声明
- BOOL WINAPI SetLayeredWindowAttributes(HWND,COLORREF,BYTE,DWORD);
- HWND WINAPI GetConsoleWindow(void);
- #endif
-
- //定义帮助说明
- #define HELP_INFORMATION "\
- setA v1.0 - Set window alpha transparent Tool - Copyright (C) 2017-2019 by Leo\n\
- Usage: setA -t[title] -a[alpha] -r[R,G,B]\n\
- \n\
- General options:\n\
- -t Specifies the window title to be operated\n\
- -a Set the alpha transparency value\n\
- -r Set the RGB value\n\
- -h SHow help information\n\
- Official website:\n\
- http://www.bathome.net/thread-44189-1-1.html\n"
-
- //开关解析
- int OPTIND=1, OPTOPT;
- TCHAR* OPTARG;
- int _tgetopt(int nargc, TCHAR* nargv[], TCHAR* ostr)
- {
- static TCHAR* place=(TCHAR*)_T("");
- static TCHAR* lastostr=NULL;
- register TCHAR* oli;
-
- if(ostr!=lastostr)
- {
- lastostr=ostr;
- place=(TCHAR*)_T("");
- }
-
- if(!*place)
- {
- if(
- (OPTIND>=nargc) ||
- (*(place=nargv[OPTIND])!=(TCHAR)_T('-')) ||
- (!*(++place))
- )
- {
- place=(TCHAR*)_T("");
- return _TEOF;
- }
- if (*place == (TCHAR)_T('-') && *(place+1) == (TCHAR)_T('\0'))
- {
- ++OPTIND;
- return _TEOF;
- }
- }
-
- if (
- (OPTOPT=*place++)==(TCHAR)_T(':') ||
- !(oli=(TCHAR*)_tcschr((TCHARFORMAT*)ostr, (TCHAR)OPTOPT))
- )
- {
- if(!*place)
- {
- ++OPTIND;
- }
- }
-
- if (oli != NULL && *(++oli) != (TCHAR)_T(':'))
- {
- OPTARG=NULL;
- if(!*place)
- {
- ++OPTIND;
- }
- }
- else
- {
- if(*place)
- {
- OPTARG=place;
- }
- else if(nargc<=++OPTIND)
- {
- place=(TCHAR*)_T("");
- }
- else
- {
- OPTARG=nargv[OPTIND];
- }
- place=(TCHAR*)_T("");
- ++OPTIND;
- }
- return OPTOPT;
- }
-
- //主函数入口
- int _tmain(int argc, TCHAR** argv)
- {
- //设置传入参数
- TCHAR* opeTITLE=NULL;
- HWND hWND=NULL;
- DWORD opeFLAG=(DWORD)0;
- INT K=-1, opeRGB=0, opeALPHA=127;
-
- if(argc<2)
- {
- //无参数则退出
- fprintf(stdout, HELP_INFORMATION);
- exit(0);
- }
-
- //开关解析
- while((K=_tgetopt(argc, argv, (TCHAR*)_T("t:a:r:hT:A:R:H")))!=_TEOF)
- {
- switch(K)
- {
- case 't':
- case 'T':
- if(OPTARG !=NULL)
- {
- opeTITLE=OPTARG;
- }
- break;
-
- case 'a':
- case 'A':
- opeFLAG |= 2;
- if(OPTARG !=NULL)
- {
- opeALPHA =_ttoi((TCHARFORMAT*)OPTARG);
- if(
- (opeALPHA == 0 && *OPTARG != _T('0')) ||
- (opeALPHA <0 || 255< opeALPHA)
- )
- {
- _ftprintf(stderr, _T("Alpha value must be in range of 0 to 255\n"));
- exit(1);
- }
- }
- break;
-
- case 'r':
- case 'R':
- opeFLAG |= 1;
- if(OPTARG !=NULL)
- {
- int tR=0, tG=0, tB=0;
- TCHAR* tSTR=NULL;
-
- tSTR=_tcstok((TCHARFORMAT*)OPTARG, _T(","));
- if(tSTR !=NULL)
- {
- tR=_ttoi((TCHARFORMAT*)tSTR);
- if(
- (tR == 0 && *tSTR != _T('0')) ||
- (tR <0 || 255< tR)
- )
- {
- _ftprintf(stderr, _T("RGB's R-color channel value must be in range of 0 to 255\n"));
- exit(1);
- }
- }
- else
- {
- break;
- }
-
- tSTR=_tcstok(NULL, _T(","));
- if(tSTR !=NULL)
- {
- tG=_ttoi((TCHARFORMAT*)tSTR);
- if(tG <0 || 255< tG)
- {
- _ftprintf(stderr, _T("RGB's G-color channel value must be in range of 0 to 255\n"));
- exit(1);
- }
- }
- else
- {
- break;
- }
-
- tSTR=_tcstok(NULL, _T(","));
- if(tSTR !=NULL)
- {
- tB=_ttoi((TCHARFORMAT*)tSTR);
- if(tB <0 || 255< tB)
- {
- _ftprintf(stderr, _T("RGB's B-color channel value must be in range of 0 to 255\n"));
- exit(1);
- }
- }
- else
- {
- break;
- }
- //合成RGB数值
- opeRGB=RGB(tR, tG, tB);
-
- }
- break;
-
- case 'h':
- case 'H':
- fprintf(stdout, HELP_INFORMATION);
- exit(0);
-
- default:
- _ftprintf(stderr, _T("Unknown switch '-%c'\n"), K);
- exit(1);
- }
- }
-
- //获取标题对应窗口句柄,无标题则获取当前控制台窗口句柄
- hWND=(opeTITLE==NULL)?GetConsoleWindow() :FindWindow(NULL, (TCHARFORMAT*)opeTITLE);
-
- if(hWND != NULL)
- {
- //获取窗口原风格
- long preSYTLE = GetWindowLong(hWND, GWL_EXSTYLE);
-
- //改指定窗口属性
- SetWindowLong(hWND, GWL_EXSTYLE, preSYTLE|WS_EX_LAYERED);
-
- //设置窗口透明度
- if(! SetLayeredWindowAttributes(hWND, opeRGB, opeALPHA, opeFLAG))
- {
- _ftprintf(stderr, _T("Setting window's alpha transparency failed\n"));
- exit(1);
- }
- }
- else
- {
- _ftprintf(stderr, _T("Can not find the window for the specified title\n"));
- exit(1);
- }
- return 0;
- }
复制代码
附一个批处理的演示,实现任何批处理隐藏运行。- @echo off
- for /l %%i in (255,-16,0) do (
- setA -a%%i
- )
- for /l %%i in (0,32,255) do (
- setA -a%%i
- )
- pause
复制代码
作者: bbaa 时间: 2017-5-21 16:01
为啥不去弄个[url=aoaoao.me]树洞[/url]的[url=file.aoaoao.me]图床[/url]呢[神级验证码警告]
或者是[url=blankwings.cn]空翼[/url]的储存:http://tieba.baidu.com/p/4655636177
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |