从GUI粘贴AutoHotKey符号的问题

问题描述 投票:0回答:1

我是AHK的新手,我想做一个脚本,打开一个GUI,里面有一个常用符号的简短列表,可以选择,然后自动粘贴。

到目前为止,我的代码。

!+q::
Gui, Add, ListBox, w100 h100, vSymbolChoice, ™|©|°|π|☭|☢|⚠|ツ|•|Ω
Gui, Add, Button, Default, Submit 
Gui, Add, Button, default, Cancel
Gui, Show
return 

ButtonSubmit:
Gui, Submit
Sleep, 1000
Send, %SymbolChoice%
Gui, Destroy

ButtonCancel: 
Gui, Destroy

它创建了GUI和... ListBox 但当我选择好并按下提交键时,却没有粘贴符号。

另外,有没有更好的方法来检测一个文本字段是否被选中,而不是仅仅等待一秒钟,希望用户在这段时间内选择了这个字段?

autohotkey
1个回答
1
投票
; auto-execute section
; create and show the Gui
Gui, Add, ListBox, w100 h130 vSymbolChoice, ™|©|°|π|☭|☢|⚠|ツ|•|Ω
Gui, Add, Button, Default, Submit
Gui, Add, Button,, Hide ; you can't have two default buttons on a Gui
Gui, Show
return

; Press Alt+Shift+Q to show the hidden Gui after ButtonSubmit or ButtonHide
!+q:: Gui, Show 

ButtonSubmit:
GuiControlGet, SymbolChoice ; get the control's contents stored in the variable SymbolChoice (retrieves the ListBox's current selection)
Gui, Submit ; saves the contents of this control to its associated variable SymbolChoice
SendInput, %SymbolChoice%
return

; Hide the Gui
ButtonHide: 
Gui, hide
return

; Press ESC or close the Gui to terminate the script
GuiClose:
Esc:: ExitApp

详细内容请看 人机界面 在文件中。

© www.soinside.com 2019 - 2024. All rights reserved.