Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
User interface 为什么GUI在循环中重生?_User Interface_Autohotkey - Fatal编程技术网

User interface 为什么GUI在循环中重生?

User interface 为什么GUI在循环中重生?,user-interface,autohotkey,User Interface,Autohotkey,继我的小型(也是第一个)自动热键GUI之后,我无法理解为什么在销毁后窗口会重新启动: Call: { ; the "phonebook" book := {"Tel Maison": "8912", "Tel Mobile": "000000"} nr := book[A_GuiControl] ; getting rid of the chooser window Gui, 1:Destroy ; raises the IP phone ; dials the number ; right

继我的小型(也是第一个)自动热键GUI之后,我无法理解为什么在
销毁后窗口会重新启动:

Call:
{
; the "phonebook"
book := {"Tel Maison": "8912", "Tel Mobile": "000000"}
nr := book[A_GuiControl]
; getting rid of the chooser window
Gui, 1:Destroy
; raises the IP phone
; dials the number  
; right now just a debug message 
MsgBox number: %nr%
}   

CapsLock::
Gui, 1:font, cBlue s20 bold, Verdana
Gui, 1:Add, Button, gCall, Tel Maison
Gui, 1:Add, Button, gCall, Tel Mobile
GUI, 1:-Border -SysMenu -Caption
Gui, 1:Show
我的理解是,该窗口在
CapsLock
之后和
Show
之后创建一次。调用
Call
时,1:Destroy
应关闭选择器(带有两个按钮的窗口)。直到下一个
CapsLock
事件

实际发生的情况:

  • 调用
    调用
    例程
  • 选择器(GUI窗口)消失
  • 此时会出现
    MsgBox
  • 单击
    OK
    后,选择器重新出现

为什么不去掉花括号并使用正常的
子语法?我认为你把
函数
sub
语法弄混了

Call:
    ;do stuff
Return
或使用函数语法:

Call(){
    ;global    ;uncomment this if you need all the vars global
    ;do stuff
}
您还应在
capslock
作业后添加
return

CapsLock::
    Gui, 1:font, cBlue s20 bold, Verdana
    Gui, 1:Add, Button, gCall, Tel Maison
    Gui, 1:Add, Button, gCall, Tel Mobile
    GUI, 1:-Border -SysMenu -Caption
    Gui, 1:Show
RETURN
我想这是你的问题。如果不关闭
调用
子块(括号不会关闭
子块
),GUI将自动加载

另外,我认为另一个问题是,每次您推capslock时,它都会创建另一个GUI。您可能想先删除旧的并重建它,或者使其可重用,然后隐藏并显示它

重建它很容易:

Gui, 1:new   ;this will cause your window to be rebuilt.
gui, 1:font, cBlue s20 bold, Verdana

这是你的全部剧本吗?是的,我将它添加到autohotkey.ahk(从内存中-我不在办公桌上,但这是默认脚本)。还有几行,修改了一些键。谢谢-我不知道sub-vs函数(这些文档不是我见过的最好的一个),你最好看看其他的例子。查看DonationCoder-Skrommel有大约150个用autohotkey编写的简洁的小程序-您可以下载exe和源ahk文件。这些都是学习和了解autohotkey可以做什么(并且很容易做到)的好工具!