Имя пользователя:
Пароль:
 

Показать сообщение отдельно

Аватара для Creat0R

Must AutoIt


Сообщения: 3054
Благодарности: 1009

Профиль | Сайт | Отправить PM | Цитировать


Цитата mitiya:
у меня скрипт без окон »
У AutoIt есть встроенное (скрытое) окно, его и использует моя функция.

Цитата mitiya:
самое главное они запускаются на терминальном сервере, и в результате скрпты всех пользователей в очередь встают, а надо чтоб очередь создавалась у каждого пользователя своя »
Вот это «самое главное» следует указывать в самом начале, при созданий темы.

Можно попробовать так:

Код: Выделить весь код
#include "WinAPIEx.au3" ;http://autoit-script.ru/index.php/topic,47.0.html

$iQueue_Position = _AppSetQueue(100)
MsgBox(64, 'Title', StringFormat('Process: %i\nQueue position: %i', @AutoItPID, $iQueue_Position))

; #FUNCTION# ====================================================================================================
; Name...........: _AppSetQueue
; Description....: Sets Queue for the next instances of this script.
; Syntax.........: _AppSetQueue($iWait = 100, $sUserName = @UserName)
; Parameters.....: $iWait [Optional] - Waiting queue (default is 100 ms).
;                  $sUserName [Optional] - Limit queue for specfific system user.
;
;
; Return values..: Success - Return Queue position (0 if this is the first instance of the program).
;                  Failure - None.
;
; Author.........: G.Sandler (CreatoR)
; Modified.......:
; Remarks........:
; Related........:
; Link...........:
; Example........:
; ===============================================================================================================
Func _AppSetQueue($iWait = 100, $sUserName = @UserName)
    Local $sUnique_Win, $sScriptName, $aProcList, $aWinList, $iQueue, $hPrev_Queue_Win, $aProcUser

    $sUnique_Win = "_Au3_Queue_Window_"
    $sScriptName = @ScriptName

    If Not @Compiled Then
        $sScriptName = StringRegExpReplace(@AutoItExe, '^.*\\', '')
    EndIf

    $aProcList = ProcessList($sScriptName)
    $aWinList = WinList($sUnique_Win)

    $iQueue = 0
    $hPrev_Queue_Win = 0

    If UBound($aWinList) > 1 Then
        $hPrev_Queue_Win = $aWinList[1][1]
    EndIf

    For $i = 1 To UBound($aProcList)-1
        $aProcUser = _WinAPI_GetProcessUser($aProcList[$i][1])

        If $aProcUser[0] <> $sUserName Then
            ContinueLoop
        EndIf

        For $j = 1 To UBound($aWinList)-1
            If $aWinList[$j][0] = $sUnique_Win And WinGetProcess($aWinList[$j][1]) = $aProcList[$i][1] Then
                $iQueue += 1

                If $j > 1 Then
                    $hPrev_Queue_Win = $aWinList[$j-1][1]
                EndIf

                ExitLoop
            EndIf
        Next
    Next

    AutoItWinSetTitle($sUnique_Win & "__")
    ControlSetText($sUnique_Win & "__", "", "Edit1", $iQueue + 1)
    AutoItWinSetTitle($sUnique_Win)

    If $iQueue = 0 Then
        Return 0
    EndIf

    While WinExists($hPrev_Queue_Win)
        Sleep($iWait)
    WEnd

    Return $iQueue
EndFunc
нужно подключить библиотеку WinAPIEx.au3.

-------
“Сделай так просто, как возможно, но не проще этого.”... “Ты никогда не решишь проблему, если будешь думать так же, как те, кто её создал.”

Альберт Эйнштейн

P.S «Не оказываю техподдержку через ПМ/ICQ, и по email - для этого есть форум. ©»

http://creator-lab.ucoz.ru/Images/Icons/autoit_icon.png Русское сообщество AutoIt | http://creator-lab.ucoz.ru/Images/Ic...eator_icon.png CreatoR's Lab | http://creator-lab.ucoz.ru/Images/Icons/oac_icon.png Opera AC Community


Последний раз редактировалось Creat0R, 18-01-2012 в 09:03.

Это сообщение посчитали полезным следующие участники:

Отправлено: 22:52, 17-01-2012 | #15