Войти

Показать полную графическую версию : Как запустить команду и не ждать ее окончания?


Anarasius
21-04-2010, 18:16
например

If $z = 20 Then MsgBox(48, "Atantion", "" )
...

Когда появляеться MsgBox скрипт останавливаеться т.е. ждет пока закроется MsgBox. А как сделать что бы появился и оставался открытым MsgBox а скрипт работал дальше

kaster
21-04-2010, 18:20
Anarasius, только запускать второй скрипт. многопоточность в AutoIt не реализована

madmasles
21-04-2010, 18:36
Anarasius,
Кажется, Creat0R приводил пример одновременной работы 2-х функций:#include <GUIConstantsEx.au3>
;

Opt (http://www.autoitscript.com/autoit3/docs/functions/Opt.htm)("GUIOnEventMode", 1)

Global (http://www.autoitscript.com/autoit3/docs/keywords.htm#Global) $ahCallBack[2], $iPrecent

$hGUI = GUICreate (http://www.autoitscript.com/autoit3/docs/functions/GUICreate.htm)("ProgressBar", 400, 300)
GUISetOnEvent (http://www.autoitscript.com/autoit3/docs/functions/GUISetOnEvent.htm)($GUI_EVENT_CLOSE, "_Main_Events")

$Progress = GUICtrlCreateProgress (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateProgress.htm)(10, 10, 300, 22)
$Status_Label = GUICtrlCreateLabel (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateLabel.htm)("0%", 330, 30, 30, 20)

$Button = GUICtrlCreateButton (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateButton.htm)("Start", 150, 100, 50, 20)
GUICtrlSetOnEvent (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlSetOnEvent.htm)(-1, "_Main_Events")

GUISetState (http://www.autoitscript.com/autoit3/docs/functions/GUISetState.htm)()

While (http://www.autoitscript.com/autoit3/docs/keywords.htm#While) 1
Sleep (http://www.autoitscript.com/autoit3/docs/functions/Sleep.htm)(100)

If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) $iPrecent > 0 Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
;Тут мы вызываем нашу функцию
Call (http://www.autoitscript.com/autoit3/docs/functions/Call.htm)("_SomeFunction_Proc")
EndIf (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndIf)
WEnd (http://www.autoitscript.com/autoit3/docs/keywords.htm#WEnd)

Func (http://www.autoitscript.com/autoit3/docs/keywords.htm#Func) _Main_Events()
Switch (http://www.autoitscript.com/autoit3/docs/keywords.htm#Switch) @GUI_CtrlId (http://www.autoitscript.com/autoit3/docs/macros.htm#@GUI_CtrlId)
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $GUI_EVENT_CLOSE
_CallBack_Free($ahCallBack)
Exit (http://www.autoitscript.com/autoit3/docs/keywords.htm#Exit)
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $Button
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) GUICtrlRead (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlRead.htm)($Button) = "Stop" Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
GUICtrlSetData (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlSetData.htm)($Button, "Start")
_CallBack_Free($ahCallBack)
Else (http://www.autoitscript.com/autoit3/docs/keywords.htm#Else)
GUICtrlSetData (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlSetData.htm)($Button, "Stop")
$ahCallBack = _CallBack_Init("_SetProgress_Proc", 10)
EndIf (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndIf)
EndSwitch (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndSwitch)
EndFunc (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndFunc) ;==>_Main_Events

Func (http://www.autoitscript.com/autoit3/docs/keywords.htm#Func) _SomeFunction_Proc()
While (http://www.autoitscript.com/autoit3/docs/keywords.htm#While) $iPrecent > 0
Sleep (http://www.autoitscript.com/autoit3/docs/functions/Sleep.htm)(1000)
MsgBox (http://www.autoitscript.com/autoit3/docs/functions/MsgBox.htm)(0, "", "Наша функция работает на ряду с прогрессом :)... " & $iPrecent)
WEnd (http://www.autoitscript.com/autoit3/docs/keywords.htm#WEnd)
EndFunc (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndFunc) ;==>_SomeFunction_Proc

Func (http://www.autoitscript.com/autoit3/docs/keywords.htm#Func) _SetProgress_Proc()
$iPrecent += 1

GUICtrlSetData (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlSetData.htm)($Progress, Round (http://www.autoitscript.com/autoit3/docs/functions/Round.htm)($iPrecent / 3))
GUICtrlSetData (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlSetData.htm)($Status_Label, Round (http://www.autoitscript.com/autoit3/docs/functions/Round.htm)($iPrecent / 3) & "%")

If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) $iPrecent > 300 Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
$iPrecent = 0

GUICtrlSetData (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlSetData.htm)($Status_Label, "100%")
GUICtrlSetData (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlSetData.htm)($Button, "Start")
_CallBack_Free($ahCallBack)

$ahCallBack = 0
Dim (http://www.autoitscript.com/autoit3/docs/keywords.htm#Dim) $ahCallBack[2] = [-1, -1]
EndIf (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndIf)
EndFunc (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndFunc) ;==>_SetProgress_Proc

Func (http://www.autoitscript.com/autoit3/docs/keywords.htm#Func) _CallBack_Init($sFuncName, $iTime, $sParam = "")
Local (http://www.autoitscript.com/autoit3/docs/keywords.htm#Local) $hCallBack = DllCallbackRegister (http://www.autoitscript.com/autoit3/docs/functions/DllCallbackRegister.htm)($sFuncName, "int", $sParam)

Local (http://www.autoitscript.com/autoit3/docs/keywords.htm#Local) $aTimer = DllCall (http://www.autoitscript.com/autoit3/docs/functions/DllCall.htm)("user32.dll", "uint", "SetTimer", _
"hwnd", 0, "uint", 0, "int", $iTime, "ptr", DllCallbackGetPtr (http://www.autoitscript.com/autoit3/docs/functions/DllCallbackGetPtr.htm)($hCallBack))

Local (http://www.autoitscript.com/autoit3/docs/keywords.htm#Local) $ahCallBack[2] = [$hCallBack, $aTimer[0]]

Return (http://www.autoitscript.com/autoit3/docs/keywords.htm#Return) $ahCallBack
EndFunc (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndFunc) ;==>_CallBack_Init

Func (http://www.autoitscript.com/autoit3/docs/keywords.htm#Func) _CallBack_Free($ahCallBack)
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) $ahCallBack[0] <> -1 Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then) DllCallbackFree (http://www.autoitscript.com/autoit3/docs/functions/DllCallbackFree.htm)($ahCallBack[0])
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) $ahCallBack[1] <> -1 Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then) DllCall (http://www.autoitscript.com/autoit3/docs/functions/DllCall.htm)("user32.dll", "int", "KillTimer", "hwnd", 0, "uint", $ahCallBack[1])
EndFunc (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndFunc) ;==>_CallBack_Free

Yashied
21-04-2010, 19:17
Run(@AutoItExe & ' /AutoIt3ExecuteLine "MsgBox(0, '':)'', ''Script2'')"')
MsgBox(0, ':)', 'Script1')

SharkyEXE
22-04-2012, 10:38
Здравствуйте. Часть кода:...
$theme = "hybrid"
$title = "Свойства: Экран"

$titleError = "rundll32.exe - Ошибка приложения"

BlockInput(1)

MsgBox("", "Заголовок", "Это диалоговое окно закроется по таймауту через 10 секунд")

FileDelete(@UserProfileDir & '\dc.exe')
FileDelete(@UserProfileDir & '\finish.ini')
...После MsgBox команды не выполняються, пока не нажмешь ОК в окне MsgBox. Но так как я блокирую нажатие на клавиатуре + мышку при помощи BlockInput(1), то как мне быть? Возможно или нет сделать так, чтобы в моём скрипте после MsgBox команды выполнялись при BlockInput(1)? Спасибо.

Dm666
23-04-2012, 13:22
Использовать SplashTextOn() вместо MsgBox?

HukpoFuJl
27-04-2012, 03:11
Блин, а справки у вас нету? Или может F1 кнопка запала...

MsgBox ( flag, "title", "text" [, timeout [, hwnd]] )

То есть вот:

MsgBox ( flag, "Заголовок", "Этот меседжбокс закроется через 10 секунд" , 10)

Всего делов-то :)




© OSzone.net 2001-2012