2016-10-11 42 views
1

どこにも見つからない可能性があるかどうかわかりません。 私はいくつかのボタンを使ってGUIを作りました。Autoit - 実行回数を制限する

それが可能であれば私は思ったんだけど:

  1. 制限GUI
  2. 制限の開口部の番号ボタン
  3. 制限時間範囲で実行回数の後になるように特定のポイントは、uが

グローバル$それを使用することはできません= "ヘルプ~~"

#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 
を説明

誰でもこれを試しましたか? 強烈なコーディングが必要でしょうか?それはない

+1

このスクリプトが行うことになっているもの手の込んだてもらえますか? 「GUIのオープニング」とはどういう意味ですか?このスクリプトの開始頻度または一度に開始できるスクリプトのインスタンス数 – mrt

答えて

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?私はこのことを願っています

ができます!

ティム

関連する問題