If statement 自动热键一小时不能读取变量

If statement 自动热键一小时不能读取变量,if-statement,variables,autohotkey,If Statement,Variables,Autohotkey,这是我的第一个剧本, 我希望这个脚本从gui中获取变量,然后它将根据变量时间1和时间2的特定时间将CTRL+E发送到特定的windows应用程序 代码只工作到mytimer:(第45行),之后如果语句不工作,则不显示msgbox,问题是什么 谢谢你的帮助 #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. ; #Warn ; Enable warnings to ass

这是我的第一个剧本, 我希望这个脚本从gui中获取变量,然后它将根据变量时间1和时间2的特定时间将CTRL+E发送到特定的windows应用程序

代码只工作到mytimer:(第45行),之后如果语句不工作,则不显示msgbox,问题是什么

谢谢你的帮助

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

#SingleInstance,Force
;Gui Layout
;----------------------
hour:="00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|"
minute:="00||01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59|"
SetTitleMatchMode,  2
SetTitleMatchMode, Fast
;Gui,Add,Text, x10, Timer control for toggle MT4 Auto Trading

Gui,Add,Text, x10, Insert your MT4 account ID :
Gui,Add,Edit, x+10 w100 vmtid
Gui,Add,Text, x10, Choose what time to toggle Auto Trading [on/off]
Gui,Add,Text, x10, Time 1 :
Gui,Add,Text, x10, Hour
Gui,Add,Text, x+50, Minutes 
Gui,Add,DropDownList, x10 w50 r10 vh1,% "16||"hour
Gui,Add,DropDownList, x+10 w50 r10 vm1,% minute

Gui,Add,Text, x10 y+10, Time 2 :
Gui,Add,Text, x10, Hour
Gui,Add,Text, x+50, Minutes 
Gui,Add,DropDownList, x10 w50 r10 vh2,% "22||"hour
Gui,Add,DropDownList, x+10 w50 r10 vm2,% minute

Gui,Add,Button, x10 y+20 w100 h50 gactive, Activate !

Gui, +AlwaysOnTop
Gui, Show, x800 y100 w300 h300, MT4 Auto Trading Timer
return

active:
Gui,Submit, NoHide
    ;MsgBox, Starting, Running Script...
#Persistent
SetTimer, mytimer, 60000
return

mytimer:
Gui, Submit, NoHide
;MsgBox, %h1%:%m1% %mtid%  ;<---only until this is working
if (A_Hour = %h1% && A_Min = %m1%)  ;<from this its not working
{

    MsgBox, wow, it h1 show
    WinActivate, %mtid%
    WinWaitActive, %mtid% 
    Send, ^e
}
if (A_Hour = %h2% && A_Min = %m2%)
{

    ;MsgBox, wow2, it h2
    WinActivate, %mtid% 
    WinWaitActive, %mtid% 
    Send, ^e
}
return


^x::ExitApp
#NoEnv;推荐用于性能和与未来自动热键版本的兼容性。
; #警告;启用警告以帮助检测常见错误。
发送模式输入;由于其优越的速度和可靠性,建议用于新脚本。
SetWorkingDir%A_ScriptDir%;确保起始目录一致。
#单一实例,强制
;图形用户界面布局
;----------------------
时间:=“00 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 | 13 | 14 | 15 | 18 | 19 | 20 | 21 | 22 |”
10日124周四周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日周日| 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 |”
SetTitleMatchMode,2
SetTitleMatch模式,快速
;Gui、添加、文本、x10、用于切换MT4自动交易的计时器控件
Gui,添加,文本,x10,插入您的MT4帐户ID:
Gui,添加,编辑,x+10 w100 vmtid
Gui,添加,文本,x10,选择何时切换自动交易[开/关]
Gui,添加,文本,x10,时间1:
Gui,添加,文本,x10,小时
Gui,添加,文本,x+50,分钟
图形用户界面,添加,下拉列表,x10 w50 r10 vh1,%“16 | |”小时
Gui,添加,下拉列表,x+10 w50 r10 vm1,%min
Gui,添加,文本,x10 y+10,时间2:
Gui,添加,文本,x10,小时
Gui,添加,文本,x+50,分钟
图形用户界面,添加,下拉列表,x10 w50 r10 vh2,%“22 | |”小时
Gui,添加,下拉列表,x+10 w50 r10 vm2,%min
Gui,添加,按钮,x10 y+20 w100 h50激活,激活!
Gui,+始终在顶部
图形用户界面,显示,x800 y100 w300 h300,MT4自动交易计时器
返回
活动:
Gui,提交,NoHide
;MsgBox,正在启动,正在运行脚本。。。
#持久的
设置计时器,我的计时器,60000
返回
我的计时器:
Gui,提交,NoHide

;MsgBox,%h1%:%m1%%mtid% 这是一个常见的错误,使用现代的,更好的,应该使用的地方

在表达式中,当您在
()
中时,您所做的就是在表达式中,您不使用引用变量的遗留方法(将它们包装在
%%
中)。您只需键入变量的名称。
因此,您的if语句应该如下所示:
if(小时=h1和分钟=m1)

您之前所做的,以及这里的另一个答案所做的(将变量包装在表达式语句中的
%%
),基本上是引用一个指向变量的指针。
但是,当指针不存在时,最终结果只是

(%A_h%=%h1%&&%A_Min%=%m1%)

计算结果为
(“”=“”&&&&&&(“”)

这总是正确的(假设指针不存在)
这可能是一个糟糕的解释,很难解释,但关键是,永远不要将变量包装在表达式中的
%%

总的来说,我建议不要使用遗留语法。现在已经不是2008年了。
我在上面链接了两次的文档页面是开始理解差异的一个很好的参考