#Include <Misc.au3>
#Include <File.au3>
#Include <Array.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
Dim $PassWord , $PassWord2 , $DimPas , $DimPas2[10]
Dim $fCount[10] = ["0","1","2","3","4","5","6","7","8","9"]
If $CmdLine[0] <> 0 Then
If $CmdLine[1] = "/adds" Then
$GuiAS = GUICreate("请输入密码",520,270,-1,-1,$WS_POPUP)
GUISetState(@SW_SHOW)
$Group1 = GUICtrlCreateGroup("",5,20,510,240)
$Group2 = GUICtrlCreateGroup("",500,0,16,21)
$Group3 = GUICtrlCreateGroup("",482,0,16,21)
$Lable1 = GUICtrlCreateLabel("×",502,7,12,12)
$Lable2 = GUICtrlCreateLabel("——",484,7,12,12)
$Lable3 = GUICtrlCreateLabel("Drunk文档加密程序",9,8,105,13)
$Lable4 = GUICtrlCreateLabel("请输入密码:",110,60,80,13)
$Lable5 = GUICtrlCreateLabel("请确认密码:",110,130,80,13)
$Input1 = GUICtrlCreateInput("",110,80,300,20,$ES_PASSWORD)
$Input2 = GUICtrlCreateInput("",110,150,300,20,$ES_PASSWORD)
$Button1 = GUICtrlCreateButton("确 定",110,200,85,20,$BS_CENTER)
$Button2 = GUICtrlCreateButton("取 消",323,200,85,20,$BS_CENTER)
GUISetBkColor(0xF5F5F5,$GuiAS)
While 1
$msg = GUIGetMsg($GuiAS)
$Cur = GUIGetCursorInfo($GuiAS)
Select
Case $msg = $gui_event_close
Exit
Case $msg = $Button1
adds()
Case $msg = $Button2
Exit
Case $Cur[4] = $Lable1
GUICtrlSetCursor($Lable1,0)
If $Cur[2] = 1 Then Exit
Case $Cur[4] = $Lable2
GUICtrlSetCursor($Lable2,0)
If $Cur[2] = 1 Then GUISetState(@SW_MINIMIZE,$GuiAS)
Case $Cur[4] <> $Lable1
If $Cur[3] = 1 Then
If WinActive("请输入密码") Then
Dim $PosDiff[2]
$MousePos = MouseGetPos()
$WinPos = WinGetPos($GuiAS, "")
$PosDiff[0] = $WinPos[0] - $MousePos[0]
$PosDiff[1] = $WinPos[1] - $MousePos[1]
While _IsPressed("02", DllOpen("user32.dll"))
$MousePos = MouseGetPos()
WinMove($GuiAS, "", $MousePos[0] + $PosDiff[0], $MousePos[1] + $PosDiff[1])
WEnd
EndIf
EndIf
EndSelect
WEnd
EndIf
EndIf
Func adds()
$PassWord = GUICtrlRead($Input1)
$PassWord2 = GUICtrlRead($Input2)
If $PassWord <> $PassWord2 Then
MsgBox(16,"错误!","两次密码输入不一致,请重新输入!",5,$GuiAS)
GUICtrlSetData($Input1,"")
GUICtrlSetData($Input2,"")
Else
For $i = 0 To 9
$DimPas = Random(1,31,1)
$DimPas2[$i] = ChrW($DimPas)
Next
$DimPass = _ArrayToString($DimPas2,"")
_FileWriteToLine(@WorkingDir&"\test.drunk",1,$DimPass)
EndIf
EndFunc
我是要获取@WorkingDir&"\test.drunk"的完整路径。我这里是测试效果才指定到文件,而如果我换个“.drunk”的文件的话写入数据还是到这同一个文件了,我的意思是将上述指定文件换成变量。而我不会表示那个变量。至于关联文件我已经手动设置关联了