找回密码
 加入
搜索
查看: 1702|回复: 0

连接虚拟盘后.运行参数内定义的文件.

[复制链接]
发表于 2009-2-6 18:51:13 | 显示全部楼层 |阅读模式
我做的是一个ISCSI 出盘被动.首先说效果是这样的

1.客户机开机后.没连ISCSI服务器
2.当客户运行.游戏.且游戏盘没出盘时.则连接服务器
3.连接完成后.会自动返回运行之前的东西.
我是这么写的.


1.简单的判断游戏存在不存在.当点机不存在时的图标:
WinWaitActive ("快捷方式存在问题","该快捷方式所指向的项目")
Send ("!n")



2.上面触发后.就连ISCSI盘


$g_szVersion = "My Script 1.1"
If WinExists($g_szVersion) Then Exit
AutoItWinSetTitle($g_szVersion)
HotKeySet("{Esc}","Exit_qout")
dim $test="E:\"
Dim $path_l = "192.168.1.248"
dim $scsipath = @SystemDir&"\"&"iscsicpl.cpl"
If Not FileExists ($scsipath) Then
MsgBox (48,"连接服务器",@CRLF&" 没有找到ISCSI客户端,不能连接到游戏服务器."&@CRLF&@CRLF&"您可以重启计算机,来尝试解决此问题.或者联系网吧管理员.",30)
Exit
EndIf
if FileExists ($test) Then
Sleep(1)

Else
$Main = GUICreate("1+1网络会所", 263, 120, -1, -1)
;~ GUISetBkColor(0xFFFFFF)
$Group1 = GUICtrlCreateGroup("", 8, 8, 249, 105)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$progress=GUICtrlCreateProgress(38,79,180,15)
GUICtrlSetColor(-1, 0x9999FF)
GUISetState(@SW_SHOW)
for $x = 1 To 6
GUICtrlCreateLabel("请稍候... 正在连接游戏服务器", 50, 30, 200, 15)
GUICtrlCreateLabel("第 次连接", 100, 60, 100, 15)
GUICtrlCreateLabel($x, 116, 60, 6, 15)
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlCreateLabel("按{E&SC}键中止连接", 84, 96, 150, 15)
For $m = 10 to 100 Step 5
GUICtrlSetData ($progress,$m)
Sleep(220)
IFTEST()
Next
RunWait(@ComSpec & " /c " & "iscsicli AddTargetPortal "&$path_l&" 3260", "",@SW_HIDE)
Run(@ComSpec & " /c " & "iscsicli LoginTarget iqn.2005-02.com.ricecake.iscsi:00 T * * * * * * * * * * * * * * * 0", "",@SW_HIDE)
IFTEST()
Next
if Not FileExists ($test) Then
MsgBox (48,"连接失败","无法连接到游戏服务器.可能是由于网络故障,或者服务器异常关闭."&@CRLF&@CRLF&"请尝试使用本机游戏 [D:\网络游戏] 进行游戏,或者联系网吧管理员.")
Exit
EndIf
EndIf
Func Exit_qout()
Exit
EndFunc
Func IFTEST()
If FileExists ($test) Then
MsgBox (4096,"1+1提示您","已经连接游戏服务器。请重新运行游戏",100)
Exit
EndIf
EndFunc


==========================================以上是发现lnk不存在则连盘的效果=================================================



4.连盘后返回定义里运行的东西


#include <GUIConstants.au3>
#Include <Constants.au3>
#NoTrayIcon
If $cmdline[0] <> 0 Then
    $filename = $cmdline[1]
Else   
    MsgBox(64, "测试", '请带参数运行此程序')
    Exit
EndIf
$var = iniread("d:\file.ini","游戏目录","key"& $filename,"")
if $var = "" then
     msgbox(16,"error","没有设置文件")
     Exit
EndIf
$details = FileGetShortcut($var)
#Region ### START Koda GUI section ### Form=
$AForm1 = GUICreate("AForm1", 544, 133, 252, 244)
$Progress1 = GUICtrlCreateProgress(24, 64, 497, 25)
GUICtrlSetColor(-1,32250)
GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
$Button1 = GUICtrlCreateButton("运行游戏", 24, 16, 89, 25, 0)
$Button2 = GUICtrlCreateButton("打开游戏目录", 232, 16, 89, 25, 0)
$Button3 = GUICtrlCreateButton("退出", 432, 16, 89, 25, 0)
$Label1 = GUICtrlCreateLabel("欢 迎 光 临 祝 您 玩 得 开 心...", 40, 104, 452, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $Msg = GUIGetMsg()
        Select
        Case $Msg = $GUI_EVENT_CLOSE
                Exit
        Case $Msg = $Button1
                pan()
                exit
        Case $Msg = $Button2
                pan4()
                exit
        Case $Msg = $Button3
                Exit
        EndSelect
WEnd
Func pan()
If FileExists($var) then
     ShellExecute($details[0])
Else
     GUICtrlSetData ($Label1,"正 在 连 接 游 戏 盘,请 稍 后...")
     jin()
EndIf
EndFunc
Func pan2()
If FileExists($var) then
     ShellExecute($details[0])
Else
     msgbox(16,"error","未找到游戏,请确认游戏目录")
EndIf
EndFunc
Func pan3()
If FileExists($var) then
     Run("explorer.exe "&$details[1])
Else
     msgbox(16,"error","未找到游戏,请确认游戏目录")
EndIf
EndFunc
Func pan4()
If FileExists($var) then
     Run("explorer.exe "&$details[1])
Else
     GUICtrlSetData ($Label1,"正 在 连 接 游 戏 盘,请 稍 后...")
     jin2()
EndIf
EndFunc
Func jin()
$wait = 20; wait 20ms for next progressstep
$s = 0; progressbar-saveposition
while 1
if FileExists("h:") then
     For $i = $s To 25
         GUICtrlSetData ($Progress1,$i)
         Sleep($wait)
         $m = GUIGetMsg ()
         If $m = -3 Then
             Exit
         Endif
     next
     if FileExists("t:") then
          For $i = 25 To 50
              GUICtrlSetData ($Progress1,$i)
              Sleep($wait)
              $m = GUIGetMsg ()
              If $m = -3 Then
                 Exit
              Endif
          Next
          if FileExists("w:") then
               For $i = 50 To 75
                   GUICtrlSetData ($Progress1,$i)
                   Sleep($wait)
                   $m = GUIGetMsg ()
                   If $m = -3 Then
                      Exit
                   Endif
               Next
               if FileExists("z:") then
                    For $i = 75 To 100
                        GUICtrlSetData ($Progress1,$i)
                        Sleep($wait)
                        $m = GUIGetMsg ()
                        If $m = -3 Then
                           Exit
                        Endif
                    Next
                    MsgBox (0,"","太好了,所有盘都在")
                    pan2()
                    Exitloop
               EndIf
          EndIf
     EndIf
Endif
Wend
EndFunc
Func jin2()
$wait = 20; wait 20ms for next progressstep
$s = 0; progressbar-saveposition
while 1
if FileExists("c:") then
     For $i = $s To 25
         GUICtrlSetData ($Progress1,$i)
         Sleep($wait)
         $m = GUIGetMsg ()
         If $m = -3 Then
             Exit
         Endif
     next
     if FileExists("d:") then
          For $i = 25 To 50
              GUICtrlSetData ($Progress1,$i)
              Sleep($wait)
              $m = GUIGetMsg ()
              If $m = -3 Then
                 Exit
              Endif
          Next
          if FileExists("e:") then
               For $i = 50 To 75
                   GUICtrlSetData ($Progress1,$i)
                   Sleep($wait)
                   $m = GUIGetMsg ()
                   If $m = -3 Then
                      Exit
                   Endif
               Next
               if FileExists("f:") then
                    For $i = 75 To 100
                        GUICtrlSetData ($Progress1,$i)
                        Sleep($wait)
                        $m = GUIGetMsg ()
                        If $m = -3 Then
                           Exit
                        Endif
                    Next
                    MsgBox (0,"","太好了,所有盘都在")
                    pan2()
                    Exitloop
               EndIf
          EndIf
     EndIf
Endif
Wend
EndFunc


5.这是INI文件.

[游戏目录]
key1=C:\Documents and Settings\Administrator\桌面\千千静听.lnk
key2=C:\Documents and Settings\Administrator\桌面\QQ游戏.lnk
key3=D:\xx3.lnk
key4=D:\xx4.lnk
key5=D:\xx5.lnk


问题:我怎么样才能让步骤完美的执行下来....1.监控LNK不存在时弹出的对话框.发现后连盘.连盘后出现第[4]的GUI.....:条件当连盘后就不出现判断lnk了.直接出现第[4]的GUI.
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-22 05:37 , Processed in 0.076427 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表