Reverted
This commit is contained in:
@@ -13,7 +13,9 @@ extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpsz
|
|||||||
extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount)
|
extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount)
|
||||||
|
|
||||||
[<DllImport("user32.dll", SetLastError = true)>]
|
[<DllImport("user32.dll", SetLastError = true)>]
|
||||||
extern uint GetWindowThreadProcessId(IntPtr hWnd, uint& lpdwProcessId)
|
extern bool PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam)
|
||||||
|
|
||||||
|
let WM_CLOSE = 0x0010u
|
||||||
|
|
||||||
let getClassName (hWnd: IntPtr) =
|
let getClassName (hWnd: IntPtr) =
|
||||||
let sb = StringBuilder(256)
|
let sb = StringBuilder(256)
|
||||||
@@ -22,62 +24,23 @@ let getClassName (hWnd: IntPtr) =
|
|||||||
else
|
else
|
||||||
""
|
""
|
||||||
|
|
||||||
let getProcessIdFromWindow (hWnd: IntPtr) =
|
|
||||||
let mutable processId = 0u
|
|
||||||
GetWindowThreadProcessId(hWnd, &processId) |> ignore
|
|
||||||
int processId
|
|
||||||
|
|
||||||
let killTuneBlade () =
|
|
||||||
try
|
|
||||||
let processes = Process.GetProcessesByName("TuneBlade")
|
|
||||||
for proc in processes do
|
|
||||||
printfn "Killing TuneBlade process (PID: %d)..." proc.Id
|
|
||||||
proc.Kill()
|
|
||||||
proc.WaitForExit(5000) |> ignore
|
|
||||||
processes.Length > 0
|
|
||||||
with
|
|
||||||
| ex ->
|
|
||||||
printfn "Error killing TuneBlade: %s" ex.Message
|
|
||||||
false
|
|
||||||
|
|
||||||
let startTuneBlade (exePath: string) =
|
|
||||||
try
|
|
||||||
printfn "Starting TuneBlade from: %s" exePath
|
|
||||||
Process.Start(exePath) |> ignore
|
|
||||||
true
|
|
||||||
with
|
|
||||||
| ex ->
|
|
||||||
printfn "Error starting TuneBlade: %s" ex.Message
|
|
||||||
false
|
|
||||||
|
|
||||||
[<EntryPoint>]
|
[<EntryPoint>]
|
||||||
let main _ =
|
let main _ =
|
||||||
let tuneBladeExe = @"C:\Program Files (x86)\TuneBlade\TuneBlade\TuneBlade.exe"
|
printfn "Running TuneBlade error suppressor..."
|
||||||
|
|
||||||
printfn "TuneBlade Suppressor"
|
|
||||||
printfn "Monitoring for errors and restarting from: %s" tuneBladeExe
|
|
||||||
printfn "Press Ctrl+C to exit"
|
|
||||||
printfn ""
|
|
||||||
|
|
||||||
while true do
|
while true do
|
||||||
let hwnd = FindWindow(null, "TuneBlade")
|
let hwnd = FindWindow(null, "TuneBlade")
|
||||||
|
|
||||||
if hwnd <> IntPtr.Zero then
|
if hwnd <> IntPtr.Zero then
|
||||||
let cls = getClassName hwnd
|
let cls = getClassName hwnd
|
||||||
if cls = "#32770" then
|
if cls = "#32770" then
|
||||||
printfn "TuneBlade error dialog detected - restarting application..."
|
printfn "TuneBlade error dialog detected — closing."
|
||||||
if killTuneBlade() then
|
PostMessage(hwnd, WM_CLOSE, IntPtr.Zero, IntPtr.Zero) |> ignore
|
||||||
System.Threading.Thread.Sleep(1000)
|
|
||||||
startTuneBlade tuneBladeExe |> ignore
|
|
||||||
System.Threading.Thread.Sleep(3000)
|
|
||||||
|
|
||||||
let child = FindWindowEx(IntPtr.Zero, IntPtr.Zero, "#32770", "TuneBlade")
|
let mutable child = FindWindowEx(IntPtr.Zero, IntPtr.Zero, "#32770", "TuneBlade")
|
||||||
if child <> IntPtr.Zero then
|
while child <> IntPtr.Zero do
|
||||||
printfn "TuneBlade dialog window detected — restarting application..."
|
printfn "Closing TuneBlade dialog window..."
|
||||||
if killTuneBlade() then
|
PostMessage(child, WM_CLOSE, IntPtr.Zero, IntPtr.Zero) |> ignore
|
||||||
System.Threading.Thread.Sleep(1000)
|
child <- FindWindowEx(IntPtr.Zero, child, "#32770", "TuneBlade")
|
||||||
startTuneBlade tuneBladeExe |> ignore
|
|
||||||
System.Threading.Thread.Sleep(3000)
|
|
||||||
|
|
||||||
System.Threading.Thread.Sleep(2000)
|
System.Threading.Thread.Sleep(2000)
|
||||||
0
|
0
|
||||||
Reference in New Issue
Block a user