Sorry, I still can’t figure out how to fix your code. Have you tried implementing this in another language?
Anyway, I extracted an example from my code:
const WM_CLOSE = 0x000010
function findwindowex(class::AbstractString, child::Ptr{Int32})
hwnd = ccall((:FindWindowExA, "user32"), Ptr{Int32},
(Ptr{Int32}, Ptr{Int32}, Cstring, Cstring),
Ptr{Int32}(), child, class, C_NULL)
return hwnd
end
function sendmessage(hwnd::Ptr{Int32}, msg::UInt32, wparam::Ptr{Int32}, lparam::Ptr{Int32})
ccall((:SendMessageA, "user32"), Int32,
(Ptr{Int32}, UInt32, Ptr{Int32}, Ptr{Int32}),
hwnd, msg, wparam, lparam)
end
function main()
hwnd = findwindowex("Notepad", Ptr{Int32}())
sendmessage(hwnd, WM_CLOSE, Ptr{Int32}(), Ptr{Int32}())
end
This should close Notepad.