That is, at least, how I would like it to work. In reality, I get two line breaks even if this is my first entry, so instead of getting a result that looks like this:
I get this:
I tried solving it by using GuiControlGet, MyEdit and immediately afterwards checking with if (!MyEdit), so that I could send a different command depending on whether the edit field is empty or not, but it looks like I don't know how to do that properly. Here's the code of that failed attempt:
Code: Select all
#SingleInstance Force
global callStartTime, MyEdit
callStartTime := A_TickCount
WriteNotes:
RunNoteWriter()
Hotkey, IfWinActive, ahk_class AutoHotkeyGUI
Hotkey, Enter, TimeStamp, On
return
TimeStamp:
callElapsedTime := A_TickCount - callStartTime
callElapsedTime := calcCallTime(callElapsedTime)
GuiControlGet, MyEdit
if (!MyEdit)
SendInput, %callElapsedTime%{enter}
else
SendInput, {enter 2}%callElapsedTime%{enter}
return
RunNoteWriter()
{
Gui, new, +Resize +MinSize600x600, Insert notes
Gui, Add, Edit, r2 vMyEdit VScroll
Gui, Show
Return
GuiSize:
If A_EventInfo = 1 ; The window has been minimized. No action needed.
Return
; Otherwise, the window has been resized or maximized. Resize the controls to match.
GuiControl Move, MyEdit, % "H" . (A_GuiHeight-20) . " W" . (A_GuiWidth-20)
Return
}
calcCallTime(ms)
{
year = 2017 ;any year above 1600
year += Floor(ms / 1000), SECONDS
FormatTime, time, %year%, HH:mm:ss
return time
}