Перейти из форума на сайт.

НовостиФайловые архивы
ПоискАктивные темыТоп лист
ПравилаКто в on-line?
Вход Забыли пароль? Первый раз на этом сайте? Регистрация
Компьютерный форум Ru.Board » Компьютеры » Программы » AutoIT (Часть 3)

Модерирует : gyra, Maz

gyra (23-01-2020 10:51): AutoIT (Часть 4)  Версия для печати • ПодписатьсяДобавить в закладки
На первую страницук этому сообщениюк последнему сообщению

   

madmasles

Advanced Member
Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору

Код:
#include <GuiToolbar.au3>
#include <GuiListView.au3>
#include <MenuConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPIEx.au3>;http://autoit-script.ru/index.php/topic,47.0.html
 
;возобновляет закачку (отдачу), закрывает заданные процессы и отключает монитор,
;если пользователь бездействовал $iMaxTime миллисекунд
 
Opt('MustDeclareVars', 1)
Opt('TrayMenuMode', 1)
 
Global $sTitle = @ScriptName & '{[/@$@\]}', $iMaxTime = 600000, _ ;Max время бездействия пользователей (10 минут)
        $iIdleTime, $iIdleTimeOld, $fMonitorOff, $iSleep = 500, $fIdleTime = True
 
If WinExists($sTitle) Then Exit
AutoItWinSetTitle($sTitle)
 
HotKeySet('{Esc}', '_Exit');кнопка Esc - выход
TraySetToolTip('<µTorrent Go>' & @CRLF & 'Выход - Esc')
_WinAPI_EmptyWorkingSet()
While 1
    $iIdleTime = _WinAPI_GetIdleTime()
    ConsoleWrite($iIdleTime & @CR)
    If $fIdleTime Then
        If $iIdleTime > $iMaxTime Then
            HotKeySet('{Esc}')
            _Utorrent_Go()
            If Not @error Then
                $fIdleTime = False
            Else
                $fIdleTime = True
            EndIf
            _Kill_Processes()
            _Monitor_Off()
            If Not @error Then
                $fMonitorOff = True
                $iIdleTimeOld = $iIdleTime
                $fIdleTime = False
            Else
                $fIdleTime = True
            EndIf
            HotKeySet('{Esc}', '_Exit')
        EndIf
    EndIf
    If $fMonitorOff Then
        If $iIdleTimeOld > $iIdleTime Then
            $fIdleTime = True
            $fMonitorOff = False
            $iIdleTimeOld = 0
        EndIf
    EndIf
    Sleep($iSleep)
WEnd
#region Func
Func _Exit()
    Exit
EndFunc   ;==>_Exit
 
Func _Utorrent_Go()
    ;посмотрите, какой у Вас µTorrent, я проверял на µTorrent 3.0
    Local $s_Title = '[Title:µTorrent 3.0;Class:µTorrent4823DF041B09]', $s_Process = 'utorrent.exe', $h_Win, _
            $_hToolBar, $h_ListView, $i_ID_TB, $i_State, $aItemSelect
 
    If Not ProcessExists($s_Process) Then Return SetError(0)
    If WinExists($s_Title) Then
        $h_Win = WinGetHandle($s_Title)
    EndIf
    If Not $h_Win Then Return SetError(1)
    $_hToolBar = ControlGetHandle($h_Win, '', '[CLASS:ToolbarWindow32; INSTANCE:3]')
    If Not $_hToolBar Then Return SetError(1)
    $h_ListView = ControlGetHandle($h_Win, '', '[CLASS:SysListView32; INSTANCE:1]')
    If Not $h_ListView Then Return SetError(1)
    $i_ID_TB = _GUICtrlToolbar_IndexToCommand($_hToolBar, 8)
    If Not $i_ID_TB Then Return SetError(1)
    $aItemSelect = _GUICtrlListView_GetSelectedIndices($h_ListView, True)
    If Not _GUICtrlListView_SetItemSelected($h_ListView, -1) Then Return SetError(1)
    $i_State = _GUICtrlToolbar_GetButtonState($_hToolBar, $i_ID_TB)
    If $i_State = -1 Then Return SetError(1)
    If BitAND($i_State, $TBSTATE_ENABLED) Then
        _SendMessage($_hToolBar, $WM_COMMAND, $i_ID_TB, $_hToolBar)
    EndIf
    $i_State = _GUICtrlToolbar_GetButtonState($_hToolBar, $i_ID_TB)
    _GUICtrlListView_SetItemSelected($h_ListView, -1, False)
    If $aItemSelect[0] Then
        For $i = 1 To $aItemSelect[0]
            _GUICtrlListView_SetItemSelected($h_ListView, $aItemSelect[$i])
        Next
    EndIf
    If BitAND($i_State, $TBSTATE_ENABLED) Then Return SetError(1)
    Return SetError(0)
EndFunc   ;==>_Utorrent_Go
 
Func _Monitor_Off()
    Local $h_Win, $Off = 2
    $h_Win = WinGetHandle('[Title:Program Manager;Class:Progman]')
    If Not $h_Win Then Return SetError(1)
    _SendMessage($h_Win, $WM_SYSCOMMAND, $SC_MONITORPOWER, $Off)
    Return SetError(@error)
EndFunc   ;==>_Monitor_Off
 
Func _Kill_Processes()
    ;Впишите (поменяйте) в массив(е) названия процессов, которые надо закрыть.
    ;цифра ... = [2,... (2) - кол-во процессов
    ;цифра $a_Processes[3]... (3) - кол-во процессов + 1
    Local $a_Processes[3] = [2, 'war3.exe', 'AkelPad.exe'], $a_List
    For $i = 1 To $a_Processes[0]
        $a_List = ProcessList($a_Processes[$i])
        If $a_List[0][0] Then
            For $j = 1 To $a_List[0][0]
                ProcessClose($a_List[$j][1])
            Next
        EndIf
    Next
    Return
EndFunc   ;==>_Kill_Processes
#endregion Func

Всего записей: 1277 | Зарегистр. 25-09-2008 | Отправлено: 19:19 23-07-2011 | Исправлено: madmasles, 20:40 26-07-2011
   

На первую страницук этому сообщениюк последнему сообщению

Компьютерный форум Ru.Board » Компьютеры » Программы » AutoIT (Часть 3)
gyra (23-01-2020 10:51): AutoIT (Часть 4)


Реклама на форуме Ru.Board.

Powered by Ikonboard "v2.1.7b" © 2000 Ikonboard.com
Modified by Ru.B0ard
© Ru.B0ard 2000-2024

BitCoin: 1NGG1chHtUvrtEqjeerQCKDMUi6S6CG4iC

Рейтинг.ru