Показать полную графическую версию : Нажатие кнопки в программе
Приветствую
Помогите решить вопрос нужен маленький скрипт
который нажимал кнопу на старт(она же после нажатия переходит в стоп) dowloadmaster через определеный период времени
сколько не пытался но програмист из меня некудышный. был бы благодарен за помощь.
может кто подскажет или хоть укажет направления где есть похожие примеры.
кнопку нужно нажимать имено в программе.
madmasles
20-12-2010, 12:45
bestkz,
Попробуйте так получить информацию:#include (http://www.autoitscript.com/autoit3/docs/keywords.htm##include) <GuiToolbar.au3>
#include (http://www.autoitscript.com/autoit3/docs/keywords.htm##include) <GuiListView.au3>
$sDM = '[Class:TMainForm;Title:Download Master]'
$sPathDM = @ProgramFilesDir (http://www.autoitscript.com/autoit3/docs/macros.htm#@programfilesdir) & '\Download Master\dmaster.exe'
Run (http://www.autoitscript.com/autoit3/docs/functions/Run.htm)($sPathDM)
WinWait (http://www.autoitscript.com/autoit3/docs/functions/WinWait.htm)($sDM)
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) Not (http://www.autoitscript.com/autoit3/docs/keywords.htm#Not) WinActive (http://www.autoitscript.com/autoit3/docs/functions/WinActive.htm)($sDM) Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then) WinActivate (http://www.autoitscript.com/autoit3/docs/functions/WinActivate.htm)($sDM)
$hHandleDM = WinWaitActive (http://www.autoitscript.com/autoit3/docs/functions/WinWaitActive.htm)($sDM)
$hToolbar = ControlGetHandle (http://www.autoitscript.com/autoit3/docs/functions/ControlGetHandle.htm)($hHandleDM, '', '[CLASS:TToolBar; INSTANCE:1]')
$hListView = ControlGetHandle (http://www.autoitscript.com/autoit3/docs/functions/ControlGetHandle.htm)($hHandleDM, '', '[CLASS:TListView; INSTANCE:2]')
$iCountTB = _GUICtrlToolbar_ButtonCount (http://dundats.mvps.org/help/html/libfunctions/_guictrltoolbar_buttoncount.htm)($hToolbar)
MsgBox (http://www.autoitscript.com/autoit3/docs/functions/MsgBox.htm)(64, 'Toolbar', 'Кнопок: ' & $iCountTB)
For (http://www.autoitscript.com/autoit3/docs/keywords.htm#For) $i = 0 To (http://www.autoitscript.com/autoit3/docs/keywords.htm#To) $iCountTB - 1
$sText = _GUICtrlToolbar_GetButtonText (http://dundats.mvps.org/help/html/libfunctions/_guictrltoolbar_getbuttontext.htm)($hToolbar, $i)
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) $sText Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
$bEnable = _GUICtrlToolbar_IsButtonEnabled (http://dundats.mvps.org/help/html/libfunctions/_guictrltoolbar_isbuttonenabled.htm)($hToolbar, $i)
MsgBox (http://www.autoitscript.com/autoit3/docs/functions/MsgBox.htm)(64, 'Индекс: ' & $i, 'Кнопка: ' & $sText & @CRLF (http://www.autoitscript.com/autoit3/docs/macros.htm#@crlf) & 'Активна: ' & $bEnable)
;If $bEnable And $sText = 'Старт' Then
; _GUICtrlToolbar_ClickButton($hToolbar, $i)
;EndIf
EndIf (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndIf)
Next (http://www.autoitscript.com/autoit3/docs/keywords.htm#Next)
$iCountItem = _GUICtrlListView_GetItemCount (http://dundats.mvps.org/help/html/libfunctions/_guictrllistview_getitemcount.htm)($hListView)
$iCountColumn = _GUICtrlListView_GetColumnCount (http://dundats.mvps.org/help/html/libfunctions/_guictrllistview_getcolumncount.htm)($hListView)
MsgBox (http://www.autoitscript.com/autoit3/docs/functions/MsgBox.htm)(64, 'ListView', 'Строк: ' & $iCountItem & @CRLF (http://www.autoitscript.com/autoit3/docs/macros.htm#@crlf) & 'Столбцов: ' & $iCountColumn)
For (http://www.autoitscript.com/autoit3/docs/keywords.htm#For) $i = 0 To (http://www.autoitscript.com/autoit3/docs/keywords.htm#To) $iCountItem - 1
$sMessage = ''
For (http://www.autoitscript.com/autoit3/docs/keywords.htm#For) $j = 0 To (http://www.autoitscript.com/autoit3/docs/keywords.htm#To) $iCountColumn - 1
$sMessage &= _GUICtrlListView_GetItemText (http://dundats.mvps.org/help/html/libfunctions/_guictrllistview_getitemtext.htm)($hListView, $i, $j) & @CRLF (http://www.autoitscript.com/autoit3/docs/macros.htm#@crlf)
Next (http://www.autoitscript.com/autoit3/docs/keywords.htm#Next)
MsgBox (http://www.autoitscript.com/autoit3/docs/functions/MsgBox.htm)(64, 'Индекс: ' & $i, $sMessage)
Next (http://www.autoitscript.com/autoit3/docs/keywords.htm#Next)А дальше делайте то, что Вам надо. Все функции для этого есть.
Спасибо немного разобрался тепер все запускается а неподскажете как зделать чтобы скрипт запускался через определеный интервал времени весь скрипт?
madmasles
20-12-2010, 18:03
bestkz,
Sleep(),
TimerInit(), TimerDiff().
Например:$iPause = 5 ;секунд
MsgBox (http://www.autoitscript.com/autoit3/docs/functions/MsgBox.htm)(64, 'Sleep()', 'Запускаем паузу на ' & $iPause & ' секунд')
Sleep (http://www.autoitscript.com/autoit3/docs/functions/Sleep.htm)($iPause * 1000)
MsgBox (http://www.autoitscript.com/autoit3/docs/functions/MsgBox.htm)(64, 'Sleep()', 'Кончилась пауза в ' & $iPause & ' секунд')
MsgBox (http://www.autoitscript.com/autoit3/docs/functions/MsgBox.htm)(64, 'TimerDiff()', 'Запускаем паузу на ' & $iPause & ' секунд')
$iStart = TimerInit (http://www.autoitscript.com/autoit3/docs/functions/TimerInit.htm)()
While (http://www.autoitscript.com/autoit3/docs/keywords.htm#While) 1
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) TimerDiff (http://www.autoitscript.com/autoit3/docs/functions/TimerDiff.htm)($iStart) >= $iPause * 1000 Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then) ExitLoop (http://www.autoitscript.com/autoit3/docs/keywords.htm#ExitLoop)
Sleep (http://www.autoitscript.com/autoit3/docs/functions/Sleep.htm)(10)
ToolTip (http://www.autoitscript.com/autoit3/docs/functions/ToolTip.htm)(Round (http://www.autoitscript.com/autoit3/docs/functions/Round.htm)(TimerDiff (http://www.autoitscript.com/autoit3/docs/functions/TimerDiff.htm)($iStart) / 1000, 2), 0, 0)
WEnd (http://www.autoitscript.com/autoit3/docs/keywords.htm#WEnd)
MsgBox (http://www.autoitscript.com/autoit3/docs/functions/MsgBox.htm)(64, 'TimerDiff()', 'Кончилась пауза в ' & $iPause & ' секунд')
© OSzone.net 2001-2012
vBulletin v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.
Available in ZeroNet 1osznRoVratMCN3bFoFpR2pSV5c9z6sTC