-
This repository QuartzGetWindow.jl gives a julia package for obtaining GUI information for macOS users.
- For example we can use
getActiveWindowName()
function to get the name of currently active window. The result should be same as pygetwindow.getActiveWindow - We also provide
getWindowGeometry(title)
function to get a window position and size with a giventitle
. The result should be same as pygetwindow.getWindowGeometry
- For example we can use
-
Note that our pacakge QuartzGetWindow.jl uses CoreGraphics library on macOS. This approach is similar to QuartzImageIO.jl.
You can record an active window during the calculation.
using Dates
using QuartzGetWindow
struct ScreenRecorder
procref::Ref{Base.Process}
end
function ScreenRecorder(proc::Base.Process)
ScreenRecorder(Ref(proc))
end
function start(::Type{ScreenRecorder})
n = getActiveWindowName()
@debug n
x, y, w, h = getWindowGeometry(n)
file = "$(Dates.now()).mov"
inp = Base.PipeEndpoint()
out = Base.PipeEndpoint()
err = Base.PipeEndpoint()
# Run `screencapture` command
cmd = `screencapture -R$(x),$(y),$(w),$(h) -v $(file)`
proc = Base.run(cmd, inp, out, err, wait = false)
recorder = ScreenRecorder(proc)
return recorder
end
function quit(recorder::ScreenRecorder)
# press q key
write(recorder.procref[], "q")
end
function main()
@debug "Start recording..."
sleep(1.0)
recorder = start(ScreenRecorder)
# Do something
sleep(1.0)
println("Count down")
for i = 5:-1:1
println("i=$(i)")
sleep(0.5)
end
println("🚀")
# Stop `screencapture` process
quit(recorder)
@debug "Quit"
exit()
end
main()
You will get the following result:
2024-12-18T16.27.00.633.mov
Somethimes, getActiveWindowName()
gets an unexpected result on Apple M-series. Restarting your macOS device may solve this issue, but I can't figure out why it happens.