Ooker
Ooker

Reputation: 3032

Why does remapping key interfere with FormatTime?

I have this code:

FormatTime, CurrentYearMonth,, yyyy-MM
MsgBox, %CurrentYearMonth%
f3::Run D:\folders\%CurrentYearMonth%

a::a

Pressing F3 only opens D:\folders, and there is no message pops up. In order to make it work properly, I need to use

#InputLevel 1
FormatTime, CurrentYearMonth,, yyyy-MM
MsgBox, %CurrentYearMonth%
f3::Run D:\folders\%CurrentYearMonth%

#InputLevel 0
a::a

But I don't understand why this should be the case. I read about #InputLevel and SendLevel but I don't understand much. Do you know why?

Upvotes: 1

Views: 56

Answers (1)

jfrmilner
jfrmilner

Reputation: 1778

I suspect your code is after the top auto-execute section of your script, this will mean your F3 hotkey (f3::) will execute only that line and %CurrentYearMonth% will not be populated. You could format your code like this,

f3::
FormatTime, CurrentYearMonth,, yyyy-MM
MsgBox, %CurrentYearMonth%
Run D:\folders\%CurrentYearMonth%
return

F3 will run all the code from f3:: until return. This is easier to read and understand. More details on return - https://www.autohotkey.com/docs/commands/Return.htm

Upvotes: 1

Related Questions