Sign in to follow this  
Followers 0
Chinasmoker

I ve a trouble

20 posts in this topic

#1 ·  Posted (edited)

Hey,guys,I ve a trouble.

I wrote a program by au3 yesterday, and when I was ready for testing it, I found If run this program twice(shortly),it was not working ,Not appeare intended effect!

R there some way can resolve this trouble,Thanks any way

Edited by Chinasmoker

One is never too old to learn

Share this post


Link to post
Share on other sites



#include<misc.au3>

_Singleton("my script")

Share this post


Link to post
Share on other sites

#include<misc.au3>

_Singleton("my script")

Thanks ,Can you give me an explanation of that two line code ? I didnt get it


One is never too old to learn

Share this post


Link to post
Share on other sites

...post the code, that way you can get an acurate answer.

code:

CODE
#include <GUIConstants.au3>

#NoTrayIcon

run ("\\vdisk\新游戏更新$\调用程序\a.bat","",@SW_HIDE);先连接虚拟磁盘

$var = DriveGetDrive( "ALL") ;读取所有类型驱动器的总数量

Select

Case $var[0] = 5 ;如果总数有5个,则直接执行use()

use()

Case $var[0] <> 5 ;如果没有5个。执行GUI,直到出现I盘

main()

EndSelect

Func use()

run ("\\vdisk\新游戏更新$\调用程序\原调用.exe")

WinWaitActive ("欢迎光临捷胜网吧")

ControlClick ("欢迎光临捷胜网吧","",$CMDline[1])

EndFunc

Func main()

$Form1 = GUICreate("欢迎光临捷胜网吧", 287, 105, -1, -1, BitOR($WS_MINIMIZEBOX,$WS_CAPTION,$WS_GROUP,$WS_BORDER,$WS_CLIPSIBLINGS), BitOR ($WS_EX_OVERLAPPEDWINDOW,$WS_EX_TOOLWINDOW,$WS_EX_WINDOWEDGE))

GUISetIcon("F:\网络游戏\QQ堂\Client.exe")

GUISetBkColor(0xA6CAF0)

$Label1 = GUICtrlCreateLabel("正在连接虚拟磁盘,请稍候...", 18, 16, 198, 24, $WS_CLIPSIBLINGS, $GUI_WS_EX_PARENTDRAG)

GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")

GUICtrlSetColor(-1, 0xFF0000)

GUICtrlSetBkColor(-1, 0xA6CAF0)

$Progress1 = GUICtrlCreateProgress(48, 64, 150, 16, BitOR($PBS_SMOOTH,$WS_CLIPSIBLINGS))

GUICtrlSetData(-1, 25)

$Label2 = GUICtrlCreateLabel("0%", 120, 40, 25, 20)

GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")

GUICtrlSetColor(-1, 0x008000)

GUICtrlSetBkColor(-1, 0xA6CAF0)

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

run ("\\vdisk\新游戏更新$\调用程序\a.bat","",@SW_HIDE)

$s=0

$wait=100

While 1

$Msg = GUIGetMsg()

For $i = $s To 100

GUICtrlSetData ($Progress1,$i)

GUICtrlSetData ($Label2,$i &"%")

Sleep($wait)

If GUICtrlRead($Progress1) = 100 Then Exit

Next

WEnd

EndFunc


One is never too old to learn

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

#include <GUIConstants.au3>
#include<misc.au3>
#NoTrayIcon

If _Singleton("What Ever",1) = 0 Then
msgbox(0,'ERROR','SCRIPT EXITS')
Exit
Endif

run ("\\vdisk\新游戏更新$\调用程序\a.bat","",@SW_HIDE);先连接虚拟磁盘
$var = DriveGetDrive( "ALL") ;读取所有类型驱动器的总数量

Select
Case $var[0] = 5 ;如果总数有5个,则直接执行use()
use()
Case $var[0] <> 5 ;如果没有5个。执行GUI,直到出现I盘
main()

EndSelect


Func use()
run ("\\vdisk\新游戏更新$\调用程序\原调用.exe")
WinWaitActive ("欢迎光临捷胜网吧")
ControlClick ("欢迎光临捷胜网吧","",$CMDline[1])
EndFunc

Func main()
$Form1 = GUICreate("欢迎光临捷胜网吧", 287, 105, -1, -1, BitOR($WS_MINIMIZEBOX,$WS_CAPTION,$WS_GROUP,$WS_BORDER,$WS_CLIPSIBLINGS), BitOR ($WS_EX_OVERLAPPEDWINDOW,$WS_EX_TOOLWINDOW,$WS_EX_WINDOWEDGE))
GUISetIcon("F:\网络游戏\QQ堂\Client.exe")
GUISetBkColor(0xA6CAF0)
$Label1 = GUICtrlCreateLabel("正在连接虚拟磁盘,请稍候...", 18, 16, 198, 24, $WS_CLIPSIBLINGS, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlSetBkColor(-1, 0xA6CAF0)
$Progress1 = GUICtrlCreateProgress(48, 64, 150, 16, BitOR($PBS_SMOOTH,$WS_CLIPSIBLINGS))
GUICtrlSetData(-1, 25)
$Label2 = GUICtrlCreateLabel("0%", 120, 40, 25, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x008000)
GUICtrlSetBkColor(-1, 0xA6CAF0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
run ("\\vdisk\新游戏更新$\调用程序\a.bat","",@SW_HIDE)
$s=0
$wait=100

While 1
$Msg = GUIGetMsg()
For $i = $s To 100
GUICtrlSetData ($Progress1,$i)
GUICtrlSetData ($Label2,$i &"%")
Sleep($wait)
If GUICtrlRead($Progress1) = 100 Then Exit
Next


WEnd

EndFunc

Edited by athiwatc

Share this post


Link to post
Share on other sites

About "_Singleton("What Ever",1)", why use "what ever",what mean,Is that a file name of my script

#include <GUIConstants.au3>
#include<misc.au3>
#NoTrayIcon

If _Singleton("What Ever",1) = 0 Then
msgbox(0,'ERROR','SCRIPT EXITS')
Exit
Endif

run ("\\vdisk\新游戏更新$\调用程序\a.bat","",@SW_HIDE);先连接虚拟磁盘
$var = DriveGetDrive( "ALL") ;读取所有类型驱动器的总数量

Select
Case $var[0] = 5 ;如果总数有5个,则直接执行use()
use()
Case $var[0] <> 5 ;如果没有5个。执行GUI,直到出现I盘
main()

EndSelect
Func use()
run ("\\vdisk\新游戏更新$\调用程序\原调用.exe")
WinWaitActive ("欢迎光临捷胜网吧")
ControlClick ("欢迎光临捷胜网吧","",$CMDline[1])
EndFunc

Func main()
$Form1 = GUICreate("欢迎光临捷胜网吧", 287, 105, -1, -1, BitOR($WS_MINIMIZEBOX,$WS_CAPTION,$WS_GROUP,$WS_BORDER,$WS_CLIPSIBLINGS), BitOR ($WS_EX_OVERLAPPEDWINDOW,$WS_EX_TOOLWINDOW,$WS_EX_WINDOWEDGE))
GUISetIcon("F:\网络游戏\QQ堂\Client.exe")
GUISetBkColor(0xA6CAF0)
$Label1 = GUICtrlCreateLabel("正在连接虚拟磁盘,请稍候...", 18, 16, 198, 24, $WS_CLIPSIBLINGS, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlSetBkColor(-1, 0xA6CAF0)
$Progress1 = GUICtrlCreateProgress(48, 64, 150, 16, BitOR($PBS_SMOOTH,$WS_CLIPSIBLINGS))
GUICtrlSetData(-1, 25)
$Label2 = GUICtrlCreateLabel("0%", 120, 40, 25, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x008000)
GUICtrlSetBkColor(-1, 0xA6CAF0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
run ("\\vdisk\新游戏更新$\调用程序\a.bat","",@SW_HIDE)
$s=0
$wait=100

While 1
$Msg = GUIGetMsg()
For $i = $s To 100
GUICtrlSetData ($Progress1,$i)
GUICtrlSetData ($Label2,$i &"%")
Sleep($wait)
If GUICtrlRead($Progress1) = 100 Then Exit
Next
WEnd

EndFunc

One is never too old to learn

Share this post


Link to post
Share on other sites

直接把那两行code放在script的开头, 这样如果重复运行就会自动关闭

Share this post


Link to post
Share on other sites

直接把那两行code放在script的开头, 这样如果重复运行就会自动关闭

谢谢,你在国内是吧,有QQ吗?


One is never too old to learn

Share this post


Link to post
Share on other sites

我在加拿大,QQ地震之后就没有用了,如果有问题可以PM我

Share this post


Link to post
Share on other sites

我在加拿大,QQ地震之后就没有用了,如果有问题可以PM我

好的。多谢,这二天要给网吧装系统,写这个方便连接虚拟磁盘,

还有个小问题,二个自定义function,能不能相互调用,刚发出来的code中在main()最后我需要用到use()


One is never too old to learn

Share this post


Link to post
Share on other sites

你这个脚本的主要用途是什么? 我怎么看也看不出来

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

about my script

It is used to connect virtual Disk(Its computer name is vdisk and its ip is 192.168.0.245)

so ,I was according tatol of drive to judge if it needs to connect virtual Disk

If tatol of drive = 5 This mean to connect virtual Disk successfully,then run use()

If not This mean to need connect virtual Disk ,so must run main(),

Edited by Chinasmoker

One is never too old to learn

Share this post


Link to post
Share on other sites

According to your code, your main function doesn't do anything, besides shows a gui and show a progress bar(it doesn't even work).

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

According to your code, your main function doesn't do anything, besides shows a gui and show a progress bar(it doesn't even work).

yep.In fact ,in main() ,There is a run bat ,This is connect to vdisk , in the end of main() ,I need to add use() in main(),but It still didnt work.damn it, Can two UDFs call each other?

CODE
#include <GUIConstants.au3>

#NoTrayIcon

#include<misc.au3>

_Singleton("my script")

run ("\\vdisk\新游戏更新$\调用程序\a.bat","",@SW_HIDE)

$var = DriveGetDrive( "ALL")

Select

Case $var[0] = 5

use()

Case $var[0] <> 5

main()

EndSelect

Func use()

run ("\\vdisk\新游戏更新$\调用程序\原调用.exe")

WinWaitActive ("欢迎光临捷胜网吧")

ControlClick ("欢迎光临捷胜网吧","",$CMDline[1])

EndFunc

Func main()

$Form1 = GUICreate("欢迎光临捷胜网吧", 287, 105, -1, -1, BitOR($WS_MINIMIZEBOX,$WS_CAPTION,$WS_GROUP,$WS_BORDER,$WS_CLIPSIBLINGS), BitOR ($WS_EX_OVERLAPPEDWINDOW,$WS_EX_TOOLWINDOW,$WS_EX_WINDOWEDGE))

GUISetIcon("F:\网络游戏\QQ堂\Client.exe")

GUISetBkColor(0xA6CAF0)

$Label1 = GUICtrlCreateLabel("正在连接虚拟磁盘,请稍候...", 18, 16, 198, 24, $WS_CLIPSIBLINGS, $GUI_WS_EX_PARENTDRAG)

GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")

GUICtrlSetColor(-1, 0xFF0000)

GUICtrlSetBkColor(-1, 0xA6CAF0)

$Progress1 = GUICtrlCreateProgress(48, 64, 150, 16, BitOR($PBS_SMOOTH,$WS_CLIPSIBLINGS))

GUICtrlSetData(-1, 25)

$Label2 = GUICtrlCreateLabel("0%", 120, 40, 25, 20)

GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")

GUICtrlSetColor(-1, 0x008000)

GUICtrlSetBkColor(-1, 0xA6CAF0)

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

run ("\\vdisk\新游戏更新$\调用程序\a.bat","",@SW_HIDE)

$s=0

$wait=100

While 1

$Msg = GUIGetMsg()

For $i = $s To 100

GUICtrlSetData ($Progress1,$i)

GUICtrlSetData ($Label2,$i &"%")

Sleep($wait)

If GUICtrlRead($Progress1) = 100 Then Exit

Next

WEnd

use()

EndFunc

Edited by Chinasmoker

One is never too old to learn

Share this post


Link to post
Share on other sites

Maybe

#include <GUIConstants.au3>
#NoTrayIcon
#include<misc.au3>
_Singleton("my script")


run ("\\vdisk\新游戏更新$\调用程序\a.bat","",@SW_HIDE)
$var = DriveGetDrive( "ALL")



Select
Case $var[0] = 5
use()
Case $var[0] <> 5
main()

EndSelect


Func use()
run ("\\vdisk\新游戏更新$\调用程序\原调用.exe")
WinWaitActive ("欢迎光临捷胜网吧")
ControlClick ("欢迎光临捷胜网吧","",$CMDline[1])
EndFunc

Func main()
$Form1 = GUICreate("欢迎光临捷胜网吧", 287, 105, -1, -1, BitOR($WS_MINIMIZEBOX,$WS_CAPTION,$WS_GROUP,$WS_BORDER,$WS_CLIPSIBLINGS), BitOR ($WS_EX_OVERLAPPEDWINDOW,$WS_EX_TOOLWINDOW,$WS_EX_WINDOWEDGE))
GUISetIcon("F:\网络游戏\QQ堂\Client.exe")
GUISetBkColor(0xA6CAF0)
$Label1 = GUICtrlCreateLabel("正在连接虚拟磁盘,请稍候...", 18, 16, 198, 24, $WS_CLIPSIBLINGS, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlSetBkColor(-1, 0xA6CAF0)
$Progress1 = GUICtrlCreateProgress(48, 64, 150, 16, BitOR($PBS_SMOOTH,$WS_CLIPSIBLINGS))
GUICtrlSetData(-1, 25)
$Label2 = GUICtrlCreateLabel("0%", 120, 40, 25, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x008000)
GUICtrlSetBkColor(-1, 0xA6CAF0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
run ("\\vdisk\新游戏更新$\调用程序\a.bat","",@SW_HIDE)
$s=0
$wait=100

While 1
$Msg = GUIGetMsg()
For $i = $s To 100
GUICtrlSetData ($Progress1,$i)
GUICtrlSetData ($Label2,$i &"%")
Sleep($wait)
If GUICtrlRead($Progress1) = 100 Then use()
Exit
EndIf
Next


WEnd

EndFunc

Share this post


Link to post
Share on other sites

My ChinesePera-Kun just had a brain-fart deciphering this thread! :)

Share this post


Link to post
Share on other sites

tetsed it

It should be

While 1

$Msg = GUIGetMsg()

For $i = $s To 100

GUICtrlSetData ($Progress1,$i)

GUICtrlSetData ($Label2,$i &"%")

Sleep($wait)

If GUICtrlRead($Progress1) = 100 Then use() and Exit

Next

WEnd

EndFunc

Thanks ,bye the way ,,speak a chinese ,谢谢

Maybe

#include <GUIConstants.au3>
#NoTrayIcon
#include<misc.au3>
_Singleton("my script")
run ("\\vdisk\新游戏更新$\调用程序\a.bat","",@SW_HIDE)
$var = DriveGetDrive( "ALL")
Select
Case $var[0] = 5
use()
Case $var[0] <> 5
main()

EndSelect
Func use()
run ("\\vdisk\新游戏更新$\调用程序\原调用.exe")
WinWaitActive ("欢迎光临捷胜网吧")
ControlClick ("欢迎光临捷胜网吧","",$CMDline[1])
EndFunc

Func main()
$Form1 = GUICreate("欢迎光临捷胜网吧", 287, 105, -1, -1, BitOR($WS_MINIMIZEBOX,$WS_CAPTION,$WS_GROUP,$WS_BORDER,$WS_CLIPSIBLINGS), BitOR ($WS_EX_OVERLAPPEDWINDOW,$WS_EX_TOOLWINDOW,$WS_EX_WINDOWEDGE))
GUISetIcon("F:\网络游戏\QQ堂\Client.exe")
GUISetBkColor(0xA6CAF0)
$Label1 = GUICtrlCreateLabel("正在连接虚拟磁盘,请稍候...", 18, 16, 198, 24, $WS_CLIPSIBLINGS, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlSetBkColor(-1, 0xA6CAF0)
$Progress1 = GUICtrlCreateProgress(48, 64, 150, 16, BitOR($PBS_SMOOTH,$WS_CLIPSIBLINGS))
GUICtrlSetData(-1, 25)
$Label2 = GUICtrlCreateLabel("0%", 120, 40, 25, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x008000)
GUICtrlSetBkColor(-1, 0xA6CAF0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
run ("\\vdisk\新游戏更新$\调用程序\a.bat","",@SW_HIDE)
$s=0
$wait=100

While 1
$Msg = GUIGetMsg()
For $i = $s To 100
GUICtrlSetData ($Progress1,$i)
GUICtrlSetData ($Label2,$i &"%")
Sleep($wait)
If GUICtrlRead($Progress1) = 100 Then use()
Exit
EndIf
Next
WEnd

EndFunc

One is never too old to learn

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0