[архив - Часть 2] AutoIt скрипты

Ответить
 • Просмотры: 16
Аватара пользователя
Creat0R

Re: [архив - Часть 2] AutoIt скрипты

Сообщение Creat0R »

Функция _ControlTab():



Код: Выделить всё

;===============================================================================
; Function Name:   _ControlTab()
; Description:     Sends a command to a SysTab32 Control.
; Syntax:          _ControlTab ( $hWnd, $sText, $sCommand  [, $sParam1 [, $sParam2 [, $sParam3]]] )
;
; Parameter(s):    $hWnd       = Window Handle/Title.
;                  $sText      = Window Text.
;                  $sCommand   = Command to send to the control (See "Return Value(s)").
;                  $sParam1, $sParam2, $sParam3 = Additional parameters required by some commands.
;
; Requirement(s):  None.
;
; Return Value(s): Depends on command as shown below. In case an invalid command or window/control, @error set to 1 and return ""
;                       If $sCommand Equel...
;                          "GetItemState" - State of the tab item returned.
;                            ($sParam1 defines what tab item (zero-based) will be used - 0 is the default).
;                            On failure return "" and set @error to 1.
;
;                          "GetItemText" - Text of the tab item returned.
;                            ($sParam1 defines what tab item (zero-based) will be used - 0 is the default).
;                            On failure return "" and set @error to 1.
;
;                          "GetItemImage" - Image Index of the tab item returned.
;                            ($sParam1 defines what tab item (zero-based) will be used - 0 is the default).
;                            On failure return "" and set @error to 1.
;
;                          "CurrentTab" - Returns the current Tab shown of a SysTabControl32.
;                            On failure return -1 and set @error to 1.
;
;                          "TabRight" - Moves to the next tab to the right of a SysTabControl32.
;                            ($sParam1 defines how many times move to the right tab - 1 is the default).
;                            On failure return -1 and set @error to 1.
;
;                          "TabLeft" - Moves to the next tab to the left of a SysTabControl32.
;                            ($sParam1 defines how many times move to the left tab - 1 is the default).
;                            On failure return -1 and set @error to 1.
;
;                          "TabSelect" - Select specific tab item (base on given zero-based index) of a SysTabControl32.
;                            On failure return -1 and set @error to 1.
;
;                          "GetTabsCount" - Returns the number of total tab items of a SysTabControl32.
;                            On failure return -1 and set @error to 1.
;
;                          "FindTab" - Search For tab item with specific text..
;                          In this case used all three additional parameters:
;                               $sParam1 - defines what text to find.
;                               $sParam2 - defines from what tab item the search will start (zero-based).
;                               $sParam3 - defines search type...
;                               If $sParam3 = True Then will be performed a partial search of the string in the tab item text.
;                           On seccess: return the tab item index taht contain founded text.
;                           On failure:
;                               If $sParam2 >= total tabs count, return -1 and set @error to 1.
;                               If could not find tab, return -1.
;
; Author(s):       G.Sandler a.k.a CreatoR
;
; Example(s):
;     $TabText = _ControlTab("Properties", "", "GetItemText", 1) ;Will return the text of second tab from the left side.
;===============================================================================
Func _ControlTab($hWnd, $sText, $sCommand, $sParam1="", $sParam2="", $sParam3="")
    Local Const $TCM_FIRST = 0x1300
    Local $hTab = ControlGetHandle($hWnd, $sText, "SysTabControl321")
    Switch $sCommand
        Case "GetItemState", "GetItemText", "GetItemImage"
            Local Const $TagTCITEM = "int Mask;int State;int StateMask;ptr Text;int TextMax;int Image;int Param"
            Local Const $TCIF_ALLDATA = 0x0000001B
            Local Const $TCM_GETITEM = $TCM_FIRST + 5
            Local $tBuffer  = DllStructCreate("char Text[4096]")
            Local $pBuffer  = DllStructGetPtr($tBuffer)
            Local $tItem    = DllStructCreate($tagTCITEM)
            Local $pItem    = DllStructGetPtr($tItem)
            DllStructSetData($tItem, "Mask", $TCIF_ALLDATA)
            DllStructSetData($tItem, "TextMax", 4096)
            DllStructSetData($tItem, "Text", $pBuffer)
            If $sParam1 = -1 Or $sParam1 = "" Then
                $sParam1 = _ControlTab($hWnd, $sText, "CurrentTab")
                If @error Then Return SetError(1, 0, "")
            EndIf
            DllCall("user32.dll", "long", "SendMessage", "hwnd", $hTab, "int", $TCM_GETITEM, "int", $sParam1, "int", $pItem)
            If @error Then Return SetError(1, 0, "")
            If $sCommand = "GetItemState" Then Return DllStructGetData($tItem, "State")
            If $sCommand = "GetItemText" Then Return DllStructGetData($tBuffer, "Text")
            If $sCommand = "GetItemImage" Then Return DllStructGetData($tItem, "Image")
        Case "CurrentTab"
            Local $iRet = ControlCommand($hWnd, $sText, "SysTabControl321", $sCommand, "")
            If @error Then Return SetError(1, 0, -1)
            Return $iRet - 1
        Case "TabRight", "TabLeft"
            Local $iRet = 0
            If Not IsNumber($sParam1) Or $sParam1 <= 0 Then $sParam1 = 1
            For $i = 1 To $sParam1
                $iRet = ControlCommand($hWnd, $sText, "SysTabControl321", $sCommand, "")
                If @error Then Return SetError(1, 0, -1)
            Next
            Return $iRet
        Case "TabSelect"
            Local Const $TCM_SETCURFOCUS = $TCM_FIRST + 48
            Local $iRet = DllCall("user32.dll", "long", "SendMessage", _
                "hwnd", $hTab, "int", $TCM_SETCURFOCUS, "int", $sParam1, "int", 0)
            If @error Then Return SetError(1, 0, -1)
            Return $iRet[0]
        Case "GetTabsCount"
            Local Const $TCM_GETITEMCOUNT = $TCM_FIRST + 4
            Local $iRet = DllCall("user32.dll", "long", "SendMessage", "hwnd", $hTab, "int", $TCM_GETITEMCOUNT, "int", 0, "int", 0)
            If @error Then Return SetError(1, 0, -1)
            Return $iRet[0]
        Case "FindTab"
            If Not IsNumber($sParam2) Or $sParam2 < 0 Then $sParam2 = 0
            Local $sTabText
            Local $iCnt = _ControlTab($hWnd, $sText, "GetTabsCount")
            If $sParam2 >= $iCnt Then Return SetError(1, 0, -1)
            For $i = $sParam2 To $iCnt
                $sTabText = _ControlTab($hWnd, $sText, "GetItemText", $i)
                If $sParam3 = True And StringInStr($sTabText, $sParam1) Then Return $i
                If $sTabText = $sParam1 Then Return $i
            Next
            Return -1
        Case Else
            Return SetError(1, 0, "")
    EndSwitch
EndFunc   ;==> _ControlTab
Аватара пользователя
Creat0R

Re: [архив - Часть 2] AutoIt скрипты

Сообщение Creat0R »

amel27,

Мы мучались с DllCallBack (чтобы скрипт не останавливался на момент перемещения окна), когда можно было просто использовать обычный GUIRegisterMsg($WM_TIMER, "WM_TIMER") Изображение - По сути тот же CallBack, но намного проще.



Инфу чисто случайно откопал из скрипта “Network profiles” (на оф. форуме) ...





Код:

Код: Выделить всё

#include 
Global Const $WM_TIMER = 0x0113
$Gui = GuiCreate("_TimerFunc Test", 300, 130)
$Left = -200
$Label = GUICtrlCreateLabel("Drag the window, i am just a runing text ;)", $Left, 100)
$RunCheckBox = GUICtrlCreateCheckbox("Run text", 20, 40)
GUISetState()
While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case -3
            _AdlibDisable($Gui)
            Exit
        Case $RunCheckBox
            If GUICtrlRead($RunCheckBox) = 1 Then
                _AdlibEnable("_TimerFunc", $Gui, 30)
            Else
                _AdlibDisable($Gui)
            EndIf
    EndSwitch
WEnd
Func _AdlibEnable($sFunction, $hWnd, $iTime=250)
    GUIRegisterMsg($WM_TIMER, $sFunction)
    DllCall("User32.dll", "int", "SetTimer", "hwnd", $hWnd, "int", 50, "int", $iTime, "int", 0)
EndFunc
Func _AdlibDisable($hWnd)
    GUIRegisterMsg($WM_TIMER, "")
    DllCall("user32.dll", "int", "KillTimer", "hwnd", $hWnd, "int_ptr", 50)
EndFunc
Func _TimerFunc()
    $Left += 2
    If $Left >= 300 Then $Left = -200
    ControlMove($Gui, "", $Label, $Left, 100)
EndFunc
Аватара пользователя
Rogalik

Re: [архив - Часть 2] AutoIt скрипты

Сообщение Rogalik »

1. Можно ли скрыть диалоговые окна при автоустановке приложений через AutoIt?

2. Почему в скриптах для автоустановки приложений вначале закомментированы строки с блокировкой ввода? Бывают проблемы?
Аватара пользователя
Creat0R

Re: [архив - Часть 2] AutoIt скрипты

Сообщение Creat0R »

Rogalik,

1. Да, см. функцию WinSetState("Title", "Text", @SW_HIDE).

2. Проблемы бывают в частности и за того что пользователь “произвольничает” в момент установки Изображение , но скрипт должен быть оптимизирован так, чтобы пользователь ничего немог нарушить - блокирвание ввода должно ставиться в крайних случаях.
Аватара пользователя
HORRIBLE

Re: [архив - Часть 2] AutoIt скрипты

Сообщение HORRIBLE »

----------------------------------------------

Подскажите пожалуйста как можно сделать проверку выполнения скрипта, а именно не застыл ли он на какой нить строчке???

Если застыл то закрываем работу скрипта.

-----------------------------------------------------------------------------------------------------------------















Может кто нить сталкивался с таким, почему на виртуальной машинке при установки программы через авто ит, не срабатывает команда Send("^c"), должен скопировать, а не копирует, или Send("^v") должен вставить то что скопировал, а вставляет v. Проверил тот же самый скрипт на другом компе, не на виртуальной машине, все замечательно копируется и вставляется.





Спасибо.
Аватара пользователя
NikLok

Re: [архив - Часть 2] AutoIt скрипты

Сообщение NikLok »

HORRIBLE, Сам сталкиваюсь часто с такими ситуациями. Мне видится, что если бы скрипт выполнялся построчно другим автоит скриптом, с этим бы не было проблем! Поэтому то (в дополнение кдругим причинам) хочется иметь аналог BSPI или WMI написанный на автоит!!!

А для копирования вставки попробуй использовать пару:

Код:

Код: Выделить всё

ClipPut($nm)
Send('+{Ins}')
Аватара пользователя
Rogalik

Re: [архив - Часть 2] AutoIt скрипты

Сообщение Rogalik »

HORRIBLE, Мало ли, может захочишь установку делать с ключами...

RunWait ( 'msiexec /i "'&$file&'" /L1049 /S /v/qn')



amel27, Creat0R, помогите сделать скрипт плз.... Нужно определить операционку, если VISTA выдаёт сообщение, если XP выдаёт сообщение. (сам бы сделал, но нет под рукой ВИСТЫ, может Вы вкурсе по каким файлам можно определять.....)

Я использовал If @OSType="WIN32_NT" Then.... , но почему то не определяется ВИСТА (наверно рна тоже относится к @OSType="WIN32_NT"). Заранее СПС!



Creat0R, ты мне давал скрипт который выполняет копирование папки с показателем времени от винды...

1. Нужно сделать так-если файлы есть - перезаписывать...

2. Возможно ли сделать на скрипте чтобы показывало остаток времени (вообщем как в винде)



*автор скрипта возможно и amel27, но разговор был с тобой....
Аватара пользователя
Creat0R

Re: [архив - Часть 2] AutoIt скрипты

Сообщение Creat0R »

Rogalik,


Цитата:



Но тогда нельзя будет работать с его контролами



Вопрос был в том, можно ли скрыть окно Изображение



Да, в скрытых окнах нажать ничего нельзя, но можно в свёрнутых (WinSetState("Title", "Text", @SW_MINIMIZE)) Изображение.
Аватара пользователя
Rogalik

Re: [архив - Часть 2] AutoIt скрипты

Сообщение Rogalik »

Creat0R, Ща нарою, не убегай...



Вот на
этой
страничке наше обсуждение, но всё что ты писал я копировал в Autolt и у меня вылазила целая куча ошибок (пробовал только что на свежей версии-непомогает).... Сразу говорю-мне нужно скопировать с диска папку i386 на С диск...
Аватара пользователя
HORRIBLE

Re: [архив - Часть 2] AutoIt скрипты

Сообщение HORRIBLE »

TERMINAL,


Цитата:



вылазила целая куча ошибок



Каких?



Вот это разве не делает то что нужно:





Код:

Код: Выделить всё

_CopyWithProgress("D:\i386", "C:\i386", $FOR_COPY, BitOR($FOF_NOCONFIRMMKDIR, $FOF_NOCONFIRMATION))

Функции
отсюда
.
Ответить

Вернуться в «AutoIt»