BUT...人生中就是會遇到那麼多的曲折,當某個應用程式有通知(例:LINE裡面的群組的人傳了不重要的訊息),然後那萬惡的工作列就彈出來了!!!FxxK我剛下載的
TaskBar Hider 下載 解壓縮密碼:wyp
本軟體使用.NET Framework 4.6
解壓縮之後把"TaskBarHider.exe"移動到C槽(避免哪天你手癢把它刪啦,然後工作列彈出來又塞不回去)
打開它,這邊建議的設定如下;WIN+Z純粹是個人覺得這樣比較好按,Load at Windows Startup是讓這個程式每次開機都會自動執行(更改設定時要Change Set,儲存設定時要Save Set)
開源程式碼:
Imports System.Reflection, System.Threading, System.ComponentModel, System.Runtime.InteropServices Public Class Form1 Dim hideflag, enableflag, keyflag As Boolean Dim keydec, keydec1 As Integer Dim WithEvents MyHook As New SystemHook() Private Sub hide_Click(sender As Object, e As EventArgs) Handles hide.Click HideTaskbar() hideflag = True hide.Enabled = False show.Enabled = True End Sub Private Sub show_Click(sender As Object, e As EventArgs) Handles show.Click UnhideTaskbar() hideflag = False hide.Enabled = True show.Enabled = False End Sub Private Sub MyHook_KeyDown(sender As Object, e As KeyEventArgs) Handles MyHook.KeyDown If keyflag = False Then If e.KeyCode = keydec1 Then keyflag = True End If Else If e.KeyCode = keydec Then If hideflag = False Then HideTaskbar() hideflag = True hide.Enabled = False show.Enabled = True Else UnhideTaskbar() hideflag = False hide.Enabled = True show.Enabled = False End If End If End If End Sub Private Sub MyHook_KeyUp(sender As Object, e As KeyEventArgs) Handles MyHook.KeyUp If keyflag = True Then keyflag = False End If End Sub Private Sub changesat_Click(sender As Object, e As EventArgs) Handles changesat.Click If enableflag = False Then changesat.Text = "Save Set" changesat.BackColor = Color.Red selectbox.Enabled = True selectbox1.Enabled = True starup.Enabled = True enableflag = True Else changesat.Text = "Change Set" changesat.BackColor = Color.GreenYellow Dim Reg As Microsoft.Win32.RegistryKey = My.Computer.Registry.LocalMachine.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True) If starup.Checked = True Then If Reg.GetValue("HideTaskbar.exe") = "" Then Reg.SetValue("HideTaskbar.exe", Application.ExecutablePath, Microsoft.Win32.RegistryValueKind.String) Reg.Close() End If Else If Reg.GetValue("HideTaskbar.exe") IsNot Nothing Then Reg.DeleteValue("HideTaskbar.exe", True) Reg.Close() End If End If If selectbox.SelectedIndex <= 26 Then keydec = 65 + Val(selectbox.SelectedIndex) Else keydec = 85 + Val(selectbox.SelectedIndex) End If If selectbox1.SelectedIndex <= 26 Then keydec1 = 65 + Val(selectbox1.SelectedIndex) Else keydec1 = 85 + Val(selectbox1.SelectedIndex) End If My.Settings.keydec_s = keydec My.Settings.keydec1_s = keydec1 My.Settings.selectbox_s = selectbox.SelectedIndex My.Settings.selectbox1_s = selectbox1.SelectedIndex My.Settings.starup = starup.Checked selectbox.Enabled = False selectbox1.Enabled = False starup.Enabled = False enableflag = False End If End Sub Private Sub Rst_Click(sender As Object, e As EventArgs) Handles Rst.Click UnhideTaskbar() MyHook.UnHook() hideflag = False keydec = 90 keydec1 = 91 selectbox.SelectedIndex = 25 selectbox1.SelectedIndex = 26 starup.Checked = False My.Settings.keydec_s = keydec My.Settings.keydec1_s = keydec1 My.Settings.selectbox_s = selectbox.SelectedIndex My.Settings.selectbox1_s = selectbox1.SelectedIndex My.Settings.starup = starup.Checked Dim Reg As Microsoft.Win32.RegistryKey = My.Computer.Registry.LocalMachine.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True) If Reg.GetValue("HideTaskbar.exe") IsNot Nothing Then Reg.DeleteValue("HideTaskbar.exe", True) Reg.Close() End If MyHook.StartHook() changesat.Text = "Change Set" changesat.BackColor = Color.GreenYellow End Sub '(*****Load and Close***** Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load HideTaskbar() UnhideTaskbar() hideflag = False enableflag = False keyflag = False keydec = My.Settings.keydec_s keydec1 = My.Settings.keydec1_s selectbox.SelectedIndex = My.Settings.selectbox_s selectbox1.SelectedIndex = My.Settings.selectbox1_s starup.Checked = My.Settings.starup MyHook.StartHook() End Sub Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick Timer1.Enabled = False winmin() End Sub Private Sub Form1_FormClosing(ByVal s As Object, ByVal e As FormClosingEventArgs) Handles Me.FormClosing MyHook.UnHook() End Sub '*****Load and Close*****) '(*****hide taskbar control***** Dim handleW1 As Long Private Declare Function FindWindowA Lib "user32" _ (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer Private Declare Function SetWindowPos Lib "user32" _ (ByVal handleW1 As Integer, ByVal handleW1InsertWhere As Integer, ByVal w As Integer, ByVal x As Integer, ByVal y As Integer, ByVal z As Integer, ByVal wFlags As Integer) As Integer Const TOGGLE_HIDEWINDOW = &H80 Const TOGGLE_UNHIDEWINDOW = &H40 Private Sub HideTaskbar() handleW1 = FindWindowA("Shell_traywnd", "") Call SetWindowPos(handleW1, 0, 0, 0, 0, 0, TOGGLE_HIDEWINDOW) End Sub Private Sub UnhideTaskbar() Call SetWindowPos(handleW1, 0, 0, 0, 0, 0, TOGGLE_UNHIDEWINDOW) End Sub '*****hide taskbar control*****) '(*****Windows Controlbox and NotifyIcon***** Private Sub x_Click(sender As Object, e As EventArgs) Handles x.Click If MsgBox("Close it?!", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then Close() End If End Sub Private Sub x_MouseLeave(sender As Object, e As EventArgs) Handles x.MouseLeave x.BackColor = Color.White End Sub Private Sub x_MouseMove(sender As Object, e As MouseEventArgs) Handles x.MouseMove x.BackColor = Color.Red End Sub Private Sub min_Click(sender As Object, e As EventArgs) Handles min.Click winmin() End Sub Private Sub NotifyIcon1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles NotifyIcon1.DoubleClick winshow() End Sub Sub winshow() NotifyIcon1.Visible = False Me.Visible = True Me.WindowState = FormWindowState.Normal End Sub Sub winmin() NotifyIcon1.Visible = True Me.Visible = False Me.WindowState = FormWindowState.Minimized End Sub '*****Windows Controlbox and NotifyIcon*****) '(*****move windows***** Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseDown Record(e) End Sub Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseMove WndMove(e) End Sub Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseUp MoveEnd(e) End Sub Private Sub title_MouseDown(sender As Object, e As MouseEventArgs) Handles title.MouseDown Record(e) End Sub Private Sub title_MouseMove(sender As Object, e As MouseEventArgs) Handles title.MouseMove WndMove(e) End Sub Private Sub title_MouseUp(sender As Object, e As MouseEventArgs) Handles title.MouseUp MoveEnd(e) End Sub Private Sub design_MouseDown(sender As Object, e As MouseEventArgs) Handles design.MouseDown Record(e) End Sub Private Sub design_MouseMove(sender As Object, e As MouseEventArgs) Handles design.MouseMove WndMove(e) End Sub Private Sub design_MouseUp(sender As Object, e As MouseEventArgs) Handles design.MouseUp MoveEnd(e) End Sub 'Module Dim nClick, nOldWnd As Point Dim isMouseDown As Boolean = False Private Sub Record(e As MouseEventArgs) If e.Button = MouseButtons.Left Then '紀錄滑鼠點選時的視窗位置與滑鼠點選位置 nOldWnd = New Point(Me.Left, Me.Top) nClick = New Point(e.X, e.Y) isMouseDown = True End If End Sub Private Sub WndMove(e As MouseEventArgs) If isMouseDown = True Then '如果滑鼠按著拖曳 '設定新的視窗位置 Me.Top = e.Y + nOldWnd.Y - nClick.Y Me.Left = e.X + nOldWnd.X - nClick.X '更新紀錄的視窗位置 nOldWnd.X = Me.Left nOldWnd.Y = Me.Top End If End Sub Private Sub MoveEnd(e As MouseEventArgs) If e.Button = MouseButtons.Left Then isMouseDown = False End If End Sub '*****move windows*****) '(*****OpenWeb***** Private Sub title_DoubleClick(sender As Object, e As EventArgs) Handles title.DoubleClick OpenWeb() End Sub Private Sub Form1_DoubleClick(sender As Object, e As EventArgs) Handles Me.DoubleClick OpenWeb() End Sub Private Sub design_DoubleClick(sender As Object, e As EventArgs) Handles design.DoubleClick OpenWeb() End Sub Private Sub OpenWeb() Shell("Rundll32.exe url.dll, FileProtocolHandler HTTP://wyp8711.blogspot.com/2016/02/taskbar-hider-xd.html", vbNormalFocus) End Sub '(*****OpenWeb***** End Class Public Class SystemHook #Region "定義結構" Private Structure MouseHookStruct Dim PT As Point Dim Hwnd As Integer Dim WHitTestCode As Integer Dim DwExtraInfo As Integer End Structure Private Structure MouseLLHookStruct Dim PT As Point Dim MouseData As Integer Dim Flags As Integer Dim Time As Integer Dim DwExtraInfo As Integer End Structure Private Structure KeyboardHookStruct Dim vkCode As Integer Dim ScanCode As Integer Dim Flags As Integer Dim Time As Integer Dim DwExtraInfo As Integer End Structure #End Region #Region "API聲明導入" Private Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Integer, ByVal lpfn As HookProc, ByVal hMod As IntPtr, ByVal dwThreadId As Integer) As Integer Private Declare Function UnhookWindowsHookEx Lib "user32" (ByVal idHook As Integer) As Integer Private Declare Function CallNextHookEx Lib "user32" (ByVal idHook As Integer, ByVal nCode As Integer, ByVal wParam As Integer, ByVal lParam As IntPtr) As Integer Private Declare Function ToAscii Lib "user32" (ByVal uVirtKey As Integer, ByVal uScancode As Integer, ByVal lpdKeyState As Byte(), ByVal lpwTransKey As Byte(), ByVal fuState As Integer) As Integer Private Declare Function GetKeyboardState Lib "user32" (ByVal pbKeyState As Byte()) As Integer Private Declare Function GetKeyState Lib "user32" (ByVal vKey As Integer) As Short Private Delegate Function HookProc(ByVal nCode As Integer, ByVal wParam As Integer, ByVal lParam As IntPtr) As Integer #End Region #Region "常量聲明" Private Const WH_MOUSE_LL = 14 Private Const WH_KEYBOARD_LL = 13 Private Const WH_MOUSE = 7 Private Const WH_KEYBOARD = 2 Private Const WM_MOUSEMOVE = &H200 Private Const WM_LBUTTONDOWN = &H201 Private Const WM_RBUTTONDOWN = &H204 Private Const WM_MBUTTONDOWN = &H207 Private Const WM_LBUTTONUP = &H202 Private Const WM_RBUTTONUP = &H205 Private Const WM_MBUTTONUP = &H208 Private Const WM_LBUTTONDBLCLK = &H203 Private Const WM_RBUTTONDBLCLK = &H206 Private Const WM_MBUTTONDBLCLK = &H209 Private Const WM_MOUSEWHEEL = &H20A Private Const WM_KEYDOWN = &H100 Private Const WM_KEYUP = &H101 Private Const WM_SYSKEYDOWN = &H104 Private Const WM_SYSKEYUP = &H105 Private Const VK_SHIFT As Byte = &H10 Private Const VK_CAPITAL As Byte = &H14 Private Const VK_NUMLOCK As Byte = &H90 #End Region #Region "事件委託處理" Private events As New System.ComponentModel.EventHandlerList '''鼠標激活事件 Public Custom Event MouseActivity As MouseEventHandler AddHandler(ByVal value As MouseEventHandler) events.AddHandler("MouseActivity", value) End AddHandler RemoveHandler(ByVal value As MouseEventHandler) events.RemoveHandler("MouseActivity", value) End RemoveHandler RaiseEvent(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Dim eh As MouseEventHandler = TryCast(events("MouseActivity"), MouseEventHandler) If eh IsNot Nothing Then eh.Invoke(sender, e) End RaiseEvent End Event '''鍵盤按下事件 Public Custom Event KeyDown As KeyEventHandler AddHandler(ByVal value As KeyEventHandler) events.AddHandler("KeyDown", value) End AddHandler RemoveHandler(ByVal value As KeyEventHandler) events.RemoveHandler("KeyDown", value) End RemoveHandler RaiseEvent(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Dim eh As KeyEventHandler = TryCast(events("KeyDown"), KeyEventHandler) If eh IsNot Nothing Then eh.Invoke(sender, e) End RaiseEvent End Event '''鍵盤輸入事件 Public Custom Event KeyPress As KeyPressEventHandler AddHandler(ByVal value As KeyPressEventHandler) events.AddHandler("KeyPress", value) End AddHandler RemoveHandler(ByVal value As KeyPressEventHandler) events.RemoveHandler("KeyPress", value) End RemoveHandler RaiseEvent(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Dim eh As KeyPressEventHandler = TryCast(events("KeyPress"), KeyPressEventHandler) If eh IsNot Nothing Then eh.Invoke(sender, e) End RaiseEvent End Event '''鍵盤鬆開事件 Public Custom Event KeyUp As KeyEventHandler AddHandler(ByVal value As KeyEventHandler) events.AddHandler("KeyUp", value) End AddHandler RemoveHandler(ByVal value As KeyEventHandler) events.RemoveHandler("KeyUp", value) End RemoveHandler RaiseEvent(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Dim eh As KeyEventHandler = TryCast(events("KeyUp"), KeyEventHandler) If eh IsNot Nothing Then eh.Invoke(sender, e) End RaiseEvent End Event #End Region Private hMouseHook As Integer Private hKeyboardHook As Integer Private Shared MouseHookProcedure As HookProc Private Shared KeyboardHookProcedure As HookProc #Region "創建與析構類型" '''創建一個全局鼠標鍵盤鉤子 (請使用Start方法開始監視) Sub New() '留空即可 End Sub '''創建一個全局鼠標鍵盤鉤子,決定是否安裝鉤子 ''' 是否立刻掛鉤系統消息 Sub New(ByVal InstallAll As Boolean) If InstallAll Then StartHook(True, True) End Sub '''創建一個全局鼠標鍵盤鉤子,並決定安裝鉤子的類型 ''' 掛鉤鍵盤消息 ''' 掛鉤鼠標消息 Sub New(ByVal InstallKeyboard As Boolean, ByVal InstallMouse As Boolean) StartHook(InstallKeyboard, InstallMouse) End Sub '''析構函數 Protected Overrides Sub Finalize() UnHook() '卸載對象時反註冊系統鉤子 MyBase.Finalize() End Sub #End Region '''開始安裝系統鉤子 ''' 掛鉤鍵盤消息 ''' 掛鉤鼠標消息 Public Sub StartHook(Optional ByVal InstallKeyboardHook As Boolean = True, Optional ByVal InstallMouseHook As Boolean = False) '註冊鍵盤鉤子 If InstallKeyboardHook AndAlso hKeyboardHook = 0 Then KeyboardHookProcedure = New HookProc(AddressOf KeyboardHookProc) hKeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, KeyboardHookProcedure, Marshal.GetHINSTANCE(Assembly.GetExecutingAssembly.GetModules()(0)), 0) If hKeyboardHook = 0 Then '檢測是否註冊完成 UnHook(True, False) '在這裡反註冊 Throw New Win32Exception(Marshal.GetLastWin32Error) '報告錯誤 End If End If '註冊鼠標鉤子 If InstallMouseHook AndAlso hMouseHook = 0 Then MouseHookProcedure = New HookProc(AddressOf MouseHookProc) hMouseHook = SetWindowsHookEx(WH_MOUSE_LL, MouseHookProcedure, Marshal.GetHINSTANCE(Assembly.GetExecutingAssembly.GetModules()(0)), 0) If hMouseHook = 0 Then UnHook(False, True) Throw New Win32Exception(Marshal.GetLastWin32Error) End If End If End Sub '''立刻卸載系統鉤子 ''' 卸載鍵盤鉤子 ''' 卸載鼠標鉤子 ''' 是否報告錯誤 Public Sub UnHook(Optional ByVal UninstallKeyboardHook As Boolean = True, Optional ByVal UninstallMouseHook As Boolean = True, Optional ByVal ThrowExceptions As Boolean = False) '卸載鍵盤鉤子 If hKeyboardHook <> 0 AndAlso UninstallKeyboardHook Then Dim retKeyboard As Integer = UnhookWindowsHookEx(hKeyboardHook) hKeyboardHook = 0 If ThrowExceptions AndAlso retKeyboard = 0 Then '如果出現錯誤,是否報告錯誤 Throw New Win32Exception(Marshal.GetLastWin32Error) '報告錯誤 End If End If '卸載鼠標鉤子 If hMouseHook <> 0 AndAlso UninstallMouseHook Then Dim retMouse As Integer = UnhookWindowsHookEx(hMouseHook) hMouseHook = 0 If ThrowExceptions AndAlso retMouse = 0 Then Throw New Win32Exception(Marshal.GetLastWin32Error) End If End If End Sub '鍵盤消息的委託處理代碼 Private Function KeyboardHookProc(ByVal nCode As Integer, ByVal wParam As Integer, ByVal lParam As IntPtr) As Integer Static handled As Boolean : handled = False If nCode >= 0 AndAlso (events("KeyDown") IsNot Nothing OrElse events("KeyPress") IsNot Nothing OrElse events("KeyUp") IsNot Nothing) Then Static MyKeyboardHookStruct As KeyboardHookStruct MyKeyboardHookStruct = DirectCast(Marshal.PtrToStructure(lParam, GetType(KeyboardHookStruct)), KeyboardHookStruct) '激活KeyDown If wParam = WM_KEYDOWN OrElse wParam = WM_SYSKEYDOWN Then '如果消息為按下普通鍵或系統鍵 Dim e As New KeyEventArgs(MyKeyboardHookStruct.vkCode) RaiseEvent KeyDown(Me, e) '激活事件 handled = handled Or e.Handled '是否取消下一個鉤子 End If '激活KeyUp If wParam = WM_KEYUP OrElse wParam = WM_SYSKEYUP Then Dim e As New KeyEventArgs(MyKeyboardHookStruct.vkCode) RaiseEvent KeyUp(Me, e) handled = handled Or e.Handled End If '激活KeyPress (TODO:此段代碼還有BUG!) If wParam = WM_KEYDOWN Then Dim isDownShift As Boolean = (GetKeyState(VK_SHIFT) & &H80 = &H80) Dim isDownCapslock As Boolean = (GetKeyState(VK_CAPITAL) <> 0) Dim keyState(256) As Byte GetKeyboardState(keyState) Dim inBuffer(2) As Byte If ToAscii(MyKeyboardHookStruct.vkCode, MyKeyboardHookStruct.ScanCode, keyState, inBuffer, MyKeyboardHookStruct.Flags) = 1 Then Static key As Char : key = Chr(inBuffer(0)) ' BUG所在 'If isDownCapslock Xor isDownShift And Char.IsLetter(key) Then ' key = Char.ToUpper(key) 'End If Dim e As New KeyPressEventArgs(key) RaiseEvent KeyPress(Me, e) handled = handled Or e.Handled End If End If '取消或者激活下一個鉤子 If handled Then Return 1 Else Return CallNextHookEx(hKeyboardHook, nCode, wParam, lParam) End If End Function '鼠標消息的委託處理代碼 Private Function MouseHookProc(ByVal nCode As Integer, ByVal wParam As Integer, ByVal lParam As IntPtr) As Integer If nCode >= 0 AndAlso events("MouseActivity") IsNot Nothing Then Static mouseHookStruct As MouseLLHookStruct mouseHookStruct = DirectCast(Marshal.PtrToStructure(lParam, GetType(MouseLLHookStruct)), MouseLLHookStruct) Static moubut As MouseButtons : moubut = MouseButtons.None '鼠標按鍵 Static mouseDelta As Integer : mouseDelta = 0 '滾輪值 Select Case wParam Case WM_LBUTTONDOWN moubut = MouseButtons.Left Case WM_RBUTTONDOWN moubut = MouseButtons.Right Case WM_MBUTTONDOWN moubut = MouseButtons.Middle Case WM_MOUSEWHEEL Static int As Integer : int = (mouseHookStruct.MouseData >> 16) And &HFFFF '本段代碼CLE添加,模仿C#的Short從Int棄位轉換 If int > Short.MaxValue Then mouseDelta = int - 65536 Else mouseDelta = int End Select Static clickCount As Integer : clickCount = 0 '單擊次數 If moubut <> MouseButtons.None Then If wParam = WM_LBUTTONDBLCLK OrElse wParam = WM_RBUTTONDBLCLK OrElse wParam = WM_MBUTTONDBLCLK Then clickCount = 2 Else clickCount = 1 End If End If Dim e As New MouseEventArgs(moubut, clickCount, mouseHookStruct.PT.X, mouseHookStruct.PT.Y, mouseDelta) RaiseEvent MouseActivity(Me, e) End If Return CallNextHookEx(hMouseHook, nCode, wParam, lParam) '激活下一個鉤子 End Function '''鍵盤鉤子是否有效 Public Property KeyHookEnabled() As Boolean Get Return hKeyboardHook <> 0 End Get Set(ByVal value As Boolean) If value Then StartHook(True, False) Else UnHook(True, False) End Set End Property '''鼠標鉤子是否有效 Public Property MouseHookEnabled() As Boolean Get Return hMouseHook <> 0 End Get Set(ByVal value As Boolean) If value Then StartHook(False, True) Else UnHook(False, True) End Set End Property End Class
沒有留言:
張貼留言