Created
July 20, 2023 13:16
-
-
Save hapylestat/c77999e96b32040ef7937f259b19e6a7 to your computer and use it in GitHub Desktop.
Switching Start Menu panne autohide option on or off
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// To compile use: | |
// C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe .\hide.cs | |
// | |
using System; | |
using System.Runtime.InteropServices; | |
using System.Drawing; | |
namespace AppBar { | |
public enum AppBarMessages | |
{ | |
New = 0x00, | |
Remove = 0x01, | |
QueryPos = 0x02, | |
SetPos = 0x03, | |
GetState = 0x04, | |
GetTaskBarPos = 0x05, | |
Activate = 0x06, | |
GetAutoHideBar = 0x07, | |
SetAutoHideBar = 0x08, | |
WindowPosChanged = 0x09, | |
SetState = 0x0a | |
} | |
[StructLayout(LayoutKind.Sequential)] | |
public struct APPBARDATA | |
{ | |
public UInt32 cbSize; | |
public IntPtr hWnd; | |
public UInt32 uCallbackMessage; | |
public UInt32 uEdge; | |
public Rectangle rc; | |
public Int32 lParam; | |
} | |
public enum AppBarStates | |
{ | |
AutoHide = 0x01, | |
AlwaysOnTop = 0x02 | |
} | |
public class StartHide{ | |
[DllImport("user32.dll", CharSet = CharSet.Auto)] | |
public static extern IntPtr FindWindow(string strClassName, string strWindowName); | |
[DllImport("shell32.dll")] | |
public static extern UInt32 SHAppBarMessage(UInt32 dwMessage, ref APPBARDATA pData); | |
/// <summary> | |
/// Set the Taskbar State option | |
/// </summary> | |
/// <param name="option">AppBarState to activate</param> | |
public static void SetTaskbarState(AppBarStates option) | |
{ | |
APPBARDATA msgData = new APPBARDATA(); | |
msgData.cbSize = (UInt32)Marshal.SizeOf(msgData); | |
msgData.hWnd = FindWindow("System_TrayWnd", null); | |
msgData.lParam = (Int32)(option); | |
SHAppBarMessage((UInt32)AppBarMessages.SetState, ref msgData); | |
} | |
/// <summary> | |
/// Gets the current Taskbar state | |
/// </summary> | |
/// <returns>current Taskbar state</returns> | |
public static AppBarStates GetTaskbarState() | |
{ | |
APPBARDATA msgData = new APPBARDATA(); | |
msgData.cbSize = (UInt32)Marshal.SizeOf(msgData); | |
msgData.hWnd = FindWindow("System_TrayWnd", null); | |
return (AppBarStates)SHAppBarMessage((UInt32)AppBarMessages.GetState, ref msgData); | |
} | |
static void Main(string[] args) | |
{ | |
if (args.Length == 1) { | |
switch (args[0]) { | |
case "1": | |
SetTaskbarState(AppBarStates.AutoHide); | |
break; | |
case "0": | |
SetTaskbarState(AppBarStates.AlwaysOnTop); | |
break; | |
} | |
return; | |
} | |
switch (GetTaskbarState()) { | |
case AppBarStates.AutoHide: | |
SetTaskbarState(AppBarStates.AlwaysOnTop); | |
break; | |
case AppBarStates.AlwaysOnTop: | |
SetTaskbarState(AppBarStates.AutoHide); | |
break; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello!
I have a small project that is mange windows things: services, components, and etc... for optimizing Windows 10 and 11 for different usecases.
My ide:
So I can manage Windows Services (States), Disable/enable Options in Registry, completly remove appxpackages, and other fun things.
My settings has some main category. One of this is a "VM-Settings" to optimize Windows Virtual Machine what is running on my Linux.
Im looking for somebody who can give me help to create a graphical user interface for this.
I start to build UI. I start with Powershell+Winforms, now I migrate to Powershell+WPF.
UI is working, but I have some missing experience to do that.
This projct is completly open source, and you can find on my Github in PowerShell-lab repository.
Are you interested in the topic?
Can I ask help please?
What do you recommend for UI? I thinking to try Tauri + React because im stuck in WPF developement.
If you are open to discuss, I can show my WPF base application.
Im open to learn dotnet, and other technologies too.
Best Regards,
@morfyum