找回密码
 新注册用户
搜索
查看: 7806|回复: 6

[分享] 显示/隐藏窗口的小程序

[复制链接]
发表于 2008-11-25 13:18:17 | 显示全部楼层 |阅读模式
配合GTV,写了一个小的程序,可以显示/隐藏窗口
其实不仅能隐藏GTV,别的窗口也行


普通使用方法:
解压后放到任意文件夹
直接运行exe,所有可见GTV窗口隐藏,所有隐藏窗口可见
运行show all.bat,显示所有GTV窗口
运行hide all.bat,隐藏所有GTV窗口



高级使用方法:
Usage: showhide [Function=0] [Window title=GTV.exe] [Class name=ConsoleWindowClass]
    Function:
    0: Hide
    1: Show
    2: Invert

代码很短,贴出来吧
#include <stdio.h>
#include <windows.h>

int function=2;        //0=hide 1=show        2=invert
char title[1024]="GTV.exe";
char classname[1024]="ConsoleWindowClass";
int windowfound=0;

BOOL CALLBACK EnumProc(HWND hwnd, LPARAM lp)
{
        //if ((GetWindowLong(hwnd,GWL_STYLE) & WS_VISIBLE)) {
                char buf[1024];
                char buf2[1024];
                GetWindowText(hwnd,buf,1024);
                GetClassName(hwnd,buf2,1024);
                if (strstr(buf,(char*)title)!=NULL){
                        if (strstr(buf2,(char*)classname)!=NULL){
                                if (function==0){
                                        //hide
                                        ShowWindow(hwnd,SW_HIDE);
                                        printf("HIDE: ");
                                }
                                else if (function==1){
                                        //show
                                        ShowWindow(hwnd,SW_SHOW);
                                        printf("SHOW: ");
                                }
                                else if (function==2){
                                        if ((GetWindowLong(hwnd,GWL_STYLE) & WS_VISIBLE)){
                                                //hide
                                                ShowWindow(hwnd,SW_HIDE);
                                                printf("HIDE: ");
                                        }
                                        else{
                                                //show
                                                ShowWindow(hwnd,SW_SHOW);
                                                printf("SHOW: ");
                                        }
                                }
                                printf("HWND=%d Title=%s Class=%s\n",hwnd,buf,buf2);
                                windowfound++;
                        }
                       
                }
        //}
        return TRUE;
}

void main( int argc, char *argv[], char *envp[] )
{
        //usage
        printf("Usage: showhide [Function=2] [Window title=GTV.exe] [Class name=ConsoleWindowClass]\n");
        printf("    Function:\n");
        printf("    0: Hide\n");
        printf("    1: Show\n");
        printf("    2: Invert\n");
        if (argc==2){
                function=atoi(argv[1]);
        }
        else if (argc==3){
                function=atoi(argv[1]);
                strcpy(title,argv[2]);
        }
        else if (argc==4){
                function=atoi(argv[1]);
                strcpy(title,argv[2]);
                strcpy(classname,argv[3]);
        }
        EnumWindows(EnumProc,NULL);
        printf("Total Windows Found=%d\n",windowfound);

       
}

[ 本帖最后由 JUST 于 2008-11-25 13:58 编辑 ]

showhidewindow.zip

27.92 KB, 下载次数: 3522

已经添加库文件

回复

使用道具 举报

发表于 2008-11-25 13:52:40 | 显示全部楼层
刚试用了一下,双击showhidewindow.exe报错了。
sh.png
回复

使用道具 举报

 楼主| 发表于 2008-11-25 13:59:04 | 显示全部楼层

回复 #2 烦人 的帖子

又是DLL的问题
现在把库包含进去了,请再试一下
回复

使用道具 举报

发表于 2008-11-25 14:06:40 | 显示全部楼层
现在有效了。Good Job!
回复

使用道具 举报

发表于 2008-11-25 17:23:47 | 显示全部楼层
GJ!    vista64 有效
回复

使用道具 举报

发表于 2008-11-25 19:40:24 | 显示全部楼层
非常谢谢JUST啊~~~这样的话我就又可以少写一点代码了~~~
回复

使用道具 举报

发表于 2008-11-26 08:08:26 | 显示全部楼层
这工具不错,好用
我把它和GTV放在一起,这样好找一点
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 新注册用户

本版积分规则

论坛官方淘宝店开业啦~
欢迎大家多多支持基金会~

Archiver|手机版|小黑屋|中国分布式计算总站 ( 沪ICP备05042587号 )

GMT+8, 2024-5-4 05:26

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表