我不知道它是否可能因为我无法找到任何地方。 我创建了一个带有一些按钮的GUI来启动。
我只是想知道是否可以:
全球$ explain ="帮助~~"
#include <IE.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $explain = "hmmm"
Global $Form1 = GUICreate("Yay", 328, 157)
Global $Label1 = GUICtrlCreateLabel("ID", 12, 14, 67, 20)
Global $Label2 = GUICtrlCreateLabel("Password", 12, 44, 67, 20)
Global $Label3 = GUICtrlCreateLabel("hello world", 225, 14, 90, 20)
Global $Input1 = GUICtrlCreateInput("", 76, 10, 105, 24)
Global $Input2 = GUICtrlCreateInput("", 76, 40, 105, 24, BitOR($ES_PASSWORD, $ES_AUTOHSCROLL))
Global $Input3 = GUICtrlCreateInput("", 228, 40, 70, 24)
Global $Button1 = GUICtrlCreateButton("Log In", 76, 69, 105, 30)
Global $Button2 = GUICtrlCreateButton("Connect", 212, 69, 100, 30)
Global $Checkbox1 = GUICtrlCreateCheckbox("hmm", 240, 113, 97, 17)
Global $Checkbox2 = GUICtrlCreateCheckbox("hmm2", 240, 134, 97, 17)
Global $Group1 = GUICtrlCreateGroup("", 5, -5, 190, 110)
Global $Edit1 = GUICtrlCreateEdit("", 5, 110, 228, 100)
GUICtrlSetData(-1, $explain)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Checkbox1
If (GUICtrlRead($Checkbox1) = $GUI_CHECKED) Then
Global $hmm = 1
EndIf
Case $Checkbox2
If (GUICtrlRead($Checkbox2) = $GUI_CHECKED) Then
Global $hmm2 = 0
EndIf
Case $Button1
Global $id = GUICtrlRead($Input1)
Global $pass = GUICtrlRead($Input2)
WinSetState("Yay", "", @SW_MINIMIZE)
MsgBox(0,"","possible to limit #of Execution?")
Case $Button2
Global $exnum = GUICtrlRead($Input3)
WinSetState("Yay", "", @SW_MINIMIZE)
MsgBox(0,"","time limit would be nice too! thnx!")
EndSwitch
WEnd
有人试过吗? 它需要密集编码吗? 如果不是太糟糕,你能提供样品
答案 0 :(得分:0)
下午好,皮塔,
烨!这绝对是可能的!有多种方法可以这样做,我会试着说一些。
管理这些请求的一个好方法是创建一个属性文件来管理所有内容。看看我下面的例子吧!
Global $explain = "help~~"
#include <IE.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
; =================================================================================================================================================
#include <File.au3>
#Include <Date.au3>
; This is the directory that the temporary file will be stored.
$fileHandle = @AppDataDir & "\TestProgram\properties.txt"
; Checks to see if the properties file exists
if FileExists($fileHandle) Then
; START Check Run Limit
; Reads the first value in the properties file. In this example, it's the limit to how many times the program can be launched.
$runLimit = FileReadLine($fileHandle, 1)
; MsgBox(0,"Run Limit", $runLimit)
; If the run limit reaches zero (or less than by some glitch), do not launch the program.
if $runLimit <= 0 Then
MsgBox(16,"Run Limit Reached", "You have reached the maximum number of launches for this program!")
Exit
EndIf
; Subtract one from the launch limit.
$newLimit = $runLimit - 1
MsgBox(0,"New Run Limit", "You may launch this program " & $newLimit & " more times!", 3)
; Update the properties file.
_FileWriteToLine($fileHandle, 1, $newLimit, True)
; END Check Run Limit
; Start CHECK Expiration Date
$expDate = FileReadLine($fileHandle, 2)
; MsgBox(0,"Expiration Date", "This program expires on " & $expDate)
; Check to see if the expiration date has already passed
if $expDate < _NowDate() Then
MsgBox(16,"Program Expired","Your trial period has expired!")
Exit
EndIf
; END Check expiration date
Else
; If the file does not exists, create it and set it up
$propFile = FileOpen($fileHandle, 10)
; Sets the launch limit to 10. Change this value to set the launch limit
FileWrite($fileHandle, "10" & @CRLF)
; Sets the expiration date to a week (7 days) from the initial launch date.
FileWrite($fileHandle, @MON & "/" & (@MDAY + 7) & "/" & @YEAR & @CRLF)
; Sets the button limit for the login button to 3.
FileWrite($fileHandle, "3" & @CRLF)
FileClose($fileHandle)
#CS
NOTE: THIS IS JUST FOR DEMONSTRATION PURPOSES! THE USER CAN SIMPLY DELETE THE PROPERTIES FILE
IN ORDER TO RESET THE VALUES AND CONTINUE USING THE PROGRAM. THIS WAS DESIGNED SIMPLY TO
GET YOU ON THE RIGHT TRACK.
#CE
EndIf
; =================================================================================================================================================
Global $explain = "hmmm"
Global $Form1 = GUICreate("Yay", 328, 157)
Global $Label1 = GUICtrlCreateLabel("ID", 12, 14, 67, 20)
Global $Label2 = GUICtrlCreateLabel("Password", 12, 44, 67, 20)
Global $Label3 = GUICtrlCreateLabel("hello world", 225, 14, 90, 20)
Global $Input1 = GUICtrlCreateInput("", 76, 10, 105, 24)
Global $Input2 = GUICtrlCreateInput("", 76, 40, 105, 24, BitOR($ES_PASSWORD, $ES_AUTOHSCROLL))
Global $Input3 = GUICtrlCreateInput("", 228, 40, 70, 24)
Global $Button1 = GUICtrlCreateButton("Log In", 76, 69, 105, 30)
Global $Button2 = GUICtrlCreateButton("Connect", 212, 69, 100, 30)
Global $Checkbox1 = GUICtrlCreateCheckbox("hmm", 240, 113, 97, 17)
Global $Checkbox2 = GUICtrlCreateCheckbox("hmm2", 240, 134, 97, 17)
Global $Group1 = GUICtrlCreateGroup("", 5, -5, 190, 110)
Global $Edit1 = GUICtrlCreateEdit("", 5, 110, 228, 100)
GUICtrlSetData(-1, $explain)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Checkbox1
If (GUICtrlRead($Checkbox1) = $GUI_CHECKED) Then
Global $hmm = 1
EndIf
Case $Checkbox2
If (GUICtrlRead($Checkbox2) = $GUI_CHECKED) Then
Global $hmm2 = 0
EndIf
Case $Button1
; START Button Limit ================================================================================================================
if FileExists($fileHandle) Then
$buttonLimit = FileReadLine($fileHandle, 3)
if $buttonLimit <= 0 Then
MsgBox(16,"Button Limit Reached", "You have reached the maximum number of times you can hit this button!")
ELSE
$newButtonLimit = $buttonLimit - 1
MsgBox(0,"New Run Limit", "You may press this button " & $newButtonLimit & " more times!", 3)
_FileWriteToLine($fileHandle, 3, $newButtonLimit, True)
; START OLD CODE
Global $id = GUICtrlRead($Input1)
Global $pass = GUICtrlRead($Input2)
; WinSetState("Yay", "", @SW_MINIMIZE)
MsgBox(0,"","possible to limit #of Execution?")
; END OLD CODE ================================================================================================================
EndIf
EndIf
; END Button Limit
Case $Button2
Global $exnum = GUICtrlRead($Input3)
WinSetState("Yay", "", @SW_MINIMIZE)
MsgBox(0,"","time limit would be nice too! thnx!")
EndSwitch
WEnd
启动程序后,会生成属性文件并将其存储在用户计算机上的appdata中。
在Windows上:按Win + R并键入%appdata%。如果您将示例保持不变,则会有一个名为“TestProgram”的文件夹,如果您更改了名称,它将是您所谓的任何名称。在这个文件夹里面,会有properties.txt文件(同样,除非你改了名字)。
我在示例代码中做了一些评论,以帮助解释我所做的事情,但我在解释事情方面并不是很棒,所以如果您需要更多帮助,请告诉我。
P.S。如果你确实使用这种方法,我强烈建议加密(可能使用Crypt?)属性文件,使其更不易编辑,并设计一些方法来判断用户是否删除了文件。
我希望这有帮助!,
添