fix(windows): silent default dump on double-click (#591)

This commit is contained in:
Roger
2026-04-27 14:47:59 +08:00
committed by GitHub
parent 5c0b1ad5cf
commit 439ff52b02
6 changed files with 50 additions and 1 deletions
+1
View File
@@ -49,6 +49,7 @@ GitHub: https://github.com/moonD4rk/HackBrowserData`,
}
func main() {
configureDoubleClickMode()
if err := rootCmd().Execute(); err != nil {
os.Exit(1)
}
+5
View File
@@ -0,0 +1,5 @@
//go:build !windows
package main
func configureDoubleClickMode() {}
+21
View File
@@ -0,0 +1,21 @@
//go:build windows
package main
import (
"github.com/inconshreveable/mousetrap"
"github.com/spf13/cobra"
"github.com/moond4rk/hackbrowserdata/utils/winapi"
)
// configureDoubleClickMode hides the console and bypasses cobra's
// double-click guard when launched from Explorer (issue #344).
func configureDoubleClickMode() {
if !mousetrap.StartedByExplorer() {
return
}
cobra.MousetrapHelpText = ""
winapi.HideConsoleWindow()
}
+1 -1
View File
@@ -4,6 +4,7 @@ go 1.20
require (
github.com/godbus/dbus/v5 v5.2.2
github.com/inconshreveable/mousetrap v1.1.0
github.com/moond4rk/binarycookies v1.0.2
github.com/moond4rk/keychainbreaker v0.2.5
github.com/moond4rk/plist v1.2.0
@@ -25,7 +26,6 @@ require (
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/ncruces/go-strftime v0.1.9 // indirect
github.com/otiai10/mint v1.6.3 // indirect
+21
View File
@@ -0,0 +1,21 @@
//go:build windows
package winapi
var (
procGetConsoleWindow = Kernel32.NewProc("GetConsoleWindow")
procShowWindow = User32.NewProc("ShowWindow")
)
const swHide = 0
// HideConsoleWindow hides the console window attached to the current
// process. Returns true if the window was previously visible.
func HideConsoleWindow() bool {
hwnd, _, _ := procGetConsoleWindow.Call()
if hwnd == 0 {
return false
}
prev, _, _ := procShowWindow.Call(hwnd, swHide)
return prev != 0
}
+1
View File
@@ -24,6 +24,7 @@ var (
Kernel32 = windows.NewLazySystemDLL("kernel32.dll")
Ntdll = windows.NewLazySystemDLL("ntdll.dll")
Crypt32 = windows.NewLazySystemDLL("crypt32.dll")
User32 = windows.NewLazySystemDLL("user32.dll")
)
// CallBoolErr wraps the common "r1 == 0 means failure" Win32 convention.