Board logo

标题: 命令行 窗口透明度 设置工具 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 [指定颜色透明]

举例:
  1. REM 设置标题为“1.txt - 记事本” 的窗口透明度为100,参数随意 ...
  2. setA -t"1.txt - 记事本" -r100,120,158
  3. setA -t"1.txt - 记事本" -r100,120,158
  4. setA -t"1.txt - 记事本" -a100
  5. setA -t"1.txt - 记事本" -r100,120,158
  6. setA -t"1.txt - 记事本" -a100 -r100,120,158
  7. REM 设置当前控制台窗口透明度;请自行发挥,参数随意 ...
  8. setA -a
  9. setA -r
  10. setA -a100
  11. setA -r255,230,187
  12. setA -a -r
复制代码
版本:
VERSION 1.0


源码:
  1. /*
  2. CONSOLE SET WINDOW ALPHA TRANSPARENT TOOL, COPYRIGHT@2017~2019 BY LEO, VERSION 1.0
  3. SETA.EXE
  4. LINK KERNEL32 USER32
  5. UNICODE COMPILATION:
  6. ==> G++ setA.c -lkernel32 -luser32 -D _UNICODE -D UNICODE -municode -O2 -static
  7. ==> CL  setA.c /O2 /Oy- /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /MD
  8. ANSI COMPILATION:
  9. ==> G++ setA.c -lkernel32 -luser32 -O2 -static
  10. ==> CL  setA.c /O2 /Oy- /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /MD
  11. */
  12. #include <stdio.h>
  13. #include <windows.h>
  14. #include <tchar.h>
  15. #ifndef _UNICODE
  16. #define TCHARFORMAT CHAR
  17. #else
  18. #define TCHARFORMAT WCHAR
  19. #endif
  20. #if defined _MSC_VER
  21. #pragma comment(lib, "kernel32.lib")
  22. #pragma comment(lib, "user32.lib")
  23. #else
  24. //API函数声明
  25. BOOL WINAPI SetLayeredWindowAttributes(HWND,COLORREF,BYTE,DWORD);
  26. HWND WINAPI GetConsoleWindow(void);
  27. #endif
  28. //定义帮助说明
  29. #define HELP_INFORMATION "\
  30. setA v1.0 - Set window alpha transparent Tool - Copyright (C) 2017-2019 by Leo\n\
  31. Usage: setA -t[title] -a[alpha] -r[R,G,B]\n\
  32. \n\
  33. General options:\n\
  34.   -t  Specifies the window title to be operated\n\
  35.   -a  Set the alpha transparency value\n\
  36.   -r  Set the RGB value\n\
  37.   -h  SHow help information\n\
  38. Official website:\n\
  39.       http://www.bathome.net/thread-44189-1-1.html\n"
  40. //开关解析
  41. int OPTIND=1, OPTOPT;
  42. TCHAR* OPTARG;
  43. int _tgetopt(int nargc, TCHAR* nargv[], TCHAR* ostr)
  44. {
  45. static TCHAR* place=(TCHAR*)_T("");
  46. static TCHAR* lastostr=NULL;
  47. register TCHAR* oli;
  48. if(ostr!=lastostr)
  49. {
  50. lastostr=ostr;
  51. place=(TCHAR*)_T("");
  52. }
  53. if(!*place)
  54. {
  55. if(
  56.     (OPTIND>=nargc)                          ||
  57.     (*(place=nargv[OPTIND])!=(TCHAR)_T('-')) ||
  58.     (!*(++place))
  59. )
  60. {
  61. place=(TCHAR*)_T("");
  62. return _TEOF;
  63. }
  64. if (*place == (TCHAR)_T('-') && *(place+1) == (TCHAR)_T('\0'))
  65. {
  66. ++OPTIND;
  67. return _TEOF;
  68. }
  69. }
  70. if (
  71.     (OPTOPT=*place++)==(TCHAR)_T(':') ||
  72.     !(oli=(TCHAR*)_tcschr((TCHARFORMAT*)ostr, (TCHAR)OPTOPT))
  73. )
  74. {
  75. if(!*place)
  76. {
  77. ++OPTIND;
  78. }
  79. }
  80. if (oli != NULL && *(++oli) != (TCHAR)_T(':'))
  81. {
  82. OPTARG=NULL;
  83. if(!*place)
  84. {
  85. ++OPTIND;
  86. }
  87. }
  88. else
  89. {
  90. if(*place)
  91. {
  92. OPTARG=place;
  93. }
  94. else if(nargc<=++OPTIND)
  95. {
  96. place=(TCHAR*)_T("");
  97. }
  98. else
  99. {
  100. OPTARG=nargv[OPTIND];
  101. }
  102. place=(TCHAR*)_T("");
  103. ++OPTIND;
  104. }
  105. return OPTOPT;
  106. }
  107. //主函数入口
  108. int _tmain(int argc, TCHAR** argv)
  109. {
  110. //设置传入参数
  111. TCHAR* opeTITLE=NULL;
  112. HWND hWND=NULL;
  113. DWORD opeFLAG=(DWORD)0;
  114. INT K=-1, opeRGB=0, opeALPHA=127;
  115. if(argc<2)
  116. {
  117. //无参数则退出
  118. fprintf(stdout, HELP_INFORMATION);
  119. exit(0);
  120. }
  121. //开关解析
  122. while((K=_tgetopt(argc, argv, (TCHAR*)_T("t:a:r:hT:A:R:H")))!=_TEOF)
  123. {
  124. switch(K)
  125. {
  126. case 't':
  127. case 'T':
  128. if(OPTARG !=NULL)
  129. {
  130. opeTITLE=OPTARG;
  131. }
  132. break;
  133. case 'a':
  134. case 'A':
  135. opeFLAG |= 2;
  136. if(OPTARG !=NULL)
  137. {
  138. opeALPHA =_ttoi((TCHARFORMAT*)OPTARG);
  139. if(
  140.     (opeALPHA == 0 && *OPTARG != _T('0')) ||
  141.     (opeALPHA <0 || 255< opeALPHA)
  142. )
  143. {
  144. _ftprintf(stderr, _T("Alpha value must be in range of 0 to 255\n"));
  145. exit(1);
  146. }
  147. }
  148. break;
  149. case 'r':
  150. case 'R':
  151. opeFLAG |= 1;
  152. if(OPTARG !=NULL)
  153. {
  154. int tR=0, tG=0, tB=0;
  155. TCHAR* tSTR=NULL;
  156. tSTR=_tcstok((TCHARFORMAT*)OPTARG, _T(","));
  157. if(tSTR !=NULL)
  158. {
  159. tR=_ttoi((TCHARFORMAT*)tSTR);
  160. if(
  161.     (tR == 0 && *tSTR != _T('0')) ||
  162.     (tR <0 || 255< tR)
  163. )
  164. {
  165. _ftprintf(stderr, _T("RGB's R-color channel value must be in range of 0 to 255\n"));
  166. exit(1);
  167. }
  168. }
  169. else
  170. {
  171. break;
  172. }
  173. tSTR=_tcstok(NULL, _T(","));
  174. if(tSTR !=NULL)
  175. {
  176. tG=_ttoi((TCHARFORMAT*)tSTR);
  177. if(tG <0 || 255< tG)
  178. {
  179. _ftprintf(stderr, _T("RGB's G-color channel value must be in range of 0 to 255\n"));
  180. exit(1);
  181. }
  182. }
  183. else
  184. {
  185. break;
  186. }
  187. tSTR=_tcstok(NULL, _T(","));
  188. if(tSTR !=NULL)
  189. {
  190. tB=_ttoi((TCHARFORMAT*)tSTR);
  191. if(tB <0 || 255< tB)
  192. {
  193. _ftprintf(stderr, _T("RGB's B-color channel value must be in range of 0 to 255\n"));
  194. exit(1);
  195. }
  196. }
  197. else
  198. {
  199. break;
  200. }
  201. //合成RGB数值
  202. opeRGB=RGB(tR, tG, tB);
  203. }
  204. break;
  205. case 'h':
  206. case 'H':
  207. fprintf(stdout, HELP_INFORMATION);
  208. exit(0);
  209. default:
  210. _ftprintf(stderr, _T("Unknown switch '-%c'\n"), K);
  211. exit(1);
  212. }
  213. }
  214. //获取标题对应窗口句柄,无标题则获取当前控制台窗口句柄
  215. hWND=(opeTITLE==NULL)?GetConsoleWindow() :FindWindow(NULL, (TCHARFORMAT*)opeTITLE);
  216. if(hWND != NULL)
  217. {
  218. //获取窗口原风格
  219. long preSYTLE = GetWindowLong(hWND, GWL_EXSTYLE);
  220. //改指定窗口属性
  221. SetWindowLong(hWND, GWL_EXSTYLE,  preSYTLE|WS_EX_LAYERED);
  222. //设置窗口透明度
  223. if(! SetLayeredWindowAttributes(hWND, opeRGB, opeALPHA, opeFLAG))
  224. {
  225. _ftprintf(stderr, _T("Setting window's alpha transparency failed\n"));
  226. exit(1);
  227. }
  228. }
  229. else
  230. {
  231. _ftprintf(stderr, _T("Can not find the window for the specified title\n"));
  232. exit(1);
  233. }
  234. return 0;
  235. }
复制代码
附一个批处理的演示,实现任何批处理隐藏运行。
  1. @echo off
  2. for /l %%i in (255,-16,0) do (
  3. setA -a%%i
  4. )
  5. for /l %%i in (0,32,255) do (
  6. setA -a%%i
  7. )
  8. 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