your first window
the whole runnable thing, from ahk and from c++
pick a door
| you are writing | you get | status |
|---|---|---|
| stock ahk v2 | Kit, over window.abi.dll | ready |
| c++ | window.core directly, raii, no marshalling | ready |
| finns ahk build | a built-in class, no dll at all | not built yet, it is P1.34 |
from ahk
#Requires AutoHotkey v2.0
#Include %A_ScriptDir%\Kit.ahk
root := Kit.Blank()
root.Theme(Kit.Theme())
label := Kit.Label("kit, the ahk wrapper")
label.SetBounds(24, 20, 300, 20)
ok := Kit.Button("ok", Kit.Btn.Primary)
ok.SetBounds(24, 56, 90, 32)
ok.OnClick(_ctrl => MsgBox("clicked"))
root.Add(label).Add(ok)
app := Kit.Window("kit demo", 380, 210)
app.Root(root).Show()three things worth knowing before you change anything
Showstarts the pump, aSetTimerthat drains the event queue. your script keeps its own thread, its hotkeys and every gui it already had- a fresh window is chromed and opaque, i.e. a real resizable app window. pass an options object for anything else
- bounds set by hand are a choice, not a workaround, since P1.42 the tree measures itself, so a flow places a fresh label at its real width
ahk/demo.ahk is this script with a working click counter, and ahk/demo-flow.ahk is the same window with
every bound taken out
from c++
the step by step lives in the c++ tutorials, five short pages from an empty folder to shapes and text. this is the shape of it at a glance
gui::host_desc_t desc; // title, logical size, x/y, always_on_top, kind, present
desc.kind = gui::host_kind_t::chromed;
desc.present = gui::present_kind_t::opaque; // chromed plus the default layered is refused
gui::host_t host;
host.create(desc);
host.set_paint([](gui::renderer_t& _r, gui::sizei_t _size) { /* draw */ });
host.show(true);
gui::run(host); // or pump_once(host) from a loop of your ownupdate()draws one frame, and only if something asked for onepaint()is the forced full frame, written as an invalidate plus an update so it cannot drift away from a dirty one- coordinates are logical px. the host pushes the dpi scale as a transform for the frame, so a 150% monitor takes care of itself
next
| you want | go to |
|---|---|
| to draw something, one step at a time | the tutorials |
the whole Kit surface | the ahk side |
| the c++ api, per header | the c++ api |
| what each control does | widgets |
| it drew the wrong thing | the backend |