gpt4 book ai didi

expression - Autohotkey 单行代码?

转载 作者:行者123 更新时间:2023-12-04 00:04:09 26 4
gpt4 key购买 nike

我有一个简单的问题,我无法通过搜索互联网找到答案。
如何将我的行合并为一行(单行)?

例如这是一个工作代码

right:: 
Send, ^s
Reload
Send, hello world

这不是

right::Send, ^s::Reload::Send, hello world

最佳答案

在 Autohotkey 中,您不能将换行符用于单个代码行。

但是如果你想把几行变成一行(单行)。

你可以试试这个,

1 - 将其放入字符串中。

2 - 转换它 + 将它保存到一个文件。

3 - 然后从外部文件运行脚本。

注意 - 我确实制作了脚本,所以你确实想要它,保存它 + ?Reload=run example1.ahk + 发送文本(它不能准确工作所以你喜欢它,但它几乎是。它是我不清楚你为什么要重新加载脚本?)

试试这段代码。

例子1.ahk

; [+ = Shift] [! = Alt] [^ = Ctrl] [# = Win] 
#SingleInstance force
sleep 100
return

right:: ConvertAndRun("Sendinput, ^s | run example1.ahk | runwait example1.ahk | Send, hello world")
left:: ConvertAndRun("Sendinput, ^s | run example1.ahk | runwait example1.ahk | Send, it works")
~esc::exitapp

ConvertAndRun(y)
{
FileDelete, Runscript.ahk
;1 - Convert the String in single codeline's with return - Character | is the breakline.
StringReplace,y,y, |, `n, all
sleep 150

;2 - Save the String to a file
x:="#notrayicon `n "
z:="`n "
FileAppend, %x%%y%%z%, Runscript.ahk
sleep 150

;3 - Now it can Run all the commands from that string.
run Runscript.ahk
sleep 150
exitapp
}
;

注意 - 此脚本确实将字符串保存到一个文件(在硬盘 c: 上),速度不是那么快,但是如果您使用 Ramdisk ,然后您可以从那里保存并运行文件,它会提高速度 - Ramdisk 是一个虚拟磁盘(存储在 RAM MEMORY z:) 并且比硬盘快 +-100 倍。 - 你可以从这里找到这个免费工具 ( Imdisk )

关于expression - Autohotkey 单行代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48274128/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com