Autohotkey 如何将内容提交到GUI编辑框中的.txt文件?
所以我对这个AHK脚本有一个问题,它基本上是一个加密和解密程序。如果你运行这个程序,你需要先输入一个密码,然后才能进入真正的程序。因此,如果你在里面输入一个字符串并进行“编码”,你有没有办法只需一个按钮就可以将“编码”字符串保存到一个.txt文件中 我在网上用Submit找到了一些东西,但我没有真正弄明白。所以我被困在这里了Autohotkey 如何将内容提交到GUI编辑框中的.txt文件?,autohotkey,Autohotkey,所以我对这个AHK脚本有一个问题,它基本上是一个加密和解密程序。如果你运行这个程序,你需要先输入一个密码,然后才能进入真正的程序。因此,如果你在里面输入一个字符串并进行“编码”,你有没有办法只需一个按钮就可以将“编码”字符串保存到一个.txt文件中 我在网上用Submit找到了一些东西,但我没有真正弄明白。所以我被困在这里了 SetBatchLines -1 StringCaseSense Off AutoTrim Off Hotkey, !x, Exit InputBox, pass ,En
SetBatchLines -1
StringCaseSense Off
AutoTrim Off
Hotkey, !x, Exit
InputBox, pass ,Encrypter 1.0, Please enter the Password , HIDE, 190, 140
ifEqual pass, pass, GoSub, key
IfNotEqual, pass, pass, MsgBox , 0, Wrong Password, The password was incorrect please try again or press "ESC" to Exit the Programm
IfNotEqual, pass, pass, Reload
Sleep, 100
;----------------Interface--------------
Gui, 1: Add, Edit, x10 y10 w280 r8 vEncDec
Gui, 1: Font, bold
Gui, 1: Add, Text,, Copy and paste your raw text here to encrypt it.
Gui, 1: Color, d80101
Gui, 1: Add, Button, x10 y150 w75 gENCRYPT, Encode
Gui, 1: Add, Button, x10 y178 w75 gDELETE, Delete
Gui, 1: Add, Button, x110 y150 w75 gDECRYPT, Decode
Gui, 1: Add, Button, x110 y178 w75 gOPEN, Save
Gui, 1: Add, Button, x215 y150 w75 gExit, Exit
Gui, 1: Add, Button, x215 y178 w75 gCREATE, Create
Gui, 1: Show, w300 h208, Encrypter v1.0
Return
;------------------MANAGMENT---------------
DELETE:
MsgBox, 262208, WARNING!, If you delete the .txt all your Saved Passwords will be deleted!
Sleep 500
MsgBox, 262196, WARNING!, Do you really want to delete the .txt?
IfMsgBox Yes
FileDelete, %Temp%\ttcrashes.txt
return
CREATE:
MsgBox, 262208, WARNING!, If you create a new .txt your old .txt file may get deleted!
Sleep 500
MsgBox, 262196, WARNING!, Do you really want to create a new .txt?
IfMsgBox Yes
FileAppend,ENCODED:, %Temp%\ttcrashes.txt
return
OPEN:
Run, %Temp%\ttcrashes.txt
return
;-------------------Key--------------------
key:
k1 := 0x5025124 ;in each of these 5 keys edit the last 10 0s to random numbers so that they are each different and look something like this: 0x1928374659
k2 := 0x0681035170
k3 := 0x9704313523
k4 := 0x0427880892
k5 := 0x8754345242
return
;----------------Exit HK--------------------
Exit:
ExitApp
return
;-----------------------------------------------
;#############################################################################################################
ENCRYPT:
encrypt = 1
decrypt = 0
GoSub, EncryptDecrypt
Return
DECRYPT:
decrypt = 1
encrypt = 0
GoSub, EncryptDecrypt
Return
;#############################################################################################################
EncryptDecrypt:
Gui, 1: Submit, NoHide
i = 9
p = 0
L =
Loop % StrLen(EncDec)
{
i++
If i > 8
{
u := p
v := k5
p++
TEA(u,v, k1,k2,k3,k4)
Stream9(u,v)
i = 0
}
StringMid c, EncDec, A_Index, 1
a := Asc(c)
If a between 32 and 126
{
If encrypt = 1
{
a += s%i%
IfGreater a, 126, SetEnv, a, % a-95
c := Chr(a)
}
If decrypt = 1
{
a -= s%i%
IfLess a, 32, SetEnv, a, % a+95
c := Chr(a)
}
}
L = %L%%c%
}
GuiControl,, EncDec, %L%
Return
;#############################################################################################################
TEA(ByRef y,ByRef z,k0,k1,k2,k3) ; (y,z) = 64-bit I/0 block
{ ; (k0,k1,k2,k3) = 128-bit key
IntFormat = %A_FormatInteger%
SetFormat Integer, D ; needed for decimal indices
s := 0
d := 0x9E3779B9
Loop 32
{
k := "k" . s & 3 ; indexing the key
y := 0xFFFFFFFF & (y + ((z << 4 ^ z >> 5) + z ^ s + %k%))
s := 0xFFFFFFFF & (s + d) ; simulate 32 bit operations
k := "k" . s >> 11 & 3
z := 0xFFFFFFFF & (z + ((y << 4 ^ y >> 5) + y ^ s + %k%))
}
SetFormat Integer, %IntFormat%
y += 0
z += 0 ; Convert to original ineger format
}
Stream9(x,y) ; Convert 2 32-bit words to 9 pad values
{ ; 0 <= s0, s1, ... s8 <= 94
Local z ; makes all s%i% global
s0 := Floor(x*0.000000022118911147) ; 95/2**32
Loop 8
{
z := (y << 25) + (x >> 7) & 0xFFFFFFFF
y := (x << 25) + (y >> 7) & 0xFFFFFFFF
x = %z%
s%A_Index% := Floor(x*0.000000022118911147)
}
}
Esc::
ExitApp
return```
Well my expected result would be that if you press the "Save" Button on the GUI you the "Encoded" string gets saved into the .txt
SetBatchLines-1
StringCasesence关闭
自动旋转关闭
热键!x、 出口
输入框,密码,加密机1.0,请输入密码,隐藏,190,140
如果相等,则传递,GoSub,键
如果noteQual,pass,pass,MsgBox,0,密码不正确,请重试或按“ESC”退出程序
IfNotEqual,通过,通过,重新加载
睡吧,100
;----------------接口--------------
Gui,1:添加、编辑,x10 y10 w280 r8 vEncDec
Gui,1:字体,粗体
Gui,1:Add,Text,,将原始文本复制并粘贴到此处进行加密。
图形用户界面,1:彩色,d80101
Gui,1:Add,按钮,x10 y150 w75 gENCRYPT,编码
Gui,1:添加,按钮,x10 y178 w75 gDELETE,删除
Gui,1:添加,按钮,x110 y150 w75 gDECRYPT,解码
Gui,1:Add,按钮,x110 y178 w75 gOPEN,保存
Gui,1:Add,按钮,x215 y150 w75 gExit,退出
Gui,1:添加,按钮,x215 y178 w75 G创建,创建
Gui,1:Show,w300 h208,加密机v1.0
返回
;------------------管理---------------
删除:
MsgBox,262208,警告!,如果删除.txt文件,所有保存的密码都将被删除!
睡500
MsgBox,262196,警告!,是否确实要删除.txt文件?
IfMsgBox是
文件删除,%Temp%\ttcrasks.txt
返回
创建:
MsgBox,262208,警告!,如果创建一个新的.txt文件,旧的.txt文件可能会被删除!
睡500
MsgBox,262196,警告!,是否确实要创建一个新的.txt文件?
IfMsgBox是
FileAppend,编码:,%Temp%\ttcrasks.txt
返回
开放式:
运行%Temp%\ttcrasks.txt
返回
;-------------------钥匙--------------------
关键:
k1:=0x5025124;在这5个键中的每一个键中,将最后10个0编辑为随机数,使它们各不相同,看起来像这样:0x1928374659
k2:=0x0681035170
k3:=0x9704313523
k4:=0x0427880892
k5:=0x8754345242
返回
;----------------退出香港--------------------
出口:
出口
返回
;-----------------------------------------------
;#############################################################################################################
加密:
加密=1
解密=0
GoSub,加密解密
返回
解密:
解密=1
加密=0
GoSub,加密解密
返回
;#############################################################################################################
加密解密:
Gui,1:提交,NoHide
i=9
p=0
L=
循环%StrLen(EncDec)
{
我++
如果我>8
{
u:=p
v:=k5
p++
茶(u,v,k1,k2,k3,k4)
第9流(u,v)
i=0
}
StringMid c,EncDec,A_指数,1
a:=Asc(c)
如果a介于32和126之间
{
如果encrypt=1
{
a+=s%i%
如果大于a,126,设置环境,a,%a-95
c:=Chr(a)
}
如果decrypt=1
{
a-=s%i%
如果没有a,32,设置环境,a,%a+95
c:=Chr(a)
}
}
L=%L%%c%
}
GuiControl,,EncDec,%L%
返回
;#############################################################################################################
茶(byrefy,byrefz,k0,k1,k2,k3);(y,z)=64位I/0块
{;(k0,k1,k2,k3)=128位密钥
IntFormat=%A\u FormatInteger%
SetFormat Integer,D;十进制索引需要
s:=0
d:=0x9E3779B9
环路32
{
k:=“k”。s&3;索引键
y:=0xFFFFFF&(y+((z>5)+z^s+%k%))
s:=0xFFFFFF&(s+d);模拟32位操作
k:=“k”.s>>11和3
z:=0xFFFFFFFF&(z+((y>5)+y^s+%k%))
}
SetFormat整数,%IntFormat%
y+=0
z+=0;转换为原始ineger格式
}
第9条(x,y);将2个32位字转换为9个焊盘值
{;0 7)&0xFFFFFFFF
x=%z%
s%A_索引%:=楼层(x*0.0000000 22118911147)
}
}
Esc::
出口
返回```
我的预期结果是,如果您按下GUI上的“保存”按钮,“编码”字符串将保存到.txt中
正如Yane所述,正确的语法是FileAppend[,Text,Filename,Encoding]
使用以下选项之一应按预期创建/修改文件
FileAppend,ENCODED: %VariableName%, %Temp%\ttcrashes.txt
或
您已经编写了
FileAppend,ENCODED:,%Temp%\ttcrasks.txt
,这会将实际文本“ENCODED:”添加到文件中。将其更改为FileAppend,%EncDec%,%Temp%\ttcrasks.txt
FileAppend,%VariableName%, %Temp%\ttcrashes.txt