|
Компьютерный форум OSzone.net » Программирование, базы данных и автоматизация действий » AutoIt » Объёденить 2 скрипта в один |
|
|
Объёденить 2 скрипта в один
|
![]() Старожил Сообщения: 379 |
Подскажите, как объёденить 2 скрипта в 1.
Вот моя ситуация: У меня в программе имеется msgbox в котором кнопка "Да" должна сама нажаться через 5 сек, если не нажали кнопку "Нет"... Для этого программа перед появлением msgbox'a запускает вторую прогут которая сначало изменяет текст кнопки "Да" на текст "Да [4]", потом текст кнопки изменяет на "Да [3]" и так далее... а потом как будет "Да [1]" нажмёт кнопку сама... Вот код 2 программы для ясности: If WinExists(@ScriptName) Then Exit EndIf AutoItWinSetTitle(@ScriptName) Opt("TrayIconHide", 1) ControlSetText("программа","","&Да","Да [5]") sleep(1000) ControlSetText("программа","","Да [5]","Да [4]") sleep(1000) ControlSetText("программа","","Да [4]","Да [3]") sleep(1000) ControlSetText("программа","","Да [3]","Да [2]") sleep(1000) ControlSetText("программа","","Да [2]","Да [1]") sleep(1000) ControlClick("программа","","Да [1]") Лично у меня проблема возникла в том, что скрипт после появления msgbox'a останавливает свою работу, пока в окне не нажать какуюнибудь кнопку, чтобы окно закрылось... И в следствии у меня не получается "держать" 2 процесса в 1 программе: Держать окно и в то же время изменять в нем текст кнопки... Заранее спасибо! |
|
------- Отправлено: 13:07, 16-11-2009 |
![]() Ветеран Сообщения: 553
|
Профиль | Отправить PM | Цитировать (С) - CreatOR
http://forum.oszone.net/thread-149514.html Global $subject = "Заголовок", $sms = "Проверка" Global $Wait = 10 Global $smsWinTitle = "Оповещение SMS" Global $smsMessage = _ 'Тема: ' & $subject & @CRLF & 'Сообщение: ' & $sms & @CRLF & 'Время до отправки SMS: %s' & @CRLF & _ 'сек. ' & @CRLF & @CRLF & 'Нажмите Отмена, если Вы НЕ хотите получить эту СМС' $isSend = _MsgBoxTimer(1, $smsWinTitle, $smsMessage, $Wait) Func _MsgBoxTimer($iFlag, $sTitle, $sText, $iMBTimeOut = 0, $hWnd=0) Local $hFile, $sMBLine, $sSet_Text, $iRet $sSet_Text = StringReplace($sText, @CRLF, '\n') $sMBLine = '#NoTrayIcon' & @CRLF $sMBLine &= 'Opt("WinWaitDelay", 1)' & @CRLF $sMBLine &= 'While Not WinExists("' & $sTitle & '")' & @CRLF $sMBLine &= ' Sleep(10)' & @CRLF $sMBLine &= 'WEnd' & @CRLF $sMBLine &= 'ControlSetText("' & $sTitle & '", "", "Static1", StringFormat("' & $sSet_Text & '", ' & $iMBTimeOut & '))' & @CRLF If $iMBTimeOut > 0 Then $sMBLine &= _ '$TimerInit = TimerInit()' & @CRLF & _ '$iTime = ' & $iMBTimeOut & @CRLF & _ 'While $iTime > 0' & @CRLF & _ ' ControlSetText("' & $sTitle & '", "", "Static1", StringFormat("' & $sSet_Text & '", $iTime))' & @CRLF & _ ' If Not WinExists("' & $sTitle & '") Then ExitLoop' & @CRLF & _ ' Sleep(1000)' & @CRLF & _ ' $iTime -= 1' & @CRLF & _ 'WEnd' EndIf $hFile = FileOpen(@TempDir & '\MiscMMB.tmp', 2) FileWrite($hFile, $sMBLine) FileClose($hFile) Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @TempDir & '\MiscMMB.tmp"') $iRet = MsgBox($iFlag, $sTitle, StringFormat($sText, $iMBTimeOut), $iMBTimeOut) While FileExists(@TempDir & '\MiscMMB.tmp') FileDelete(@TempDir & '\MiscMMB.tmp') WEnd Return $iRet EndFunc |
Отправлено: 17:47, 16-11-2009 | #2 |
Для отключения данного рекламного блока вам необходимо зарегистрироваться или войти с учетной записью социальной сети. Если же вы забыли свой пароль на форуме, то воспользуйтесь данной ссылкой для восстановления пароля. |
![]() Старожил Сообщения: 379
|
Профиль | Отправить PM | Цитировать Спасибо, но мне нужно чтобы изменялся текст кнопки...
используя только 1 скрипт |
------- Отправлено: 20:28, 16-11-2009 | #3 |
![]() Ветеран Сообщения: 553
|
Профиль | Отправить PM | Цитировать А зделать по образцу ... или всё расжевать нужно.
|
Отправлено: 20:51, 16-11-2009 | #4 |
![]() Старожил Сообщения: 379
|
Профиль | Отправить PM | Цитировать лучше разжевать xD я за разжеванные благодарность не забываю ставить
![]() ![]() |
|
------- Отправлено: 21:16, 16-11-2009 | #5 |
Must AutoIt Сообщения: 3054
|
Профиль | Сайт | Отправить PM | Цитировать Цитата sashadeg:
_MsgBoxTimer(36, 'Заголовок', 'Сообщение', 5) Func _MsgBoxTimer($iFlag, $sTitle, $sText, $iMBTimeOut = 0, $hWnd = 0) Local $hFile, $sMBLine, $sSet_Text, $iRet $sMBLine = '#NoTrayIcon' & @CRLF $sMBLine &= '$h_Title = WinGetHandle("' & $sTitle & '")' & @CRLF $sMBLine &= 'Opt("WinWaitDelay", 1)' & @CRLF $sMBLine &= 'While Not WinExists($h_Title)' & @CRLF $sMBLine &= ' Sleep(10)' & @CRLF $sMBLine &= 'WEnd' & @CRLF If $iMBTimeOut > 0 Then $sMBLine &= _ '$sButtonText = ControlGetText($h_Title, "", "Button1")' & @CRLF & _ 'ControlSetText($h_Title, "", "Button1", $sButtonText & " (' & $iMBTimeOut & ')")' & @CRLF & _ '$TimerInit = TimerInit()' & @CRLF & _ '$iTime = ' & $iMBTimeOut & @CRLF & _ 'While $iTime > 0' & @CRLF & _ ' If Not WinExists($h_Title) Then ExitLoop' & @CRLF & _ ' $sButtonText = StringRegExpReplace(ControlGetText($h_Title, "", "Button1"), " \(\d+\)$", "")' & @CRLF & _ ' ControlSetText($h_Title, "", "Button1", $sButtonText & " (" & $iTime & ")")' & @CRLF & _ ' If Not WinExists($h_Title) Then ExitLoop' & @CRLF & _ ' Sleep(1000)' & @CRLF & _ ' If Not WinExists($h_Title) Then ExitLoop' & @CRLF & _ ' $iTime -= 1' & @CRLF & _ 'WEnd' EndIf $hFile = FileOpen(@TempDir & '\MiscMMB.tmp', 2) FileWrite($hFile, $sMBLine) FileClose($hFile) Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @TempDir & '\MiscMMB.tmp"') $iRet = MsgBox($iFlag, $sTitle, StringFormat($sText, $iMBTimeOut), $iMBTimeOut) While FileExists(@TempDir & '\MiscMMB.tmp') FileDelete(@TempDir & '\MiscMMB.tmp') WEnd Return $iRet EndFunc ;==>_MsgBoxTimer |
|
------- Отправлено: 22:27, 16-11-2009 | #6 |
Must AutoIt Сообщения: 3054
|
Профиль | Сайт | Отправить PM | Цитировать Ну или вариант с самопальным (GUI)MsgBox:
#Include <GUIConstantsEx.au3> #Include <ButtonConstants.au3> #Include <WindowsConstants.au3> ; $Title = "My Custom MsgBox" $Prompt = "Вы уверены?" $CheckBoxText = "Больше не спрашивать" $hWnd = WinGetHandle("") $Ask = _GUIMsgBox(36, 2, $Title, $Prompt, 330, 120, $CheckBoxText, 10, $hWnd, "Да", "Нет") Func _GUIMsgBox($iIcoType,$iBtnNum,$sTitle,$sTxt,$iW=350,$iH=130,$sCB_Txt=-1,$iTimer=-1,$hWnd=0,$sB1Txt=-1,$sB2Txt=-1,$nExStyle=-1) Local $nYes_Button, $nNo_Button, $nOK_Button, $nCheckBox=-1, $hMsgBox_GUI, $iGuiHeight = $iH Local $nStyle = BitOR($WS_CAPTION, $WS_POPUP) Local $nMsg, $iReturnVal = 0 Local $nDefButton, $sDefButtonText = $sB1Txt, $iCounter Local $iMessageBeep = -1, $iIcon_Id = 102 Local $iOld_Opt_GOEM = Opt('GuiOnEventMode', 0) Local $iOld_Opt_GCOE = Opt('GUICloseOnESC', 0) If $iBtnNum = 1 Then $nStyle = BitOR($nStyle, $WS_SYSMENU) If BitAND($iIcoType, 262144) Then If $nExStyle = -1 Or $nExStyle = Default Then $nExStyle = 0 $nExStyle = BitOR($nExStyle, $WS_EX_TOPMOST) EndIf If $sCB_Txt <> -1 Then $iGuiHeight += 25 If $sB1Txt = -1 Then $sB1Txt = 'OK' If $sB2Txt = -1 Then $sB2Txt = 'Cancel' If IsHWnd($hWnd) Then WinSetState($hWnd, "", @SW_DISABLE) $hMsgBox_GUI = GUICreate($sTitle, $iW, $iGuiHeight, -1, -1, $nStyle, $nExStyle, $hWnd) Select Case $iIcoType = 16 Or $iIcoType = 16 + 256 $iIcon_Id = 103 $iMessageBeep = 0x00000010 Case $iIcoType = 32 Or $iIcoType = 32 + 256 $iIcon_Id = 102 $iMessageBeep = 0x00000020 Case $iIcoType = 48 Or $iIcoType = 48 + 256 $iIcon_Id = 101 $iMessageBeep = 0x00000030 Case $iIcoType = 64 Or $iIcoType = 64 + 256 $iIcon_Id = 104 $iMessageBeep = 0x00000040 EndSelect GUICtrlCreateIcon('user32.dll', $iIcon_Id, 10, 10) GUICtrlCreateLabel($sTxt, 70, 15, $iW-80, $iH-50) Select Case $iBtnNum = 2 $nYes_Button = GUICtrlCreateButton($sB1Txt, ($iW/2)-90, $iH-35, 70, 20, $BS_DEFPUSHBUTTON) $nDefButton = $nYes_Button Local $iSecButtDeffStyle = 0 If BitAND($iIcoType, 256) Then $iSecButtDeffStyle = $BS_DEFPUSHBUTTON $nNo_Button = GUICtrlCreateButton($sB2Txt, ($iW/2)+20, $iH-35, 70, 20, $iSecButtDeffStyle) If BitAND($iIcoType, 256) Then $nDefButton = $nNo_Button Case Else $nOK_Button = GUICtrlCreateButton($sB1Txt, ($iW-70)/2, $iH-35, 70, 20) GUICtrlSetState($nOK_Button, $GUI_ONTOP) $nDefButton = $nOK_Button EndSelect If $sCB_Txt <> -1 Then $nCheckBox = GUICtrlCreateCheckbox($sCB_Txt, 15, $iH-10) GUISetState(@SW_SHOW, $hMsgBox_GUI) DllCall("user32.dll", "int", "MessageBeep", "int", $iMessageBeep) If $iTimer > 0 Then $iCounter = $iTimer $iTimer = TimerInit() $sDefButtonText = GUICtrlRead($nDefButton) GUICtrlSetData($nDefButton, $sDefButtonText & ' (' & $iCounter & ')') EndIf While 1 $nMsg = GUIGetMsg() If $iTimer > 0 And TimerDiff($iTimer) >= 1000 Then $iTimer = TimerInit() $iCounter -= 1 GUICtrlSetData($nDefButton, $sDefButtonText & ' (' & $iCounter & ')') If $iCounter < 0 Then $nMsg = $nDefButton EndIf Select Case $iBtnNum = 2 And $nMsg = $nYes_Button $iReturnVal = 6 ExitLoop Case $iBtnNum = 2 And $nMsg = $nNo_Button $iReturnVal = 7 ExitLoop Case $nMsg = -3 Or ($nMsg = $nOK_Button And $iBtnNum <> 2) $iReturnVal = 1 ExitLoop EndSelect WEnd If GUICtrlRead($nCheckBox) = 1 Then $iReturnVal += 8 If IsHWnd($hWnd) Then WinSetState($hWnd, "", @SW_ENABLE) GUIDelete($hMsgBox_GUI) If IsHWnd($hWnd) Then GUISwitch($hWnd) Opt('GuiOnEventMode', $iOld_Opt_GOEM) Opt('GUICloseOnESC', $iOld_Opt_GCOE) Return $iReturnVal EndFunc |
------- Отправлено: 22:34, 16-11-2009 | #7 |
![]() Старожил Сообщения: 379
|
Профиль | Отправить PM | Цитировать В этих скриптах идёт 2 процесса вместе? Мне как бы это главнее
![]() |
------- Отправлено: 07:43, 17-11-2009 | #8 |
![]() Старожил Сообщения: 379
|
Профиль | Отправить PM | Цитировать Creat0R, я использовал твой первый код...
Просит endf =( А куда его вставить я не понимаю.... Где ошибка??? Вот вся прога: Opt("TrayAutoPause", 0) TrayTip("The Internet is connected?", "Подождите...", 5, 1) $var = Ping("www.google.com") If $var <> 0 Then MsgBox(64, "The Internet is connected?", "Все в порядке, Интрернет работает :)"& @CRLF &"Время подключения: " & @hour &":"& @min &":"&@sec) Exit Else $1=_MsgBoxTimer(36, 'Заголовок', 'Сообщение', 5) Func _MsgBoxTimer($iFlag, $sTitle, $sText, $iMBTimeOut = 0, $hWnd = 0) Local $hFile, $sMBLine, $sSet_Text, $iRet $sMBLine = '#NoTrayIcon' & @CRLF $sMBLine &= '$h_Title = WinGetHandle("' & $sTitle & '")' & @CRLF $sMBLine &= 'Opt("WinWaitDelay", 1)' & @CRLF $sMBLine &= 'While Not WinExists($h_Title)' & @CRLF $sMBLine &= ' Sleep(10)' & @CRLF $sMBLine &= 'WEnd' & @CRLF If $iMBTimeOut > 0 Then $sMBLine &= _ '$sButtonText = ControlGetText($h_Title, "", "Button1")' & @CRLF & _ 'ControlSetText($h_Title, "", "Button1", $sButtonText & " (' & $iMBTimeOut & ')")' & @CRLF & _ '$TimerInit = TimerInit()' & @CRLF & _ '$iTime = ' & $iMBTimeOut & @CRLF & _ 'While $iTime > 0' & @CRLF & _ ' If Not WinExists($h_Title) Then ExitLoop' & @CRLF & _ ' $sButtonText = StringRegExpReplace(ControlGetText($h_Title, "", "Button1"), " \(\d+\)$", "")' & @CRLF & _ ' ControlSetText($h_Title, "", "Button1", $sButtonText & " (" & $iTime & ")")' & @CRLF & _ ' If Not WinExists($h_Title) Then ExitLoop' & @CRLF & _ ' Sleep(1000)' & @CRLF & _ ' If Not WinExists($h_Title) Then ExitLoop' & @CRLF & _ ' $iTime -= 1' & @CRLF & _ 'WEnd' EndIf $hFile = FileOpen(@TempDir & '\MiscMMB.tmp', 2) FileWrite($hFile, $sMBLine) FileClose($hFile) Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @TempDir & '\MiscMMB.tmp"') $iRet = MsgBox($iFlag, $sTitle, StringFormat($sText, $iMBTimeOut), $iMBTimeOut) While FileExists(@TempDir & '\MiscMMB.tmp') FileDelete(@TempDir & '\MiscMMB.tmp') WEnd Return $iRet EndFunc ;==>_MsgBoxTimer EndIf If $1<>7 Then TrayTip("The Internet is connected?","Программа ожидает подключения сети Интернет...", 7, 1) While 1 $var = Ping("www.google.com") If $var <> 0 Then MsgBox(64, "The Internet is connected?", "Все в порядке, Интрернет работает :)"& @CRLF &"Время подключения: " & @hour &":"& @min &":"&@sec) Exit EndIf sleep(500) WEnd Else TrayTip("The Internet is connected?","Bye-bye!!!", 3, 1) Sleep(3000) EndIf |
------- Последний раз редактировалось sashadeg, 17-11-2009 в 11:53. Отправлено: 09:06, 17-11-2009 | #9 |
Старожил Сообщения: 307
|
Профиль | Отправить PM | Цитировать Саму функцию лушче всегда описывать после всего кода (по крайней мере не в середине "проверки условия" где у тебя), а вызов этой функции - в нужном тебе месте.
|
------- Отправлено: 15:59, 17-11-2009 | #10 |
|
![]() |
Участник сейчас на форуме |
![]() |
Участник вне форума |
![]() |
Автор темы |
![]() |
Сообщение прикреплено |
| |||||
Название темы | Автор | Информация о форуме | Ответов | Последнее сообщение | |
Как объединить два скрипта в один | Fantasy22 | AutoIt | 1 | 04-12-2009 12:32 | |
Интернет - не пускает ни один браузер,выбрасывает на один и тот же сайт | mopss | Microsoft Windows 2000/XP | 3 | 28-11-2009 02:17 | |
CMD/BAT - [решено] два скрипта объеденить в один. | exo | Скриптовые языки администрирования Windows | 8 | 16-10-2009 13:28 | |
Модификация скрипта | venuko | Вебмастеру | 1 | 31-03-2009 19:55 | |
Win32 API - mciSendString из скрипта | pva | Программирование и базы данных | 9 | 07-11-2008 13:23 |
|