Some time ago i have been looking at this but gave up beyond simple input edit because it is so much work to get even simple editing like caret position indication!
This is a simple input window concept i was working on:
#SingleInstance, Force
#NoEnv
SetBatchLines, -1
; Uncomment if Gdip.ahk is not in your standard library
;#Include, Gdip.ahk
; Start gdi+
If !pToken := Gdip_Startup()
{
MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
ExitApp
}
OnExit, Exit
w=300
h=100
Gui, 1: -Caption +E0x80000 +LastFound +OwnDialogs +Owner +alwaysontop
Gui, 1: Show, NA x0 y0
gui +lastfound
hwnd := WinExist()
hbm := CreateDIBSection(w,h)
hdc := CreateCompatibleDC()
obm := SelectObject(hdc, hbm)
G := Gdip_GraphicsFromHDC(hdc)
font =arial
If !hFamily := Gdip_FontFamilyCreate(Font)
{
MsgBox, Font error! exit app!
exitapp
}
Gdip_SetCompositingMode(G, 1)
pBrush:=Gdip_BrushCreateSolid(0xDE000000)
pBrush1:=Gdip_BrushCreateSolid(0x50000000)
Gdip_FillRectangle(G, pBrush, 0, 0, w, h)
Gdip_SetCompositingMode(G, 1)
Gdip_FillRectangle(G, pBrush1, 50, 20, 200, 20)
Gdip_SetCompositingMode(G, 0)
Options = x50 y19 w200 cff000000 Left r4 s14
rc:=Gdip_TextToGraphics(G, "press F4 to edit enter to quit", Options, font)
UpdateLayeredWindow(hwnd, hdc,0,0,w,h)
WinMove, ahk_id %hwnd%,,300,300
OnMessage(0x201, "WM_LBUTTONDOWN")
Return
f4::
gosub update
gosub edit
return
edit:
hotkey,Backspace,on
loop
{
Input, SingleKey, L1
if (singlekey="`n")
break
a .=singlekey
tooltip %a%
gosub update
}
hotkey,Backspace,off
return
update:
Gdip_SetClipRect(G, 50, 20, 200, 20)
Gdip_SetCompositingMode(G, 1)
Gdip_FillRectangle(G, pBrush1, 0, 0, w,h)
Gdip_ResetClip(G)
display_text:= a
Gdip_SetCompositingMode(G, 0)
Options = x50 y19 w200 cff000000 Left r4 s14
rc:=Gdip_TextToGraphics(G, display_text, Options, font)
UpdateLayeredWindow(hwnd, hdc)
return
!v::listvars
~Backspace::
stringtrimright,a,a,1
gosub update
return
WM_LBUTTONDOWN()
{
PostMessage, 0xA1, 2
}
esc::
Exit:
Gdip_DeleteBrush(pBrush)
Gdip_DeleteBrush(pBrush1)
SelectObject(hdc, obm)
DeleteObject(hbm)
DeleteDC(hdc)
Gdip_DeleteGraphics(G)
Gdip_Shutdown(pToken)
ExitApp
Return