Показать полную графическую версию : Одновременная работа цикла и программы
ShogenOFF
13-08-2010, 17:56
Вызов функций в проге производится опросом:
case "abc"
func1
case"amg"
func2
case"adm"
func3
если вызвать функцию2, то опрос останавливается, пока не выполнит эту фунцию2, а функц2 это бесконецный цикл:
while 1
msgbox(0,"","message")
wend
Как заставить работать прогу параллельно с циклом
saavaage
13-08-2010, 18:18
ShogenOFF, не уверен, но, возможно, реализовать как отдельный скрипт и запускать его из основного?
ShogenOFF
13-08-2010, 20:58
А нет других вариантов? Ехе'шник, желательно, должен быть один. Если это что-то меняет, то цикл do...until.
madmasles
13-08-2010, 21:22
ShogenOFF,
Попробуйте так:While (http://www.autoitscript.com/autoit3/docs/keywords.htm#While) 1
$ahCallBack_1 = _CallBack_Init("My_Func_1", 5555)
$ahCallBack_2 = _CallBack_Init("My_Func_2", 2222)
My_Func_3()
WEnd (http://www.autoitscript.com/autoit3/docs/keywords.htm#WEnd)
Func (http://www.autoitscript.com/autoit3/docs/keywords.htm#Func) My_Func_1()
Local (http://www.autoitscript.com/autoit3/docs/keywords.htm#Local) $iX = Random (http://www.autoitscript.com/autoit3/docs/functions/Random.htm)(1, @DesktopWidth (http://www.autoitscript.com/autoit3/docs/macros.htm#@desktopwidth) - 50, 1), $iY = Random (http://www.autoitscript.com/autoit3/docs/functions/Random.htm)(1, @DesktopHeight (http://www.autoitscript.com/autoit3/docs/macros.htm#@desktopheight) - 50, 1)
MouseMove (http://www.autoitscript.com/autoit3/docs/functions/MouseMove.htm)($iX, $iY)
EndFunc (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndFunc) ;==>My_Func_1
Func (http://www.autoitscript.com/autoit3/docs/keywords.htm#Func) My_Func_2()
SoundPlay (http://www.autoitscript.com/autoit3/docs/functions/SoundPlay.htm)(@WindowsDir (http://www.autoitscript.com/autoit3/docs/macros.htm#@windowsdir) & "\media\tada.wav")
EndFunc (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndFunc) ;==>My_Func_2
Func (http://www.autoitscript.com/autoit3/docs/keywords.htm#Func) My_Func_3()
While (http://www.autoitscript.com/autoit3/docs/keywords.htm#While) 1
MsgBox (http://www.autoitscript.com/autoit3/docs/functions/MsgBox.htm)(0, "", "Будут работать все 3 функции, пока не нажмешь OK")
ExitLoop (http://www.autoitscript.com/autoit3/docs/keywords.htm#ExitLoop)
WEnd (http://www.autoitscript.com/autoit3/docs/keywords.htm#WEnd)
_CallBack_Free($ahCallBack_1)
_CallBack_Free($ahCallBack_2)
Exit (http://www.autoitscript.com/autoit3/docs/keywords.htm#Exit)
EndFunc (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndFunc) ;==>My_Func_3
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
ShogenOFF
13-08-2010, 22:48
Спасибо, madmasles. Но....ради цикла мсгбокса не хочу так заморачиваться. Думал, есть какая-нить стандартная ф-ия.
© OSzone.net 2001-2012
vBulletin v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.