AutoIt中的变量在未声明的情况下使用

时间:2014-07-10 21:01:02

标签: windows variables windows-7 autoit

这是我的完整代码:

$hGUI0 = GUICreate('GUI',480,500)
Opt("GUIOnEventMode", 1)
$file = FileOpen("TEX.dll", 0)
$tex = FileRead($file)
GUISetBkColor ($tex, $hGUI0 )
;$rand=(Random(1,2,1))
$rand="1"
$file = FileOpen("PNT.dll", 0)
$pnt = FileRead($file)
if $rand="1" Then
   $Pic1 = GUICtrlCreatePic("Images\ANT.bmp", 5, 5, 180, 60)
   GUICtrlSetOnEvent(-1, "antpoint")
EndIf
GUISetState()
while 1
   sleep(200)
WEnd
func antpoint()
   if not FileExists("PNT.dll") then
      fileopen("PNT.dll")
      FileWrite("PNT.dll", "7845369875465")
   EndIf
   $file = FileOpen("PNT.dll", 0)
   $pnt = FileRead($file)
   if $pnt="7845369875465" then $points="0"
   if $pnt="1659523976984" then $points="1"
   if $pnt="4523691256486" then $points="2"
   if $pnt="6254896328015" then $points="3"
   if $pnt="0325698742531" then $points="4"
   if $pnt="1032645798421" then $points="5"
   if $pnt="8421455781253" then $points="6"
   if $pnt="4763130118223" then $points="7"
   if $pnt="1336455476895" then $points="8"
   if $pnt="6345722484814" then $points="9"
   if $pnt="4658522798872" then $points="10"
   if $pnt="1548112413000" then $points="11"
   if $pnt="5489435001878" then $points="12"
   if $pnt="5153140897831" then $points="13"
   if $pnt="2320164745795" then $points="14"
   if $pnt="0446136297802" then $points="15"
   if $pnt="4507631042900" then $points="16"
   if $pnt="7854121321298" then $points="17"
   if $pnt="0745942134507" then $points="18"
   if $pnt="8496742170896" then $points="19"
   if $pnt="3124784055213" then $points="20"
   if $pnt="6790814267910" then $points="21"
   if $pnt="4597800457948" then $points="22"
   if $pnt="5731606040013" then $points="23"
   if $pnt="2197489745302" then $points="24"
   if $pnt="1564879645316" then $points="25"
   if $pnt="4845021975120" then $points="26"
   if $pnt="6789851260316" then $points="27"
   if $pnt="2601579516715" then $points="28"
   if $pnt="0975109780279" then $points="29"
   if $pnt="5973123167519" then $points="30"
   if $pnt="0579059746127" then $points="31"
   if $pnt="9150975178107" then $points="32"
   if $pnt="5910792192317" then $points="33"
   if $pnt="9517917219012" then $points="34"
   if $pnt="0218756169103" then $points="35"
   if $pnt="2187854126789" then $points="36"
   if $pnt="5420248751054" then $points="37"
   if $pnt="8710329741096" then $points="38"
   if $pnt="3584120687451" then $points="39"
   if $pnt="6498451205448" then $points="40"
   if $pnt="4105481510150" then $points="41"
   if $pnt="1487049210132" then $points="42"
   if $pnt="0165484087020" then $points="43"
   if $pnt="0321894089748" then $points="44"
   if $pnt="9540894865156" then $points="45"
   if $pnt="0408945660481" then $points="46"
   if $pnt="5684651045749" then $points="47"
   if $pnt="1398711612984" then $points="48"
   if $pnt="1332548484544" then $points="49"
   if $pnt="9887411231545" then $points="50"
   $PNTfile = FileOpen("PNT.dll", 1)
   FileDelete("PNT.dll")
   if $points="0" then FileWrite($PNTfile, "1659523976984")
   if $points="1" then FileWrite($PNTfile, "4523691256486")
   if $points="2" then FileWrite($PNTfile, "6254896328015")
   if $points="3" then FileWrite($PNTfile, "0325698742531")
   if $points="4" then FileWrite($PNTfile, "1032645798421")
   if $points="5" then FileWrite($PNTfile, "8421455781253")
   if $points="6" then FileWrite($PNTfile, "4763130118223")
   if $points="7" then FileWrite($PNTfile, "1336455476895")
   if $points="8" then FileWrite($PNTfile, "6345722484814")
   if $points="9" then FileWrite($PNTfile, "4658522798872")
   if $points="10" then FileWrite($PNTfile, "1548112413000")
   if $points="11" then FileWrite($PNTfile, "5489435001878")
   if $points="12" then FileWrite($PNTfile, "5153140897831")
   if $points="13" then FileWrite($PNTfile, "2320164745795")
   if $points="14" then FileWrite($PNTfile, "0446136297802")
   if $points="15" then FileWrite($PNTfile, "4507631042900")
   if $points="16" then FileWrite($PNTfile, "7854121321298")
   if $points="17" then FileWrite($PNTfile, "0745942134507")
   if $points="18" then FileWrite($PNTfile, "8496742170896")
   if $points="19" then FileWrite($PNTfile, "3124784055213")
   if $points="20" then FileWrite($PNTfile, "6790814267910")
   if $points="21" then FileWrite($PNTfile, "4597800457948")
   if $points="22" then FileWrite($PNTfile, "5731606040013")
   if $points="23" then FileWrite($PNTfile, "2197489745302")
   if $points="24" then FileWrite($PNTfile, "1564879645316")
   if $points="25" then FileWrite($PNTfile, "4845021975120")
   if $points="26" then FileWrite($PNTfile, "6789851260316")
   if $points="27" then FileWrite($PNTfile, "2601579516715")
   if $points="28" then FileWrite($PNTfile, "0975109780279")
   if $points="29" then FileWrite($PNTfile, "5973123167519")
   if $points="30" then FileWrite($PNTfile, "0579059746127")
   if $points="31" then FileWrite($PNTfile, "9150975178107")
   if $points="32" then FileWrite($PNTfile, "5910792192317")
   if $points="33" then FileWrite($PNTfile, "9517917219012")
   if $points="34" then FileWrite($PNTfile, "0218756169103")
   if $points="35" then FileWrite($PNTfile, "2187854126789")
   if $points="36" then FileWrite($PNTfile, "5420248751054")
   if $points="37" then FileWrite($PNTfile, "8710329741096")
   if $points="38" then FileWrite($PNTfile, "3584120687451")
   if $points="39" then FileWrite($PNTfile, "6498451205448")
   if $points="40" then FileWrite($PNTfile, "4105481510150")
   if $points="41" then FileWrite($PNTfile, "1487049210132")
   if $points="42" then FileWrite($PNTfile, "0165484087020")
   if $points="43" then FileWrite($PNTfile, "0321894089748")
   if $points="44" then FileWrite($PNTfile, "9540894865156")
   if $points="45" then FileWrite($PNTfile, "0408945660481")
   if $points="46" then FileWrite($PNTfile, "5684651045749")
   if $points="47" then FileWrite($PNTfile, "1398711612984")
   if $points="48" then FileWrite($PNTfile, "1332548484544")
   if $points="49" then FileWrite($PNTfile, "9887411231545")
   if $points="50" then FileWrite($PNTfile, "9887411231545")
   msgbox(0,$pnt,$pnt)
   msgbox(0,$points,$points)
endfunc

当我按下按钮时,我收到两个msgbox,它可以正常工作。当我再次按下它时,问题开始了;我收到一个错误说:

"G:\Users\09stephenb\Desktop\AUTOIT\Combine\RANDOM.au3" (78) : ==> Variable used without being declared.:
if $points="0" then FileWrite($PNTfile, "1659523976984")
if ^ ERROR

我该如何解决?

我已经查看了它,并且当它运行一次时,变量必须有一个值。

1 个答案:

答案 0 :(得分:2)

好的,经过一些澄清后,我希望这就是你要找的东西:

#include <Crypt.au3>
#include <GUIConstantsEx.au3>

;OnAutoItExitRegister("_OnAutoItExit")
Global $count, $sFile, $sRead
Global Const $SecurePass = "securepassword"    ;Change your secure password here if you want
;Local $rand=(Random(1,2,1))
Local $rand = "1"
Local $file = FileOpen("TEX.dll", 0)
Local $tex = FileRead($file)
FileClose($file)
Local $hGUI0 = GUICreate('GUI', 480, 500)
GUISetBkColor($tex, $hGUI0)
If $rand = "1" Then
    $Pic1 = GUICtrlCreateButton("Images\ANT.bmp", 5, 5, 180, 60)
EndIf
GUISetState()

While 1
    $sMsg = GUIGetMsg()
    Switch $sMsg
        Case -3
            ExitLoop
        Case $Pic1
            If $rand = "1" Then antpoint()
    EndSwitch
    Sleep(20)
WEnd


Func antpoint()
    If Not FileExists("PNT.txt") Then
        $count = NumberEncryptDecrypt(True, 1, $SecurePass, $CALG_3DES)
        $sFile = FileOpen("PNT.txt", 2)
            FileWrite($sFile, StringTrimLeft($count, 2))
        FileClose($sFile)
    Else
        $sFile = FileOpen("PNT.txt")
        $sRead = FileRead("PNT.txt")
        FileClose($sFile)
        $count = NumberEncryptDecrypt(False, "0x" & $sRead, $SecurePass, $CALG_3DES)
        $count += 1
        $count = NumberEncryptDecrypt(True, $count, $SecurePass, $CALG_3DES)
        $sFile = FileOpen("PNT.txt", 2)
        FileWrite($sFile, StringTrimLeft($count, 2))
        FileClose($sFile)
    EndIf

    $sFile = FileOpen("PNT.txt")
    $sRead = FileRead($sFile)
    $count = NumberEncryptDecrypt(False, "0x" & $sRead, $SecurePass, $CALG_3DES)
    FileClose($sFile)

    If Number($count) <> 0 Then
        MsgBox(0, "Our Line", $count)
    Else
        MsgBox(0, "", "failed, you need a better debug. Seriously ;)")
    EndIf
EndFunc   ;==>antpoint


Func NumberEncryptDecrypt($State, $Data, $Password, $ALG_ID)
    _Crypt_Startup()
    Local $sReturn = ''
    If $State Then
        $sReturn = _Crypt_EncryptData(String($Data), $Password, $ALG_ID)
    Else
        $sReturn = BinaryToString(_Crypt_DecryptData(String($Data), $Password, $ALG_ID))
    EndIf
    _Crypt_Shutdown()
    Return String($sReturn)
EndFunc


Func _OnAutoItExit()
    $timer = TimerInit()
    While FileExists("PNT.txt") And TimerDiff($timer) < 10000    ;; Avoid looping forever!
        FileDelete("PNT.txt")
        Sleep(200)
    WEnd
EndFunc

P.S。:如果您想在每次退出脚本时删除该文件,请注释掉这一行:

;OnAutoItExitRegister("_OnAutoItExit")