AHK可以动态设置变量吗?

Post a reply


In an effort to prevent automatic submissions, we require that you complete the following challenge.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :| :mrgreen: :geek: :ugeek: :arrow: :angel: :clap: :crazy: :eh: :lolno: :problem: :shh: :shifty: :sick: :silent: :think: :thumbup: :thumbdown: :salute: :wave: :wtf: :yawn: :facepalm: :bravo: :dance: :beard: :morebeard: :xmas: :HeHe: :trollface: :cookie: :rainbow: :monkeysee: :monkeysay: :happybday: :headwall: :offtopic: :superhappy: :terms: :beer:
View more smilies

BBCode is ON
[img] is OFF
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: AHK可以动态设置变量吗?

Re: AHK可以动态设置变量吗?

Post by garry » 24 Jan 2024, 08:51

array example

Code: Select all

#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.
;-------------------------------
e=
(Ltrim join`r`n
https://www.youtube.com/watch?v=iR0w0mWB3uA - 李香蘭 Li Xiang Lan 1920 - 2014
https://www.youtube.com/watch?v=NklP8BDourg - Suo Luo He Zhi Lian
https://www.youtube.com/watch?v=EFSZnC3-E4A - Lilian de Celis - El Relicario
https://www.youtube.com/watch?v=Fs8cYa1Z2Tk - 春風吻上我的臉 - 姚莉 / 鍾情
)
Arr:=StrSplit(e,"`n")
tot:=arr.maxindex(),a1:=arr[1],a2:=arr[2],a3:=arr[3],a4:=arr[4]
msgbox,Total=%tot%`n%a1%`n%a2%`n%a3%`n%a4%`n`nRun A4= > 春風吻上我的臉 - 姚莉 / 鍾情
try,
 run,%a4%
return
;=======================================================

AHK可以动态设置变量吗?

Post by wyj304 » 22 Jan 2024, 03:29

比如变量a的值是字符串"Array1",怎么据此定义一个数组【Array1】?
a := "Array1"
【Array1】 := []
================================================================
上面的提问是没有意义的,只是因为我对控件的命名和引用没理解。
快速参考有提到:V: 设置控件的名称. 在字母 V 后指定一个名称, V 不包含在名称中. 例如, 指定 vMyEdit 会将控件命名为 "MyEdit".
可以用MyGui["MyEdit"]来引用该控件,这样是可以用表达式来命名不同的控件,之前我只知道MyEdit:=MyGui.Add("Edit")这种写法,然后用固定的名称"MyEdit"来引用该控件。

Top