46 lines
1.6 KiB
Forth
46 lines
1.6 KiB
Forth
open System
|
|
open System.Diagnostics
|
|
open System.Runtime.InteropServices
|
|
open System.Text
|
|
|
|
[<DllImport("user32.dll", SetLastError = true)>]
|
|
extern IntPtr FindWindow(string lpClassName, string lpWindowName)
|
|
|
|
[<DllImport("user32.dll", SetLastError = true)>]
|
|
extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow)
|
|
|
|
[<DllImport("user32.dll", SetLastError = true)>]
|
|
extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount)
|
|
|
|
[<DllImport("user32.dll", SetLastError = true)>]
|
|
extern bool PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam)
|
|
|
|
let WM_CLOSE = 0x0010u
|
|
|
|
let getClassName (hWnd: IntPtr) =
|
|
let sb = StringBuilder(256)
|
|
if GetClassName(hWnd, sb, sb.Capacity) > 0 then
|
|
sb.ToString()
|
|
else
|
|
""
|
|
|
|
[<EntryPoint>]
|
|
let main _ =
|
|
printfn "Running TuneBlade error suppressor..."
|
|
while true do
|
|
let hwnd = FindWindow(null, "TuneBlade")
|
|
|
|
if hwnd <> IntPtr.Zero then
|
|
let cls = getClassName hwnd
|
|
if cls = "#32770" then
|
|
printfn "TuneBlade error dialog detected — closing."
|
|
PostMessage(hwnd, WM_CLOSE, IntPtr.Zero, IntPtr.Zero) |> ignore
|
|
|
|
let mutable child = FindWindowEx(IntPtr.Zero, IntPtr.Zero, "#32770", "TuneBlade")
|
|
while child <> IntPtr.Zero do
|
|
printfn "Closing TuneBlade dialog window..."
|
|
PostMessage(child, WM_CLOSE, IntPtr.Zero, IntPtr.Zero) |> ignore
|
|
child <- FindWindowEx(IntPtr.Zero, child, "#32770", "TuneBlade")
|
|
|
|
System.Threading.Thread.Sleep(2000)
|
|
0 |