吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 5946|回复: 31
收起左侧

[C&C++ 转载] 隐藏任务栏及鼠标移动到底部实现任务栏切换

  [复制链接]
夏日已末 发表于 2018-6-6 15:21
本帖最后由 夏日已末 于 2018-6-6 18:00 编辑

隐藏前:
1.jpg
隐藏后:(黑色部分不属于桌面)
2.jpg

源码:
[C++] 纯文本查看 复制代码
#include <stdio.h>  
#include <iostream>
#include <windows.h>  
#include <atlstr.h>
using namespace std;
int main(int argc, char* argv[])
{
        HWND button, task,startmenu;
        
        //desktop = FindWindow(L"ProgMan", NULL);
        task = FindWindow(L"Shell_TrayWnd", NULL);  //任务栏窗口号
        //startmenu = FindWindow(L"TrayNotifyWnd", NULL);  //开始菜单窗口号
        button = FindWindow(L"button", NULL);          
        //for (int i = 0; i < 20; i+=2)
        //{
        //        startmenu = (HWND)((int)task + i);
        //        LPWSTR PerfData = (LPWSTR)malloc(255);
        //        GetClassName(startmenu, PerfData, 255);
        //        printf(CW2A(PerfData));
        //        printf("\n");
        //        system("pause");
        //        ShowWindow(startmenu, SW_SHOW);//显示
        //}

        APPBARDATA apBar;
        memset(&apBar, 0, sizeof(apBar));
        apBar.cbSize = sizeof(apBar);
        apBar.hWnd = task;
        LPARAM lParam = SHAppBarMessage(ABM_GETSTATE, &apBar);
        //if (lParam == ABS_AUTOHIDE)
        //{
        //        apBar.lParam = ABS_ALWAYSONTOP;
        //        SHAppBarMessage(ABM_SETSTATE, &apBar);
        //}
        //else
        //{
        //        apBar.lParam = ABS_AUTOHIDE | ABS_ALWAYSONTOP;
        //        SHAppBarMessage(ABM_SETSTATE, &apBar);
        //}




        if (IsWindowVisible(task) || IsWindowVisible(button))
        {
                apBar.lParam = ABS_AUTOHIDE | ABS_ALWAYSONTOP;
                SHAppBarMessage(ABM_SETSTATE, &apBar);
                ShowWindow(task, SW_HIDE);//隐藏任务栏 
                ShowWindow(button, SW_HIDE);//隐藏任务栏 
        }
        else
        {
                ShowWindow(task, SW_SHOW);//显示任务栏 
                ShowWindow(button, SW_SHOW);//显示任务栏 
                Sleep(500);
                apBar.lParam = ABS_ALWAYSONTOP;
                SHAppBarMessage(ABM_SETSTATE, &apBar);
        }


        //LPRECT rect=(LPRECT)malloc(10);
        //GetWindowRect(task, rect);
        //MoveWindow(task, 0, 0, 0, 0, 0);
        //ShowWindow(desktop, SW_HIDE);//隐藏桌面  
        //Sleep(3000);
        //ShowWindow(task, SW_SHOW);//显示  
        //ShowWindow(desktop, SW_SHOW);//显示  
        //system("pause");
        return 0;
}




实现鼠标移动到底部中间部分实现任务栏切换
3.png

源码:
[C++] 纯文本查看 复制代码
// testProject.cpp : 定义控制台应用程序的入口点。[/backcolor]//

#include "stdio.h"
#include <iostream>
#include<windows.h>
#include <conio.h>
//#include <conio.h>
//#include <string>
using namespace std;

BOOL CtrlHandler(DWORD fdwCtrlType);

int main()
{
        SetConsoleCtrlHandler((PHANDLER_ROUTINE)CtrlHandler, TRUE);
        //cout << "控制鼠标移动的程序已经开始运行^_^" << endl;
        //DEVMODE DevMode;
        //EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &DevMode);
        //DevMode.dmPelsWidth;
        //DevMode.dmPelsHeight;
        double width = 0.4;
        int  cx = GetSystemMetrics(SM_CXFULLSCREEN);
        int  cy = GetSystemMetrics(SM_CYFULLSCREEN);
        //cout << cx << " " << cy << endl;
        HWND hwndnew,hwndtemp;
        HWND hwndold=GetForegroundWindow();
        hwndnew = hwndold;
        ShowWindow(hwndold,SW_HIDE); //将cmd窗口隐藏起来,让程序在后台运行
        POINT last_p;
        bool ifpressed=0;
        int left = cx*width;
        int right = cx*(1 - width);
        while (true)
        {
                GetCursorPos(&last_p);//获取鼠标坐标
                Sleep(100);
                //cout << last_p.x << " " << last_p.y << endl;
                if (last_p.x >= left&&last_p.x <= right && last_p.y >= cy)
                {
                        //cout << last_p.x << "," << last_p.y << endl;
                        keybd_event(VK_MENU, MapVirtualKey(VK_MENU, 0), 0, 0);
                        keybd_event(VK_TAB, MapVirtualKey(VK_TAB, 0), 0, 0);
                        keybd_event(VK_TAB, MapVirtualKey(VK_TAB, 0), KEYEVENTF_KEYUP, 0);
                        ifpressed = 1;
                        while (1)
                        {
                                GetCursorPos(&last_p);
                                Sleep(100);
                                if (last_p.x<left || last_p.x>right || last_p.y < cy)
                                        break;
                        }
                }
                if (ifpressed)
                {
                        if (GetKeyState(0x0001) & 0x8000)
                        {
                                while (1)
                                {
                                        if (!(GetKeyState(0x0001) & 0x8000))
                                                break;
                                }
                                keybd_event(VK_MENU, MapVirtualKey(VK_MENU, 0), KEYEVENTF_KEYUP, 0);
                                ifpressed = 0;
                                //GetCursorPos(&last_p);
                                //mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
                        }
                        if (_kbhit())
                        {
                                keybd_event(VK_MENU, MapVirtualKey(VK_MENU, 0), KEYEVENTF_KEYUP, 0);
                                ifpressed = 0;
                        }
                }
                

                hwndtemp = GetForegroundWindow();
                bool state = 0;
                if (hwndtemp != hwndnew &&hwndtemp!= hwndold)
                {
                        hwndold = hwndnew;
                        hwndnew = hwndtemp;
                        state = 1;

                }
                if (last_p.x == 0 && last_p.y == 0)
                {
                        if (hwndtemp == hwndold)
                        {
                                ShowWindow(hwndnew, SW_SHOW);
                                SetForegroundWindow(hwndnew);
                        }
                        else if (hwndtemp == hwndnew)
                        {
                                ShowWindow(hwndold, SW_SHOW);
                                SetForegroundWindow(hwndold);
                        }
                        while (1)
                        {
                                GetCursorPos(&last_p);
                                Sleep(100);
                                if (last_p.x!=0 ||last_p.y !=0 )
                                        break;
                        }
                }
                //if (state)
                //{
                //        cout << "hwndold:" << hwndold << endl;
                //        //cout << "hwndtemp:" << hwndtemp << endl;
                //        cout << "hwndnew:" << hwndnew << endl;
                //}
        }


        return 0;
}

BOOL CtrlHandler(DWORD fdwCtrlType)
{
        switch (fdwCtrlType)
        {
        //        /* handle the CTRL-C signal */
        //case CTRL_C_EVENT:
        //        printf("CTRL-C event\n");
        //        Beep(750, 300);
        //        return TRUE;

        //        /* handle the CTRL-BREAK signal */
        //case CTRL_BREAK_EVENT:
        //        printf("CTRL-BREAK event\n");
        //        Beep(900, 200);
        //        return TRUE;

                /* handle the CTRL-CLOSE signal */
        case CTRL_CLOSE_EVENT:
                printf("点击了控制台右上角的“X”\n");
                keybd_event(VK_MENU, MapVirtualKey(VK_MENU, 0), KEYEVENTF_KEYUP, 0);
                //Beep(600, 200);
                return TRUE;

                /* handle the CTRL-LOGOFF signal */
        //case CTRL_LOGOFF_EVENT:
        //        printf("CTRL-LOGOFF event\n");
        //        Beep(1000, 200);
        //        return TRUE;

        //        /* handle the CTRL-SHUTDOWN signal */
        //case CTRL_SHUTDOWN_EVENT:
        //        printf("CTRL-SHUTDOWN event\n");
        //        Beep(750, 500);
        //        return TRUE;

        default:
                return FALSE;
        }
}


release版本,直接运行不知道会不会提示缺少文件
hidetask执行过后不会有进程,再次执行就能显示任务栏了,tab的如果要结束需要结束进程
Desk.zip (11.53 KB, 下载次数: 126)



免费评分

参与人数 7吾爱币 +8 热心值 +7 收起 理由
幕拂晓 + 2 + 1 我很赞同!
某些人 + 1 + 1 谢谢@Thanks!
桔子 + 1 + 1 用心讨论,共获提升!
taotao8070 + 1 + 1 我很赞同!
341 + 1 + 1 我很赞同!
丿超超 + 2 + 1 谢谢@Thanks!
CanoeC + 1 热心回复!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

冥界3大法王 发表于 2018-6-7 08:50
@夏日已末
楼主你的代码有点长
[Asm] 纯文本查看 复制代码
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.  
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.  
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.  
  
hw_tray := DllCall( "FindWindowEx", "uint",0, "uint",0, "str","Shell_TrayWnd", "uint",0 )  
MsgBox, % hw_tray  
WinHide, ahk_id %hw_tray%  
MsgBox, 隐藏  
WinShow, ahk_id %hw_tray%  
MsgBox, 显示  
Return     
  
;~ 简单版  
WinHide ahk_class Shell_TrayWnd   ;隐藏任务栏  
WinShow ahk_class Shell_TrayWnd  ;显示任务栏  
  
;可以拉伸桌面的版  
F8::  
VarSetCapacity( APPBARDATA, 36, 0 )  
IfWinNotExist, ahk_class Shell_TrayWnd  
{  
NumPut( (ABS_ALWAYSONTOP := 0x2), APPBARDATA, 32, "UInt" )           ;Enable "Always on top" (& disable auto-hide)  
DllCall( "Shell32.dll\SHAppBarMessage", "UInt", ( ABM_SETSTATE := 0xA ), "UInt", &APPBARDATA )  
WinShow ahk_class Shell_TrayWnd  
}  
Else  
{  
NumPut( ( ABS_AUTOHIDE := 0x1 ), APPBARDATA, 32, "UInt" )            ;Disable "Always on top" (& enable auto-hide to hide Start button)  
DllCall( "Shell32.dll\SHAppBarMessage", "UInt", ( ABM_SETSTATE := 0xA ), "UInt", &APPBARDATA )  
WinHide ahk_class Shell_TrayWnd  
}  
  
Return  
流离之人卖火柴 发表于 2018-6-6 15:32
头像被屏蔽
孤静之美 发表于 2018-6-6 15:34
520dman 发表于 2018-6-6 15:43
支持~虽然看不懂。。。。
341 发表于 2018-6-6 15:47
厉害了,666
taotao8070 发表于 2018-6-6 15:52
为什么要隐藏呢?
Taobi 发表于 2018-6-6 15:54
不错 有软件吗
chanbork 发表于 2018-6-6 15:56
看起来很高大上,但是看不懂!
 楼主| 夏日已末 发表于 2018-6-6 16:19
taotao8070 发表于 2018-6-6 15:52
为什么要隐藏呢?

一般都是结合第三方插件来美化的
深蓝浅 发表于 2018-6-6 16:20
C++代码看的脑壳痛
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-11-26 07:29

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

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