Jump to content

browse through the radio items with the keyboard


Darien
 Share

Recommended Posts

I can't even begin to try and aswer that question, I'm pretty sure most others won't be able to either. If you mean to go from one radio button to another on a program, then use Tab or the arrow keys in a lot of cases. If that's not what you want, you need to give us a LOT more information.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

  • Moderators

How about posting your code so we can take a look? I'm working on a couple GUIs that rely heavily on Radio Buttons, and they all work with TABs.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

deja vu?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

My code is somewhat complex and the variables are in Portuguese, but here goes a part:

Func Seleciona_item_radio ( $cabecalho , $lista_itens , $lista_detalhes , $rodape , $lista_botoes , $largura_janela )

    ; Cria as matrizes de ítens, detalhes e botões ---------------------------------------------------------------------------------

    $matriz_itens      = StringSplit ( $lista_itens     , "|" )
    $matriz_detalhes = StringSplit ( $lista_detalhes , "|" )
    $matriz_botoes     = StringSplit ( $lista_botoes     , "|" )
    $qtde_itens         = $matriz_itens  [0]

    ; Se houver apenas um ítem, finaliza a função selecionando esse ítem -----------------------------------------------------------

    If $qtde_itens = 1  Then

        $item_selecionado = $lista_itens
        Return ( $item_selecionado )

    EndIf

    ; Separa o ícone e o texto do rodapé ------------------------------------------------------------------------------------

    If Not StringInStr ( $rodape , "|" ) Then

        $icone_rodape = "não há"

    Else

        $icone_rodape = -5 - _ArraySearch ( $matriz_icones , StringLeft ( $rodape , 1 ) , 0 , 0 , 0 , 0 , 1 )
        $rodape       = StringTrimLeft ( $rodape , 2 )

    EndIf

    ; Calcula as dimensões da janela e dos seus componentes (cabeçalho, ítens, ícone e rodapé) ------------------------------

    If $lista_detalhes = "" Then
        $altura_item = 20 * $proporcao
    Else
        $altura_item = 40 * $proporcao
    EndIf

    $largura_janela      = $largura_janela * $proporcao
    $proporcao_rodape = ( $tam_fonte - 2 ) / 8.5
    $largura_icone      = ( $icone_rodape <> "não há" ) * ( 32 + 12 * $proporcao_rodape )
    $altura_rodape      = Altura_texto ( $rodape    , $tam_fonte - 2 , $largura_janela - 60 * $proporcao - $largura_icone )
    $altura_cabecalho = Altura_texto ( $cabecalho , $tam_fonte     , $largura_janela - 60 * $proporcao )

    If $icone_rodape <> "não há" And $altura_rodape < 32 Then $altura_rodape = 32
    If $rodape          <> ""                                  Then $altura_rodape = $altura_rodape + 20 * $proporcao_rodape

    $altura_janela = $altura_cabecalho + 80 * $proporcao + $qtde_itens * $altura_item + $altura_rodape + 60

    ; Cria a janela e exibe o cabeçalho --------------------------------------------------------------------------------------------

    Exibe_janela_cabecalho ( $largura_janela , $altura_janela , $cabecalho , $altura_cabecalho , $tam_fonte , $proporcao )

    ; Exibe os ítens e seus detalhes -----------------------------------------------------------------------------------------------

    Dim $matriz_itens_radio [$qtde_itens + 1]

    For $numero = 1 to $qtde_itens

        $matriz_itens_radio [$numero] = GUICtrlCreateRadio ( $matriz_itens [$numero] , 30 * $proporcao _
                                                           , 65 * $proporcao + $altura_cabecalho _
                                                           + $altura_item * ( $numero - 1 ) _
                                                           , $largura_janela - 60 * $proporcao )

        If $lista_detalhes <> "" Then

            GUICtrlCreateLabel ( $matriz_detalhes [$numero] , 41 * $proporcao , 88 * $proporcao + $altura_cabecalho _
                               + $altura_item * ( $numero - 1 ) , $largura_janela - 60 * $proporcao )
            GUICtrlSetFont        ( -1 , $tam_fonte - 2 )

        EndIf

    Next

    GUICtrlSetState ( $matriz_itens_radio [1] , $GUI_CHECKED )

    ; Exibe o rodapé ---------------------------------------------------------------------------------------------------------------

    Exibe_rodape ( $rodape , $altura_rodape , $icone_rodape , $largura_icone , $largura_janela , $altura_janela )

    ; Exibe os botões e obtém o botão clicado --------------------------------------------------------------------------------------

    Obtem_botao_clicado ( $matriz_botoes , 80 , "H" , $largura_janela , $altura_janela )

    ; Obtém o ítem selecionado -----------------------------------------------------------------------------------------------------

    For $numero = 1 to $qtde_itens

        If GUICtrlRead ( $matriz_itens_radio [$numero] ) = $GUI_CHECKED Then $item_selecionado = $matriz_itens [$numero]

    Next

    ; Fecha a janela e finaliza a função ------------------------------------------------------------------------------------

    GUIDelete ()
    Return       ( $item_selecionado )

EndFunc

Func Exibe_janela_cabecalho ( $largura_janela , $altura_janela , $cabecalho , $altura_cabecalho , $tam_fonte_janela _
                            , $proporcao_cabecalho )

    ; Cria a janela ----------------------------------------------------------------------------------------------------------------

    GUICreate ( $titulo_janela , $largura_janela , $altura_janela , -1 , -1 , $WS_CAPTION , $WS_EX_TOPMOST )

    ; Exibe o cabeçalho ------------------------------------------------------------------------------------------------------------

    GUICtrlCreateGraphic ( 0 , 0 , $largura_janela , 30 * $proporcao_cabecalho + $altura_cabecalho )
    GUICtrlSetBkColor     ( -1 , 0xffffff )
    GUICtrlSetColor         ( -1 , 0 )
    GUISetFont                 ( $tam_fonte_janela )
    GUICtrlCreateLabel      ( $cabecalho , 30 * $proporcao_cabecalho , 15 * $proporcao_cabecalho _
                         , $largura_janela - 60 * $proporcao_cabecalho , $altura_cabecalho )
    GUICtrlSetBkColor     ( -1 , 0xffffff )

EndFunc

Func Exibe_rodape ( $rodape , $altura_rodape , $icone_rodape , $largura_icone , $largura_janela , $altura_janela )

    If $rodape <> "" Then

        GUICtrlCreateIcon  ( @ScriptFullPath , $icone_rodape , 30 * $proporcao , $altura_janela - 25 - $altura_rodape )
        GUICtrlCreateLabel ( $rodape , 30 * $proporcao + $largura_icone , $altura_janela - 25 - $altura_rodape _
                           , $largura_janela - 60 * $proporcao - $largura_icone , $altura_rodape )
        GUICtrlSetFont        ( -1 , $tam_fonte - 2 )

    EndIf

EndFunc

Func Obtem_botao_clicado ( $matriz_botoes , $largura_botoes , $disposicao_botoes , $largura_janela , $altura_janela )

    ; Exibe os botões --------------------------------------------------------------------------------------------------------------

    If $disposicao_botoes = "H" Then
        GUICtrlCreateGroup ( "" , 0 , $altura_janela - 56 , $largura_janela , 56 )
        GUISetFont            (8.5)
    Else
        GUISetFont           ($tam_fonte)
    EndIf

    $qtde_botoes  = UBound ( $matriz_botoes ) - 1
    $botao_padrao = 1

    For $numero = 1 to $qtde_botoes

        If $disposicao_botoes = "H" Then

            If $qtde_botoes = 1 Then

                $posicao_horizontal  = $largura_janela / 2 - $largura_botoes / 2

            ElseIf $numero = $qtde_botoes Then

                $posicao_horizontal     = $largura_janela - 10 - $largura_botoes

            Else

                $posicao_horizontal     = $largura_janela - ( $qtde_botoes - $numero ) * $largura_botoes - 20 - $largura_botoes

            EndIf

            $matriz_botoes [$numero] = GUICtrlCreateButton ( $matriz_botoes [$numero] , $posicao_horizontal _
                                                           , $altura_janela - 35 , $largura_botoes )

        Else

            $matriz_botoes [$numero] = GUICtrlCreateButton ( $matriz_botoes [$numero] , $largura_janela / 2 _
                                                           - $largura_botoes / 2 , $altura_janela - 20 * $proporcao _
                                                           - ( ( $qtde_botoes - $numero + 1 ) * 27 * $proporcao ) _
                                                           , $largura_botoes , 21 * $proporcao )

        EndIf

        Switch GUICtrlRead ( $matriz_botoes [$numero] )

            Case "OK" , "Sim" , "Avançar >"

                $botao_padrao = $numero

        EndSwitch

    Next

    GUICtrlSetState ( $matriz_botoes [$botao_padrao] , $GUI_DEFBUTTON )
    GUISetState     ()

    ; Obtém o botão clicado --------------------------------------------------------------------------------------------------------

    While 1

        If $instalando_impressora = "sim" Then Avanca_janela_impressora ()

        $acao = GUIGetMsg ()

        For $numero = 1 to $qtde_botoes

            If $acao = $matriz_botoes [$numero] Then

                $botao_clicado = GUICtrlRead ( $acao )

                Switch $botao_clicado

                    Case "Créditos"

                        GUISetState    ( @SW_HIDE )
                        Obtem_resposta ( $creditos , "OK" , 360 )
                        GUISetState    ( @SW_SHOW )

                    Case "Sair"

                        Aborta ()

                    Case Else

                        ExitLoop 2

                EndSwitch

            EndIf

        Next

    WEnd

    Return ( $botao_clicado )

EndFunc
Edited by Melba23
Added code tags
Link to comment
Share on other sites

this is exactly what I want: to go from one radio button to another on a autoit program, but Tab or the arrow keys do not work.

Please stop, you're repeating the EXACT same line over and over. No one is going to help you unless you show us what you're doing with your code.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

  • Moderators

Darien,

If you post code, please use Code tags - put [autoit] before and [/autoit] after your posted code. :)

I have done it for you above - please do it yourself from now on. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Unfortunately the code you posted is not going to help with the problem, it doesn't run it's just a collection of functions. Plus, there's only one radio button statement in the whole script, and there's nothing obvious from the script why it won't do what you want it to. You're not using anything special when you're creating it/them, no style settings that might confuse things, so with just this to work with I can't say for sure why it doesn't go from one control to the next.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Here's a script that works.

Now I realized that just is not possible to navigate between radio items when there are labels between them.

; ===================================================================================================================================
;                                                    CONFIGURAÇÕES INICIAIS
; ===================================================================================================================================

; Adiciona os ícones ao executável do script

#AutoIt3Wrapper_Res_Icon_Add=AutoIt - íconesAviso.ico
#AutoIt3Wrapper_Res_Icon_Add=AutoIt - íconesHelpDesk.ico
#AutoIt3Wrapper_Res_Icon_Add=AutoIt - íconesInformação.ico
#AutoIt3Wrapper_Res_Icon_Add=AutoIt - íconesNegação.ico
#AutoIt3Wrapper_Res_Icon_Add=AutoIt - íconesOK.ico
#AutoIt3Wrapper_Res_Icon_Add=AutoIt - íconesQuestão.ico

; Inclui o script necessário para usar o comando GUICreate

#include <GUIConstantsEx.au3>

; Inclui o script necessário para usar o parâmetro style do comando GUICreate

#include <WindowsConstants.au3>

; Inclui o script necessário para usar o parâmetro style do comando GUICtrlCreateInput

#include <EditConstants.au3>

; Inclui o script necessário para usar o parâmetro style do comando GUICtrlCreateCombo

#include <ComboConstants.au3>

; Inclui o script necessário para usar o parâmetro style do comando GUICtrlCreateLabel

#include <StaticConstants.au3>

; Inclui o script necessário para usar o parâmetro style do comando GUICtrlCreateList

#include <ListboxConstants.au3>

; Inclui o script necessário para usar o parâmetro style do comando GUICtrlCreateUpdown

#include <UpdownConstants.au3>

; Inclui o script necessário para usar o parâmetro style do comando GUICtrlCreateGroup

#include <ButtonConstants.au3>

; Inclui o script necessário para usar o parâmetro style do comando GUICtrlCreateEdit

#include <EditConstants.au3>

; Inclui o script necessário para usar o comando _ArraySearch

#Include <Array.au3>

; Inclui o script necessário para usar os comandos _FilePrint e _ReplaceStringInFile

#Include <File.au3>

; Inclui o script necessário para usar o comando _StringRepeat

#Include <String.au3>

; Inclui o script necessário para usar o comando _Singleton

#include <Misc.au3>

; Inclui o script necessário para usar o comando _SetTime

#Include <Date.au3>

; Faz com que o script seja executado com direitos de administrador

#requireadmin

; ==================================================================================================================
;                                             PROGRAMA PRINCIPAL
; ==================================================================================================================

; ==============================
; Definição de variáveis globais
; ==============================

Global $titulo_janela , $item_selecionado , $botao_clicado , $barra_progresso , $configuracao_atual , $creditos , _
       $creditos , $matriz_icones [6] = [ "A" , "H" , "I" , "N" , "O" , "Q" ]

; Resolução de vídeo

Global $res_horizontal = @DesktopWidth , $res_vertical = @DesktopHeight

; Tamanho da fonte

Global $ppp = RegRead ( "HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionFontDPI" , "LogPixels" ) , _
       $tam_fonte = 14 / ( $ppp / 96 ) , $proporcao = $tam_fonte / 8.5 * ( $ppp / 96 )

; =============================================================
; Encerra o programa se outra instância dele já estiver rodando
; =============================================================

_Singleton ( @ScriptName )

; =============================================================================================
; Desabilita a possibilidade do usuário pausar ou encerrar o script clicando no ícone do AutoIt
; =============================================================================================

Break (0)

; ==================================================================================================================
;                                                  FUNÇÕES
; ==================================================================================================================

Seleciona_item_radio ( "Example1: here you can browse among the items with the keyboard." , "Item 1|Item 2|Item 3" , "" , "" , "Next" , 500 )
Seleciona_item_radio ( "Example2: here you can not browse among the items with the keyboard." , "Item 1|Item 2|Item 3" , "detail 1|detail 2|detail 3" , "" , "Next" , 500 )

; ========================================================
; Função que seleciona um ítem de uma lista estilo "Radio"
; ========================================================

#comments-start

Sintaxe:
-------

Seleciona_item_radio ( "cabeçalho" , "item1[|item2|item3|...]" , "[detalhe1|detalhe2|...]" , "[[ID do ícone|]rodapé]"
                     , "botão1[|botão2|botão3|...]" , largura da janela )

Parâmetros:
----------

ID do ícone = A (ícone de Aviso), H (ícone de HelpDesk), I (ícone de Informação), N (ícone de Negação), O (ícone de OK) ou
           Q (ícone de Questão)

Requisitos:
----------

Devem existir as variáveis globais $titulo_janela, $tam_fonte, $proporcao, $item_selecionado, $botao_clicado e
$matriz_icones, as funções Altura_texto, Exibe_janela_cabecalho, Exibe_rodape e Obtem_botao_clicado e, no momento da
compilação, os arquivos Aviso.ico, HelpDesk.ico, Informação.ico, Negação.ico, OK.ico e Questão.ico na pasta
'AutoIt - ícones' da raiz da unidade onde o script se encontra.

Resultados:
----------

Será exibida uma janela com o cabeçalho, os ítens numa lista estilo "Radio" (opcionalmente com um texto abaixo de
cada um deles), opcionalmente um rodapé (com um ícone também opcionalmente) e os botões.
A função retornará o ítem selecionado (se houver apenas um ítem, ele será selecionado automaticamente sem que a janela
seja exibida) e alterará o valor das variáveis $item_selecionado e $botao_clicado.

#comments-end

Func Seleciona_item_radio ( $cabecalho , $lista_itens , $lista_detalhes , $rodape , $lista_botoes , $largura_janela )

    ; Cria as matrizes de ítens, detalhes e botões ---------------------------------------------------------------------------------

    $matriz_itens      = StringSplit ( $lista_itens     , "|" )
    $matriz_detalhes = StringSplit ( $lista_detalhes , "|" )
    $matriz_botoes     = StringSplit ( $lista_botoes     , "|" )
    $qtde_itens         = $matriz_itens  [0]

    ; Se houver apenas um ítem, finaliza a função selecionando esse ítem -----------------------------------------------------------

    If $qtde_itens = 1  Then

        $item_selecionado = $lista_itens
        Return ( $item_selecionado )

    EndIf

    ; Separa o ícone e o texto do rodapé ------------------------------------------------------------------------------------

    If Not StringInStr ( $rodape , "|" ) Then

        $icone_rodape = "não há"

    Else

        $icone_rodape = -5 - _ArraySearch ( $matriz_icones , StringLeft ( $rodape , 1 ) , 0 , 0 , 0 , 0 , 1 )
        $rodape       = StringTrimLeft ( $rodape , 2 )

    EndIf

    ; Calcula as dimensões da janela e dos seus componentes (cabeçalho, ítens, ícone e rodapé) ------------------------------

    If $lista_detalhes = "" Then
        $altura_item = 20 * $proporcao
    Else
        $altura_item = 40 * $proporcao
    EndIf

    $largura_janela      = $largura_janela * $proporcao
    $proporcao_rodape = ( $tam_fonte - 2 ) / 8.5
    $largura_icone      = ( $icone_rodape <> "não há" ) * ( 32 + 12 * $proporcao_rodape )
    $altura_rodape      = Altura_texto ( $rodape    , $tam_fonte - 2 , $largura_janela - 60 * $proporcao - $largura_icone )
    $altura_cabecalho = Altura_texto ( $cabecalho , $tam_fonte   , $largura_janela - 60 * $proporcao )

    If $icone_rodape <> "não há" And $altura_rodape < 32 Then $altura_rodape = 32
    If $rodape          <> ""                                  Then $altura_rodape = $altura_rodape + 20 * $proporcao_rodape

    $altura_janela = $altura_cabecalho + 80 * $proporcao + $qtde_itens * $altura_item + $altura_rodape + 60

    ; Cria a janela e exibe o cabeçalho --------------------------------------------------------------------------------------------

    Exibe_janela_cabecalho ( $largura_janela , $altura_janela , $cabecalho , $altura_cabecalho , $tam_fonte , $proporcao )

    ; Exibe os ítens e seus detalhes -----------------------------------------------------------------------------------------------

    Dim $matriz_itens_radio [$qtde_itens + 1]

    For $numero = 1 to $qtde_itens

        $matriz_itens_radio [$numero] = GUICtrlCreateRadio ( $matriz_itens [$numero]     , 30 * $proporcao _
                                                           , 65 * $proporcao + $altura_cabecalho _
                                                           + $altura_item * ( $numero - 1 ) _
                                                           , $largura_janela - 60 * $proporcao )

        If $lista_detalhes <> "" Then

            GUICtrlCreateLabel ( $matriz_detalhes [$numero] , 41 * $proporcao , 88 * $proporcao + $altura_cabecalho _
                               + $altura_item * ( $numero - 1 ) , $largura_janela - 60 * $proporcao )
            GUICtrlSetFont        ( -1 , $tam_fonte - 2 )

        EndIf

    Next

    GUICtrlSetState ( $matriz_itens_radio [1] , $GUI_CHECKED )

    ; Exibe o rodapé ---------------------------------------------------------------------------------------------------------------

    Exibe_rodape ( $rodape , $altura_rodape , $icone_rodape , $largura_icone , $largura_janela , $altura_janela )

    ; Exibe os botões e obtém o botão clicado --------------------------------------------------------------------------------------

    Obtem_botao_clicado ( $matriz_botoes , 80 , "H" , $largura_janela , $altura_janela )

    ; Obtém o ítem selecionado -----------------------------------------------------------------------------------------------------

    For $numero = 1 to $qtde_itens

        If GUICtrlRead ( $matriz_itens_radio [$numero] ) = $GUI_CHECKED Then $item_selecionado = $matriz_itens [$numero]

    Next

    ; Fecha a janela e finaliza a função ------------------------------------------------------------------------------------

    GUIDelete ()
    Return       ( $item_selecionado )

EndFunc

; ===============================================
; Função que obtém uma resposta para uma pergunta
; ===============================================

#comments-start

Sintaxe:
-------

Obtem_resposta ( "[ID do ícone ou barra de progresso|]pergunta" , "[botão1|botão2|...]" , largura da janela )

Parâmetros:
----------

ID do ícone ou barra de progresso = A (ícone de Aviso), B (barra de progresso), H (ícone de HelpDesk),
                                 I (ícone de Informação), N (ícone de Negação), O (ícone de OK) ou Q (ícone de Questão)

Requisitos:
----------

Devem existir as variáveis globais $titulo_janela, $tam_fonte, $proporcao, $botao_clicado, $barra_progresso,
$configuracao_atual e $matriz_icones, as funções Altura_texto e Obtem_botao_clicado e, no momento da compilação,
os arquivos Aviso.ico, HelpDesk.ico, Informação.ico, Negação.ico, OK.ico e Questão.ico na pasta 'AutoIt - ícones'
da raiz da unidade onde o script se encontra.

Resultados:
----------

Se não for especificado o ID da barra de progresso, será exibida uma janela com a pergunta (opcionalmente com um ícone)
e opcionalmente com botões. Se houver botões, a função retornará o botão clicado e alterará o valor da variável
$botao_clicado. Se não houver botões, a janela permanecerá aberta após a conclusão da função, que não retornará nenhum valor.
Se for especificado o ID da barra de progresso, será exibida uma janela com uma barra de progresso e a pergunta acima dela
e a janela permanecerá aberta após a conclusão da função, que não retornará nenhum valor. As variáveis $barra_progresso
e $configuracao_atual serão associadas à barra de progresso a ao texto que será exibido abaixo dela, respectivamente.

#comments-end

Func Obtem_resposta ( $pergunta , $lista_botoes , $largura_janela )

    ; Cria a matriz de botões e define sua altura e largura ----------------------------------------------------------------

    If $lista_botoes = "" Then

        $altura_botoes = 0

    Else

        $matriz_botoes  = StringSplit ( $lista_botoes , "|" )
        $qtde_botoes    = $matriz_botoes [0]
        $altura_botoes  = 27 * $proporcao
        $largura_botoes = 48 * $proporcao

    EndIf

    ; Separa o ícone e o texto da pergunta ----------------------------------------------------------------------------------

    If StringInStr ( $pergunta , "|" ) Then

        If StringLeft ( $pergunta , 1 ) = "B" Then

            $barra_progresso = "há"
            $icone_pergunta  = "não há"

        Else

            $barra_progresso = "não há"
            $icone_pergunta  = -5 - _ArraySearch ( $matriz_icones , StringLeft ( $pergunta , 1 ) , 0 , 0 , 0 , 0 , 1 )

        EndIf

        $pergunta = StringTrimLeft ( $pergunta , 2 )

    Else

        $barra_progresso = "não há"
        $icone_pergunta  = "não há"

    EndIf

    ; Calcula as dimensões da janela e de seus componentes (ícone e pergunta) -----------------------------------------------

    $largura_janela     = $largura_janela * $proporcao
    $largura_icone     = ( $icone_pergunta <> "não há" ) * ( 32 + 12 * $proporcao )
    $altura_pergunta = Altura_texto ( $pergunta , $tam_fonte , $largura_janela - 60 * $proporcao - $largura_icone )

    If $icone_pergunta <> "não há" And $altura_pergunta < 32 Then $altura_pergunta = 32

    $altura_janela = $altura_pergunta + ( 54 + 40 * ( $barra_progresso = "há" ) ) * $proporcao + $altura_botoes

    ; Cria a janela --------------------------------------------------------------------------------------------------------

    GUICreate  ( $titulo_janela , $largura_janela , $altura_janela , -1 , -1 , $WS_CAPTION , $WS_EX_TOPMOST )
    GUISetFont ( $tam_fonte )

    ; Exibe a pergunta ------------------------------------------------------------------------------------------------------------

    GUICtrlCreateIcon ( @ScriptFullPath , $icone_pergunta , 30 * $proporcao , 30 * $proporcao )

    If $altura_pergunta = 14 * $proporcao And $icone_pergunta = "não há" Then

        GUICtrlCreateLabel ( $pergunta , 30 * $proporcao + $largura_icone , 30 * $proporcao _
                           , $largura_janela - 60 * $proporcao - $largura_icone , $altura_pergunta , $SS_CENTER )

    Else

        GUICtrlCreateLabel ( $pergunta , 30 * $proporcao + $largura_icone , 30 * $proporcao _
                           , $largura_janela - 60 * $proporcao - $largura_icone , $altura_pergunta )

    EndIf

    ; Exibe a barra de progresso ----------------------------------------------------------------------------------------------

    If $barra_progresso = "há" Then

        $barra_progresso     = GUICtrlCreateProgress ( 15 * $proporcao , $altura_janela - 45 * $proporcao _
                                                    , $largura_janela - 30 * $proporcao , 20 * $proporcao )
        $configuracao_atual = GUICtrlCreateLabel    ( "" , 15 * $proporcao , $altura_janela - 20 * $proporcao _
                                                    , $largura_janela - 30 * $proporcao , 20 * $proporcao , $SS_CENTER )
                              GUICtrlSetFont         ( -1 , $tam_fonte - 3 )

    EndIf

    If $lista_botoes <> "" Then

        ; Se houver botões, exibe-os, obtém o botão clicado, fecha a janela e encerra a função devolvendo o botão clicado --------

        Obtem_botao_clicado ( $matriz_botoes , $largura_botoes , "H" , $largura_janela , $altura_janela )
        GUIDelete             ()
        Return                   ( $botao_clicado )

    Else

        ; Se não houver botões, apenas ativa a janela e encerra a função ---------------------------------------------------

        GUISetState ()
        Return

    EndIf

EndFunc

; ===============================================
; Função que cria uma janela e exibe um cabeçalho
; ===============================================

#comments-start

Sintaxe:
-------

Exibe_janela_cabecalho ( largura da janela , altura da janela , "cabeçalho" , altura do cabeçalho ,
                       tamanho da fonte da janela , proporção do cabeçalho )

Requisitos:
----------

Deve existir a variável global $titulo_janela.

#comments-end

Func Exibe_janela_cabecalho ( $largura_janela , $altura_janela , $cabecalho , $altura_cabecalho , $tam_fonte_janela _
                            , $proporcao_cabecalho )

    ; Cria a janela ----------------------------------------------------------------------------------------------------------------

    GUICreate ( $titulo_janela , $largura_janela , $altura_janela , -1 , -1 , $WS_CAPTION , $WS_EX_TOPMOST )

    ; Exibe o cabeçalho ------------------------------------------------------------------------------------------------------------

    GUICtrlCreateGraphic ( 0 , 0 , $largura_janela , 30 * $proporcao_cabecalho + $altura_cabecalho )
    GUICtrlSetBkColor     ( -1 , 0xffffff )
    GUICtrlSetColor         ( -1 , 0 )
    GUISetFont                 ( $tam_fonte_janela )
    GUICtrlCreateLabel      ( $cabecalho , 30 * $proporcao_cabecalho , 15 * $proporcao_cabecalho _
                         , $largura_janela - 60 * $proporcao_cabecalho , $altura_cabecalho )
    GUICtrlSetBkColor     ( -1 , 0xffffff )

EndFunc

; ==========================
; Função que exibe um rodapé
; ==========================

#comments-start

Sintaxe:
-------

Exibe_rodape ( "rodapé" , altura do rodapé , número do ícone , largura do ícone , largura da janela , altura da janela )

Parâmetros:
----------

Número do ícone = número que identifica o ícone dentro do arquivo que o contém.

Requisitos:
----------

Devem existir a variáveis globais $tam_fonte e $proporcao.

Resultados:
----------

Exibe o rodapé e opcionalmente um ícone.

#comments-end

Func Exibe_rodape ( $rodape , $altura_rodape , $icone_rodape , $largura_icone , $largura_janela , $altura_janela )

    If $rodape <> "" Then

        GUICtrlCreateIcon  ( @ScriptFullPath , $icone_rodape , 30 * $proporcao , $altura_janela - 25 - $altura_rodape )
        GUICtrlCreateLabel ( $rodape , 30 * $proporcao + $largura_icone , $altura_janela - 25 - $altura_rodape _
                           , $largura_janela - 60 * $proporcao - $largura_icone , $altura_rodape )
        GUICtrlSetFont        ( -1 , $tam_fonte - 2 )

    EndIf

EndFunc

; ===============================================
; Função que exibe botões e obtém o botão clicado
; ===============================================

#comments-start

Sintaxe:
-------

Obtem_botao_clicado ( matriz de botões , largura dos botões , "ID da disposição dos botões"    , largura da janela
                    , altura da janela )

Parâmetros:
----------

ID da disposição dos botões = H (horizontal) ou V (vertical)

Requisitos:
----------

Devem existir a variáveis globais $proporcao e $creditos e a função Aborta.

Resultados:
----------

Serão exibidos os botões. A função retornará o botão clicado e alterará o valor da variável $botao_clicado.

#comments-end

Func Obtem_botao_clicado ( $matriz_botoes , $largura_botoes , $disposicao_botoes , $largura_janela , $altura_janela )

    ; Exibe os botões --------------------------------------------------------------------------------------------------------------

    If $disposicao_botoes = "H" Then
        GUICtrlCreateGroup ( "" , 0 , $altura_janela - 56 , $largura_janela , 56 )
        GUISetFont            (8.5)
    Else
        GUISetFont           ($tam_fonte)
    EndIf

    $qtde_botoes  = UBound ( $matriz_botoes ) - 1
    $botao_padrao = 1

    For $numero = 1 to $qtde_botoes

        If $disposicao_botoes = "H" Then

            If $qtde_botoes = 1 Then

                $posicao_horizontal  = $largura_janela / 2 - $largura_botoes / 2

            ElseIf $numero = $qtde_botoes Then

                $posicao_horizontal     = $largura_janela - 10 - $largura_botoes

            Else

                $posicao_horizontal     = $largura_janela - ( $qtde_botoes - $numero ) * $largura_botoes - 20 - $largura_botoes

            EndIf

            $matriz_botoes [$numero] = GUICtrlCreateButton ( $matriz_botoes [$numero] , $posicao_horizontal _
                                                           , $altura_janela - 35 , $largura_botoes )

        Else

            $matriz_botoes [$numero] = GUICtrlCreateButton ( $matriz_botoes [$numero] , $largura_janela / 2 _
                                                           - $largura_botoes / 2 , $altura_janela - 20 * $proporcao _
                                                           - ( ( $qtde_botoes - $numero + 1 ) * 27 * $proporcao ) _
                                                           , $largura_botoes , 21 * $proporcao )

        EndIf

        Switch GUICtrlRead ( $matriz_botoes [$numero] )

            Case "OK" , "Sim" , "Avançar >"

                $botao_padrao = $numero

        EndSwitch

    Next

    GUICtrlSetState ( $matriz_botoes [$botao_padrao] , $GUI_DEFBUTTON )
    GUISetState     ()

    ; Obtém o botão clicado --------------------------------------------------------------------------------------------------------

    While 1

        $acao = GUIGetMsg ()

        For $numero = 1 to $qtde_botoes

            If $acao = $matriz_botoes [$numero] Then

                $botao_clicado = GUICtrlRead ( $acao )

                Switch $botao_clicado

                    Case "Créditos"

                        GUISetState    ( @SW_HIDE )
                        Obtem_resposta ( $creditos , "OK" , 360 )
                        GUISetState    ( @SW_SHOW )

                    Case "Sair"

                        Aborta ()

                    Case Else

                        ExitLoop 2

                EndSwitch

            EndIf

        Next

    WEnd

    Return ( $botao_clicado )

EndFunc

; =======================================
; Função que calcula a altura de um texto
; =======================================

Func Altura_texto ( $texto , $tam_fonte_texto , $largura_paragrafo )

    $proporcao_texto   = $tam_fonte_texto / 8.5 * ( $ppp / 96 )
    $altura               = 0
    $matriz_paragrafos = StringSplit ( $texto , Chr(13) )

    For $num = 1 To $matriz_paragrafos [0]

        $altura = $altura + ( Ceiling ( StringLen ( $matriz_paragrafos [$num] ) / ( $largura_paragrafo / _
                  ( 5 * $proporcao_texto ) ) ) * 14 * $proporcao_texto )
        If $matriz_paragrafos [$num] = "" Then $altura = $altura + 14 * $proporcao_texto

    Next

    Return ( $altura )

EndFunc

; ============================
; Função que aborta o programa
; ============================

Func Aborta ()

    GUISetState ( @SW_HIDE )
    If Obtem_resposta ( "Q|O programa ainda não foi concluído." & Chr(13) & Chr(13) & "Tem certeza que deseja sair?" _
                      , "Sim|Não" , 280 ) = "Sim" Then Encerra ()
    GUISetState ( @SW_SHOW )

EndFunc

; =============================
; Função que encerra o programa
; =============================

#comments-start

Requisitos:
----------

Devem existir a variáveis globais $res_horizontal e $res_horizontal e o programa 1365VidChng.exe
na supasta "Arquivos" da pasta onde o programa se encontra

#comments-end

Func Encerra ()

    RunWait ( @ComSpec & " /c " & """" & @ScriptDir & "Arquivos1365VidChng.exe"" " & $res_horizontal & "x" & _
            $res_vertical & "x32@60 -q" )
    Exit

EndFunc
Link to comment
Share on other sites

Here's a script that works.

Now I realized that just is not possible to navigate between radio items when there are labels between them.

; ===================================================================================================================================
;                                                    CONFIGURAÇÕES INICIAIS
; ===================================================================================================================================

; Adiciona os ícones ao executável do script

#AutoIt3Wrapper_Res_Icon_Add=AutoIt - íconesAviso.ico
#AutoIt3Wrapper_Res_Icon_Add=AutoIt - íconesHelpDesk.ico
#AutoIt3Wrapper_Res_Icon_Add=AutoIt - íconesInformação.ico
#AutoIt3Wrapper_Res_Icon_Add=AutoIt - íconesNegação.ico
#AutoIt3Wrapper_Res_Icon_Add=AutoIt - íconesOK.ico
#AutoIt3Wrapper_Res_Icon_Add=AutoIt - íconesQuestão.ico

; Inclui o script necessário para usar o comando GUICreate

#include <GUIConstantsEx.au3>

; Inclui o script necessário para usar o parâmetro style do comando GUICreate

#include <WindowsConstants.au3>

; Inclui o script necessário para usar o parâmetro style do comando GUICtrlCreateInput

#include <EditConstants.au3>

; Inclui o script necessário para usar o parâmetro style do comando GUICtrlCreateCombo

#include <ComboConstants.au3>

; Inclui o script necessário para usar o parâmetro style do comando GUICtrlCreateLabel

#include <StaticConstants.au3>

; Inclui o script necessário para usar o parâmetro style do comando GUICtrlCreateList

#include <ListboxConstants.au3>

; Inclui o script necessário para usar o parâmetro style do comando GUICtrlCreateUpdown

#include <UpdownConstants.au3>

; Inclui o script necessário para usar o parâmetro style do comando GUICtrlCreateGroup

#include <ButtonConstants.au3>

; Inclui o script necessário para usar o parâmetro style do comando GUICtrlCreateEdit

#include <EditConstants.au3>

; Inclui o script necessário para usar o comando _ArraySearch

#Include <Array.au3>

; Inclui o script necessário para usar os comandos _FilePrint e _ReplaceStringInFile

#Include <File.au3>

; Inclui o script necessário para usar o comando _StringRepeat

#Include <String.au3>

; Inclui o script necessário para usar o comando _Singleton

#include <Misc.au3>

; Inclui o script necessário para usar o comando _SetTime

#Include <Date.au3>

; Faz com que o script seja executado com direitos de administrador

#requireadmin

; ==================================================================================================================
;                                             PROGRAMA PRINCIPAL
; ==================================================================================================================

; ==============================
; Definição de variáveis globais
; ==============================

Global $titulo_janela , $item_selecionado , $botao_clicado , $barra_progresso , $configuracao_atual , $creditos , _
       $creditos , $matriz_icones [6] = [ "A" , "H" , "I" , "N" , "O" , "Q" ]

; Resolução de vídeo

Global $res_horizontal = @DesktopWidth , $res_vertical = @DesktopHeight

; Tamanho da fonte

Global $ppp = RegRead ( "HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionFontDPI" , "LogPixels" ) , _
       $tam_fonte = 14 / ( $ppp / 96 ) , $proporcao = $tam_fonte / 8.5 * ( $ppp / 96 )

; =============================================================
; Encerra o programa se outra instância dele já estiver rodando
; =============================================================

_Singleton ( @ScriptName )

; =============================================================================================
; Desabilita a possibilidade do usuário pausar ou encerrar o script clicando no ícone do AutoIt
; =============================================================================================

Break (0)

; ==================================================================================================================
;                                                  FUNÇÕES
; ==================================================================================================================

Seleciona_item_radio ( "Example1: here you can browse among the items with the keyboard." , "Item 1|Item 2|Item 3" , "" , "" , "Next" , 500 )
Seleciona_item_radio ( "Example2: here you can not browse among the items with the keyboard." , "Item 1|Item 2|Item 3" , "detail 1|detail 2|detail 3" , "" , "Next" , 500 )

; ========================================================
; Função que seleciona um ítem de uma lista estilo "Radio"
; ========================================================

Func Seleciona_item_radio ( $cabecalho , $lista_itens , $lista_detalhes , $rodape , $lista_botoes , $largura_janela )

    ; Cria as matrizes de ítens, detalhes e botões ---------------------------------------------------------------------------------

    $matriz_itens      = StringSplit ( $lista_itens     , "|" )
    $matriz_detalhes = StringSplit ( $lista_detalhes , "|" )
    $matriz_botoes     = StringSplit ( $lista_botoes     , "|" )
    $qtde_itens         = $matriz_itens  [0]

    ; Se houver apenas um ítem, finaliza a função selecionando esse ítem -----------------------------------------------------------

    If $qtde_itens = 1  Then

        $item_selecionado = $lista_itens
        Return ( $item_selecionado )

    EndIf

    ; Separa o ícone e o texto do rodapé ------------------------------------------------------------------------------------

    If Not StringInStr ( $rodape , "|" ) Then

        $icone_rodape = "não há"

    Else

        $icone_rodape = -5 - _ArraySearch ( $matriz_icones , StringLeft ( $rodape , 1 ) , 0 , 0 , 0 , 0 , 1 )
        $rodape       = StringTrimLeft ( $rodape , 2 )

    EndIf

    ; Calcula as dimensões da janela e dos seus componentes (cabeçalho, ítens, ícone e rodapé) ------------------------------

    If $lista_detalhes = "" Then
        $altura_item = 20 * $proporcao
    Else
        $altura_item = 40 * $proporcao
    EndIf

    $largura_janela      = $largura_janela * $proporcao
    $proporcao_rodape = ( $tam_fonte - 2 ) / 8.5
    $largura_icone      = ( $icone_rodape <> "não há" ) * ( 32 + 12 * $proporcao_rodape )
    $altura_rodape      = Altura_texto ( $rodape    , $tam_fonte - 2 , $largura_janela - 60 * $proporcao - $largura_icone )
    $altura_cabecalho = Altura_texto ( $cabecalho , $tam_fonte   , $largura_janela - 60 * $proporcao )

    If $icone_rodape <> "não há" And $altura_rodape < 32 Then $altura_rodape = 32
    If $rodape          <> ""                                  Then $altura_rodape = $altura_rodape + 20 * $proporcao_rodape

    $altura_janela = $altura_cabecalho + 80 * $proporcao + $qtde_itens * $altura_item + $altura_rodape + 60

    ; Cria a janela e exibe o cabeçalho --------------------------------------------------------------------------------------------

    Exibe_janela_cabecalho ( $largura_janela , $altura_janela , $cabecalho , $altura_cabecalho , $tam_fonte , $proporcao )

    ; Exibe os ítens e seus detalhes -----------------------------------------------------------------------------------------------

    Dim $matriz_itens_radio [$qtde_itens + 1]

    For $numero = 1 to $qtde_itens

        $matriz_itens_radio [$numero] = GUICtrlCreateRadio ( $matriz_itens [$numero]     , 30 * $proporcao _
                                                           , 65 * $proporcao + $altura_cabecalho _
                                                           + $altura_item * ( $numero - 1 ) _
                                                           , $largura_janela - 60 * $proporcao )

        If $lista_detalhes <> "" Then

            GUICtrlCreateLabel ( $matriz_detalhes [$numero] , 41 * $proporcao , 88 * $proporcao + $altura_cabecalho _
                               + $altura_item * ( $numero - 1 ) , $largura_janela - 60 * $proporcao )
            GUICtrlSetFont        ( -1 , $tam_fonte - 2 )

        EndIf

    Next

    GUICtrlSetState ( $matriz_itens_radio [1] , $GUI_CHECKED )

    ; Exibe o rodapé ---------------------------------------------------------------------------------------------------------------

    Exibe_rodape ( $rodape , $altura_rodape , $icone_rodape , $largura_icone , $largura_janela , $altura_janela )

    ; Exibe os botões e obtém o botão clicado --------------------------------------------------------------------------------------

    Obtem_botao_clicado ( $matriz_botoes , 80 , "H" , $largura_janela , $altura_janela )

    ; Obtém o ítem selecionado -----------------------------------------------------------------------------------------------------

    For $numero = 1 to $qtde_itens

        If GUICtrlRead ( $matriz_itens_radio [$numero] ) = $GUI_CHECKED Then $item_selecionado = $matriz_itens [$numero]

    Next

    ; Fecha a janela e finaliza a função ------------------------------------------------------------------------------------

    GUIDelete ()
    Return       ( $item_selecionado )

EndFunc

; ===============================================
; Função que obtém uma resposta para uma pergunta
; ===============================================

Func Obtem_resposta ( $pergunta , $lista_botoes , $largura_janela )

    ; Cria a matriz de botões e define sua altura e largura ----------------------------------------------------------------

    If $lista_botoes = "" Then

        $altura_botoes = 0

    Else

        $matriz_botoes  = StringSplit ( $lista_botoes , "|" )
        $qtde_botoes    = $matriz_botoes [0]
        $altura_botoes  = 27 * $proporcao
        $largura_botoes = 48 * $proporcao

    EndIf

    ; Separa o ícone e o texto da pergunta ----------------------------------------------------------------------------------

    If StringInStr ( $pergunta , "|" ) Then

        If StringLeft ( $pergunta , 1 ) = "B" Then

            $barra_progresso = "há"
            $icone_pergunta  = "não há"

        Else

            $barra_progresso = "não há"
            $icone_pergunta  = -5 - _ArraySearch ( $matriz_icones , StringLeft ( $pergunta , 1 ) , 0 , 0 , 0 , 0 , 1 )

        EndIf

        $pergunta = StringTrimLeft ( $pergunta , 2 )

    Else

        $barra_progresso = "não há"
        $icone_pergunta  = "não há"

    EndIf

    ; Calcula as dimensões da janela e de seus componentes (ícone e pergunta) -----------------------------------------------

    $largura_janela     = $largura_janela * $proporcao
    $largura_icone     = ( $icone_pergunta <> "não há" ) * ( 32 + 12 * $proporcao )
    $altura_pergunta = Altura_texto ( $pergunta , $tam_fonte , $largura_janela - 60 * $proporcao - $largura_icone )

    If $icone_pergunta <> "não há" And $altura_pergunta < 32 Then $altura_pergunta = 32

    $altura_janela = $altura_pergunta + ( 54 + 40 * ( $barra_progresso = "há" ) ) * $proporcao + $altura_botoes

    ; Cria a janela --------------------------------------------------------------------------------------------------------

    GUICreate  ( $titulo_janela , $largura_janela , $altura_janela , -1 , -1 , $WS_CAPTION , $WS_EX_TOPMOST )
    GUISetFont ( $tam_fonte )

    ; Exibe a pergunta ------------------------------------------------------------------------------------------------------------

    GUICtrlCreateIcon ( @ScriptFullPath , $icone_pergunta , 30 * $proporcao , 30 * $proporcao )

    If $altura_pergunta = 14 * $proporcao And $icone_pergunta = "não há" Then

        GUICtrlCreateLabel ( $pergunta , 30 * $proporcao + $largura_icone , 30 * $proporcao _
                           , $largura_janela - 60 * $proporcao - $largura_icone , $altura_pergunta , $SS_CENTER )

    Else

        GUICtrlCreateLabel ( $pergunta , 30 * $proporcao + $largura_icone , 30 * $proporcao _
                           , $largura_janela - 60 * $proporcao - $largura_icone , $altura_pergunta )

    EndIf

    ; Exibe a barra de progresso ----------------------------------------------------------------------------------------------

    If $barra_progresso = "há" Then

        $barra_progresso     = GUICtrlCreateProgress ( 15 * $proporcao , $altura_janela - 45 * $proporcao _
                                                    , $largura_janela - 30 * $proporcao , 20 * $proporcao )
        $configuracao_atual = GUICtrlCreateLabel    ( "" , 15 * $proporcao , $altura_janela - 20 * $proporcao _
                                                    , $largura_janela - 30 * $proporcao , 20 * $proporcao , $SS_CENTER )
                              GUICtrlSetFont         ( -1 , $tam_fonte - 3 )

    EndIf

    If $lista_botoes <> "" Then

        ; Se houver botões, exibe-os, obtém o botão clicado, fecha a janela e encerra a função devolvendo o botão clicado --------

        Obtem_botao_clicado ( $matriz_botoes , $largura_botoes , "H" , $largura_janela , $altura_janela )
        GUIDelete             ()
        Return                   ( $botao_clicado )

    Else

        ; Se não houver botões, apenas ativa a janela e encerra a função ---------------------------------------------------

        GUISetState ()
        Return

    EndIf

EndFunc

; ===============================================
; Função que cria uma janela e exibe um cabeçalho
; ===============================================

Func Exibe_janela_cabecalho ( $largura_janela , $altura_janela , $cabecalho , $altura_cabecalho , $tam_fonte_janela _
                            , $proporcao_cabecalho )

    ; Cria a janela ----------------------------------------------------------------------------------------------------------------

    GUICreate ( $titulo_janela , $largura_janela , $altura_janela , -1 , -1 , $WS_CAPTION , $WS_EX_TOPMOST )

    ; Exibe o cabeçalho ------------------------------------------------------------------------------------------------------------

    GUICtrlCreateGraphic ( 0 , 0 , $largura_janela , 30 * $proporcao_cabecalho + $altura_cabecalho )
    GUICtrlSetBkColor     ( -1 , 0xffffff )
    GUICtrlSetColor         ( -1 , 0 )
    GUISetFont                 ( $tam_fonte_janela )
    GUICtrlCreateLabel      ( $cabecalho , 30 * $proporcao_cabecalho , 15 * $proporcao_cabecalho _
                         , $largura_janela - 60 * $proporcao_cabecalho , $altura_cabecalho )
    GUICtrlSetBkColor     ( -1 , 0xffffff )

EndFunc

; ==========================
; Função que exibe um rodapé
; ==========================

Func Exibe_rodape ( $rodape , $altura_rodape , $icone_rodape , $largura_icone , $largura_janela , $altura_janela )

    If $rodape <> "" Then

        GUICtrlCreateIcon  ( @ScriptFullPath , $icone_rodape , 30 * $proporcao , $altura_janela - 25 - $altura_rodape )
        GUICtrlCreateLabel ( $rodape , 30 * $proporcao + $largura_icone , $altura_janela - 25 - $altura_rodape _
                           , $largura_janela - 60 * $proporcao - $largura_icone , $altura_rodape )
        GUICtrlSetFont        ( -1 , $tam_fonte - 2 )

    EndIf

EndFunc

; ===============================================
; Função que exibe botões e obtém o botão clicado
; ===============================================

Func Obtem_botao_clicado ( $matriz_botoes , $largura_botoes , $disposicao_botoes , $largura_janela , $altura_janela )

    ; Exibe os botões --------------------------------------------------------------------------------------------------------------

    If $disposicao_botoes = "H" Then
        GUICtrlCreateGroup ( "" , 0 , $altura_janela - 56 , $largura_janela , 56 )
        GUISetFont            (8.5)
    Else
        GUISetFont           ($tam_fonte)
    EndIf

    $qtde_botoes  = UBound ( $matriz_botoes ) - 1
    $botao_padrao = 1

    For $numero = 1 to $qtde_botoes

        If $disposicao_botoes = "H" Then

            If $qtde_botoes = 1 Then

                $posicao_horizontal  = $largura_janela / 2 - $largura_botoes / 2

            ElseIf $numero = $qtde_botoes Then

                $posicao_horizontal     = $largura_janela - 10 - $largura_botoes

            Else

                $posicao_horizontal     = $largura_janela - ( $qtde_botoes - $numero ) * $largura_botoes - 20 - $largura_botoes

            EndIf

            $matriz_botoes [$numero] = GUICtrlCreateButton ( $matriz_botoes [$numero] , $posicao_horizontal _
                                                           , $altura_janela - 35 , $largura_botoes )

        Else

            $matriz_botoes [$numero] = GUICtrlCreateButton ( $matriz_botoes [$numero] , $largura_janela / 2 _
                                                           - $largura_botoes / 2 , $altura_janela - 20 * $proporcao _
                                                           - ( ( $qtde_botoes - $numero + 1 ) * 27 * $proporcao ) _
                                                           , $largura_botoes , 21 * $proporcao )

        EndIf

        Switch GUICtrlRead ( $matriz_botoes [$numero] )

            Case "OK" , "Sim" , "Avançar >"

                $botao_padrao = $numero

        EndSwitch

    Next

    GUICtrlSetState ( $matriz_botoes [$botao_padrao] , $GUI_DEFBUTTON )
    GUISetState     ()

    ; Obtém o botão clicado --------------------------------------------------------------------------------------------------------

    While 1

        $acao = GUIGetMsg ()

        For $numero = 1 to $qtde_botoes

            If $acao = $matriz_botoes [$numero] Then

                $botao_clicado = GUICtrlRead ( $acao )

                Switch $botao_clicado

                    Case "Créditos"

                        GUISetState    ( @SW_HIDE )
                        Obtem_resposta ( $creditos , "OK" , 360 )
                        GUISetState    ( @SW_SHOW )

                    Case "Sair"

                        Aborta ()

                    Case Else

                        ExitLoop 2

                EndSwitch

            EndIf

        Next

    WEnd

    Return ( $botao_clicado )

EndFunc

; =======================================
; Função que calcula a altura de um texto
; =======================================

Func Altura_texto ( $texto , $tam_fonte_texto , $largura_paragrafo )

    $proporcao_texto   = $tam_fonte_texto / 8.5 * ( $ppp / 96 )
    $altura               = 0
    $matriz_paragrafos = StringSplit ( $texto , Chr(13) )

    For $num = 1 To $matriz_paragrafos [0]

        $altura = $altura + ( Ceiling ( StringLen ( $matriz_paragrafos [$num] ) / ( $largura_paragrafo / _
                  ( 5 * $proporcao_texto ) ) ) * 14 * $proporcao_texto )
        If $matriz_paragrafos [$num] = "" Then $altura = $altura + 14 * $proporcao_texto

    Next

    Return ( $altura )

EndFunc

; ============================
; Função que aborta o programa
; ============================

Func Aborta ()

    GUISetState ( @SW_HIDE )
    If Obtem_resposta ( "Q|O programa ainda não foi concluído." & Chr(13) & Chr(13) & "Tem certeza que deseja sair?" _
                      , "Sim|Não" , 280 ) = "Sim" Then Encerra ()
    GUISetState ( @SW_SHOW )

EndFunc

; =============================
; Função que encerra o programa
; =============================

Func Encerra ()

    RunWait ( @ComSpec & " /c " & """" & @ScriptDir & "Arquivos1365VidChng.exe"" " & $res_horizontal & "x" & _
            $res_vertical & "x32@60 -q" )
    Exit

EndFunc
Link to comment
Share on other sites

The controls must be sequential for arrow key navigation.

Create the labels after the radio buttons.

; Exibe os ítens e seus detalhes -----------------------------------------------------------------------------------------------

Dim $matriz_itens_radio [$qtde_itens + 1]

For $numero = 1 to $qtde_itens

     $matriz_itens_radio [$numero] = GUICtrlCreateRadio ( $matriz_itens [$numero]    , 30 * $proporcao _
                                                         , 65 * $proporcao + $altura_cabecalho _
                                                         + $altura_item * ( $numero - 1 ) _
                                                         , $largura_janela - 60 * $proporcao )
Next


For $numero = 1 to $qtde_itens
     If $lista_detalhes <> "" Then
         GUICtrlCreateLabel ( $matriz_detalhes [$numero] , 41 * $proporcao , 88 * $proporcao + $altura_cabecalho _
                             + $altura_item * ( $numero - 1 ) , $largura_janela - 60 * $proporcao )
         GUICtrlSetFont  ( -1 , $tam_fonte - 2 )
     EndIf
Next


GUICtrlSetState ( $matriz_itens_radio [1] , $GUI_CHECKED )

; Exibe o rodapé ---------------------------------------------------------------------------------------------------------------

I see fascists...

Link to comment
Share on other sites

I got! I created the functions "Volta_item_radio" and "Avanca_item_radio" to be executed by HotKeySet.

See the script below:

; ===================================================================================================================================
;                                                    CONFIGURAÇÕES INICIAIS
; ===================================================================================================================================

; Adiciona os ícones ao executável do script

#AutoIt3Wrapper_Res_Icon_Add=AutoIt - íconesAviso.ico
#AutoIt3Wrapper_Res_Icon_Add=AutoIt - íconesHelpDesk.ico
#AutoIt3Wrapper_Res_Icon_Add=AutoIt - íconesInformação.ico
#AutoIt3Wrapper_Res_Icon_Add=AutoIt - íconesNegação.ico
#AutoIt3Wrapper_Res_Icon_Add=AutoIt - íconesOK.ico
#AutoIt3Wrapper_Res_Icon_Add=AutoIt - íconesQuestão.ico

; Inclui o script necessário para usar o comando GUICreate

#include <GUIConstantsEx.au3>

; Inclui o script necessário para usar o parâmetro style do comando GUICreate

#include <WindowsConstants.au3>

; Inclui o script necessário para usar o parâmetro style do comando GUICtrlCreateInput

#include <EditConstants.au3>

; Inclui o script necessário para usar o parâmetro style do comando GUICtrlCreateCombo

#include <ComboConstants.au3>

; Inclui o script necessário para usar o parâmetro style do comando GUICtrlCreateLabel

#include <StaticConstants.au3>

; Inclui o script necessário para usar o parâmetro style do comando GUICtrlCreateList

#include <ListboxConstants.au3>

; Inclui o script necessário para usar o parâmetro style do comando GUICtrlCreateUpdown

#include <UpdownConstants.au3>

; Inclui o script necessário para usar o parâmetro style do comando GUICtrlCreateGroup

#include <ButtonConstants.au3>

; Inclui o script necessário para usar o parâmetro style do comando GUICtrlCreateEdit

#include <EditConstants.au3>

; Inclui o script necessário para usar o comando _ArraySearch

#Include <Array.au3>

; Inclui o script necessário para usar os comandos _FilePrint e _ReplaceStringInFile

#Include <File.au3>

; Inclui o script necessário para usar o comando _StringRepeat

#Include <String.au3>

; Inclui o script necessário para usar o comando _Singleton

#include <Misc.au3>

; Inclui o script necessário para usar o comando _SetTime

#Include <Date.au3>

; Faz com que o script seja executado com direitos de administrador

#requireadmin

; ==================================================================================================================
;                                             PROGRAMA PRINCIPAL
; ==================================================================================================================

; ==============================
; Definição de variáveis globais
; ==============================

Global $titulo_janela , $item_selecionado , $botao_clicado , $barra_progresso , $configuracao_atual , $creditos , _
       $creditos , $matriz_icones [6] = [ "A" , "H" , "I" , "N" , "O" , "Q" ]

; Resolução de vídeo

Global $res_horizontal = @DesktopWidth , $res_vertical = @DesktopHeight

; Tamanho da fonte

Global $ppp = RegRead ( "HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionFontDPI" , "LogPixels" ) , _
       $tam_fonte = 14 / ( $ppp / 96 ) , $proporcao = $tam_fonte / 8.5 * ( $ppp / 96 )

; =============================================================
; Encerra o programa se outra instância dele já estiver rodando
; =============================================================

_Singleton ( @ScriptName )

; =============================================================================================
; Desabilita a possibilidade do usuário pausar ou encerrar o script clicando no ícone do AutoIt
; =============================================================================================

Break (0)

; ==================================================================================================================
;                                                  FUNÇÕES
; ==================================================================================================================

Seleciona_item_radio ( "Example1: here you can browse among the items with the keyboard." , "Item 1|Item 2|Item 3" , "" , "" , "Next" , 500 )
Seleciona_item_radio ( "Example2: here you can not browse among the items with the keyboard." , "Item 1|Item 2|Item 3" , "detail 1|detail 2|detail 3" , "" , "Next" , 500 )

; ========================================================
; Função que seleciona um ítem de uma lista estilo "Radio"
; ========================================================

Func Seleciona_item_radio ( $cabecalho , $lista_itens , $lista_detalhes , $rodape , $lista_botoes , $largura_janela )

    ; Cria as matrizes de ítens, detalhes e botões ---------------------------------------------------------------------------------

    $matriz_itens      = StringSplit ( $lista_itens     , "|" )
    $matriz_detalhes = StringSplit ( $lista_detalhes , "|" )
    $matriz_botoes     = StringSplit ( $lista_botoes     , "|" )
    $qtde_itens         = $matriz_itens  [0]

    ; Se houver apenas um ítem, finaliza a função selecionando esse ítem -----------------------------------------------------------

    If $qtde_itens = 1  Then

        $item_selecionado = $lista_itens
        Return ( $item_selecionado )

    EndIf

    ; Separa o ícone e o texto do rodapé ------------------------------------------------------------------------------------

    If Not StringInStr ( $rodape , "|" ) Then

        $icone_rodape = "não há"

    Else

        $icone_rodape = -5 - _ArraySearch ( $matriz_icones , StringLeft ( $rodape , 1 ) , 0 , 0 , 0 , 0 , 1 )
        $rodape       = StringTrimLeft ( $rodape , 2 )

    EndIf

    ; Calcula as dimensões da janela e dos seus componentes (cabeçalho, ítens, ícone e rodapé) ------------------------------

    If $lista_detalhes = "" Then
        $altura_item = 20 * $proporcao
    Else
        $altura_item = 40 * $proporcao
    EndIf

    $largura_janela      = $largura_janela * $proporcao
    $proporcao_rodape = ( $tam_fonte - 2 ) / 8.5
    $largura_icone      = ( $icone_rodape <> "não há" ) * ( 32 + 12 * $proporcao_rodape )
    $altura_rodape      = Altura_texto ( $rodape    , $tam_fonte - 2 , $largura_janela - 60 * $proporcao - $largura_icone )
    $altura_cabecalho = Altura_texto ( $cabecalho , $tam_fonte   , $largura_janela - 60 * $proporcao )

    If $icone_rodape <> "não há" And $altura_rodape < 32 Then $altura_rodape = 32
    If $rodape          <> ""                                  Then $altura_rodape = $altura_rodape + 20 * $proporcao_rodape

    $altura_janela = $altura_cabecalho + 80 * $proporcao + $qtde_itens * $altura_item + $altura_rodape + 60

    ; Cria a janela e exibe o cabeçalho --------------------------------------------------------------------------------------------

    Exibe_janela_cabecalho ( $largura_janela , $altura_janela , $cabecalho , $altura_cabecalho , $tam_fonte , $proporcao )

    ; Exibe os ítens e seus detalhes -----------------------------------------------------------------------------------------------

    Global $matriz_itens_radio [$qtde_itens + 1]

    For $numero = 1 to $qtde_itens

        $matriz_itens_radio [$numero] = GUICtrlCreateRadio ( $matriz_itens [$numero] , 30 * $proporcao _
                                                           , 65 * $proporcao + $altura_cabecalho _
                                                           + $altura_item * ( $numero - 1 ) _
                                                           , $largura_janela - 60 * $proporcao )

        If $lista_detalhes <> "" Then

            GUICtrlCreateLabel ( $matriz_detalhes [$numero] , 41 * $proporcao , 88 * $proporcao + $altura_cabecalho _
                               + $altura_item * ( $numero - 1 ) , $largura_janela - 60 * $proporcao )
            GUICtrlSetFont        ( -1 , $tam_fonte - 2 )

        EndIf

    Next

    GUICtrlSetState ( $matriz_itens_radio [1] , $GUI_CHECKED )

    ; Exibe o rodapé ---------------------------------------------------------------------------------------------------------------

    Exibe_rodape ( $rodape , $altura_rodape , $icone_rodape , $largura_icone , $largura_janela , $altura_janela )

    ; Define as funções que permitem navegar pelos ítens através do teclado --------------------------------------------------------

    HotKeySet ( "{UP}"      , "Volta_item_radio"  )
    HotKeySet ( "{DOWN}" , "Avanca_item_radio" )

    ; Exibe os botões e obtém o botão clicado --------------------------------------------------------------------------------------

    Obtem_botao_clicado ( $matriz_botoes , 80 , "H" , $largura_janela , $altura_janela )

    ; Obtém o ítem selecionado -----------------------------------------------------------------------------------------------------

    For $numero = 1 to $qtde_itens

        If GUICtrlRead ( $matriz_itens_radio [$numero] ) = $GUI_CHECKED Then $item_selecionado = $matriz_itens [$numero]

    Next

    ; Fecha a janela e finaliza a função ------------------------------------------------------------------------------------

    GUIDelete ()
    Return       ( $item_selecionado )

EndFunc

; ===========================================================================
; Função que retrocede um ítem de uma lista estilo "Radio" através do teclado
; ===========================================================================

Func Volta_item_radio ()

    $qtde_itens = UBound ( $matriz_itens_radio ) - 1

    For $numero = 1 to $qtde_itens

        If GUICtrlRead ( $matriz_itens_radio [$numero] ) = $GUI_CHECKED Then

            GUICtrlSetState ( $matriz_itens_radio [$numero] , $GUI_UNCHECKED + $GUI_NOFOCUS )

            If $numero = 1 Then
                GUICtrlSetState ( $matriz_itens_radio [$qtde_itens] , $GUI_CHECKED + $GUI_FOCUS )
            Else
                GUICtrlSetState ( $matriz_itens_radio [$numero - 1] , $GUI_CHECKED + $GUI_FOCUS )
            EndIf

            Return

        EndIf

    Next

EndFunc

; ========================================================================
; Função que avança um ítem de uma lista estilo "Radio" através do teclado
; ========================================================================

Func Avanca_item_radio ()

    $qtde_itens = UBound ( $matriz_itens_radio ) - 1

    For $numero = 1 to $qtde_itens

        If GUICtrlRead ( $matriz_itens_radio [$numero] ) = $GUI_CHECKED Then

            GUICtrlSetState ( $matriz_itens_radio [$numero] , $GUI_UNCHECKED + $GUI_NOFOCUS )

            If $numero = $qtde_itens Then
                GUICtrlSetState ( $matriz_itens_radio [1]             , $GUI_CHECKED + $GUI_FOCUS )
            Else
                GUICtrlSetState ( $matriz_itens_radio [$numero + 1] , $GUI_CHECKED + $GUI_FOCUS )
            EndIf

            Return

        EndIf

    Next

EndFunc

; ===============================================
; Função que obtém uma resposta para uma pergunta
; ===============================================

Func Obtem_resposta ( $pergunta , $lista_botoes , $largura_janela )

    ; Cria a matriz de botões e define sua altura e largura ----------------------------------------------------------------

    If $lista_botoes = "" Then

        $altura_botoes = 0

    Else

        $matriz_botoes  = StringSplit ( $lista_botoes , "|" )
        $qtde_botoes    = $matriz_botoes [0]
        $altura_botoes  = 27 * $proporcao
        $largura_botoes = 48 * $proporcao

    EndIf

    ; Separa o ícone e o texto da pergunta ----------------------------------------------------------------------------------

    If StringInStr ( $pergunta , "|" ) Then

        If StringLeft ( $pergunta , 1 ) = "B" Then

            $barra_progresso = "há"
            $icone_pergunta  = "não há"

        Else

            $barra_progresso = "não há"
            $icone_pergunta  = -5 - _ArraySearch ( $matriz_icones , StringLeft ( $pergunta , 1 ) , 0 , 0 , 0 , 0 , 1 )

        EndIf

        $pergunta = StringTrimLeft ( $pergunta , 2 )

    Else

        $barra_progresso = "não há"
        $icone_pergunta  = "não há"

    EndIf

    ; Calcula as dimensões da janela e de seus componentes (ícone e pergunta) -----------------------------------------------

    $largura_janela     = $largura_janela * $proporcao
    $largura_icone     = ( $icone_pergunta <> "não há" ) * ( 32 + 12 * $proporcao )
    $altura_pergunta = Altura_texto ( $pergunta , $tam_fonte , $largura_janela - 60 * $proporcao - $largura_icone )

    If $icone_pergunta <> "não há" And $altura_pergunta < 32 Then $altura_pergunta = 32

    $altura_janela = $altura_pergunta + ( 54 + 40 * ( $barra_progresso = "há" ) ) * $proporcao + $altura_botoes

    ; Cria a janela --------------------------------------------------------------------------------------------------------

    GUICreate  ( $titulo_janela , $largura_janela , $altura_janela , -1 , -1 , $WS_CAPTION , $WS_EX_TOPMOST )
    GUISetFont ( $tam_fonte )

    ; Exibe a pergunta ------------------------------------------------------------------------------------------------------------

    GUICtrlCreateIcon ( @ScriptFullPath , $icone_pergunta , 30 * $proporcao , 30 * $proporcao )

    If $altura_pergunta = 14 * $proporcao And $icone_pergunta = "não há" Then

        GUICtrlCreateLabel ( $pergunta , 30 * $proporcao + $largura_icone , 30 * $proporcao _
                           , $largura_janela - 60 * $proporcao - $largura_icone , $altura_pergunta , $SS_CENTER )

    Else

        GUICtrlCreateLabel ( $pergunta , 30 * $proporcao + $largura_icone , 30 * $proporcao _
                           , $largura_janela - 60 * $proporcao - $largura_icone , $altura_pergunta )

    EndIf

    ; Exibe a barra de progresso ----------------------------------------------------------------------------------------------

    If $barra_progresso = "há" Then

        $barra_progresso     = GUICtrlCreateProgress ( 15 * $proporcao , $altura_janela - 45 * $proporcao _
                                                    , $largura_janela - 30 * $proporcao , 20 * $proporcao )
        $configuracao_atual = GUICtrlCreateLabel    ( "" , 15 * $proporcao , $altura_janela - 20 * $proporcao _
                                                    , $largura_janela - 30 * $proporcao , 20 * $proporcao , $SS_CENTER )
                              GUICtrlSetFont         ( -1 , $tam_fonte - 3 )

    EndIf

    If $lista_botoes <> "" Then

        ; Se houver botões, exibe-os, obtém o botão clicado, fecha a janela e encerra a função devolvendo o botão clicado --------

        Obtem_botao_clicado ( $matriz_botoes , $largura_botoes , "H" , $largura_janela , $altura_janela )
        GUIDelete             ()
        Return                   ( $botao_clicado )

    Else

        ; Se não houver botões, apenas ativa a janela e encerra a função ---------------------------------------------------

        GUISetState ()
        Return

    EndIf

EndFunc

; ===============================================
; Função que cria uma janela e exibe um cabeçalho
; ===============================================

Func Exibe_janela_cabecalho ( $largura_janela , $altura_janela , $cabecalho , $altura_cabecalho , $tam_fonte_janela _
                            , $proporcao_cabecalho )

    ; Cria a janela ----------------------------------------------------------------------------------------------------------------

    GUICreate ( $titulo_janela , $largura_janela , $altura_janela , -1 , -1 , $WS_CAPTION , $WS_EX_TOPMOST )

    ; Exibe o cabeçalho ------------------------------------------------------------------------------------------------------------

    GUICtrlCreateGraphic ( 0 , 0 , $largura_janela , 30 * $proporcao_cabecalho + $altura_cabecalho )
    GUICtrlSetBkColor     ( -1 , 0xffffff )
    GUICtrlSetColor         ( -1 , 0 )
    GUISetFont                 ( $tam_fonte_janela )
    GUICtrlCreateLabel      ( $cabecalho , 30 * $proporcao_cabecalho , 15 * $proporcao_cabecalho _
                         , $largura_janela - 60 * $proporcao_cabecalho , $altura_cabecalho )
    GUICtrlSetBkColor     ( -1 , 0xffffff )

EndFunc

; ==========================
; Função que exibe um rodapé
; ==========================

Func Exibe_rodape ( $rodape , $altura_rodape , $icone_rodape , $largura_icone , $largura_janela , $altura_janela )

    If $rodape <> "" Then

        GUICtrlCreateIcon  ( @ScriptFullPath , $icone_rodape , 30 * $proporcao , $altura_janela - 25 - $altura_rodape )
        GUICtrlCreateLabel ( $rodape , 30 * $proporcao + $largura_icone , $altura_janela - 25 - $altura_rodape _
                           , $largura_janela - 60 * $proporcao - $largura_icone , $altura_rodape )
        GUICtrlSetFont        ( -1 , $tam_fonte - 2 )

    EndIf

EndFunc

; ===============================================
; Função que exibe botões e obtém o botão clicado
; ===============================================

Func Obtem_botao_clicado ( $matriz_botoes , $largura_botoes , $disposicao_botoes , $largura_janela , $altura_janela )

    ; Exibe os botões --------------------------------------------------------------------------------------------------------------

    If $disposicao_botoes = "H" Then
        GUICtrlCreateGroup ( "" , 0 , $altura_janela - 56 , $largura_janela , 56 )
        GUISetFont            (8.5)
    Else
        GUISetFont           ($tam_fonte)
    EndIf

    $qtde_botoes  = UBound ( $matriz_botoes ) - 1
    $botao_padrao = 1

    For $numero = 1 to $qtde_botoes

        If $disposicao_botoes = "H" Then

            If $qtde_botoes = 1 Then

                $posicao_horizontal  = $largura_janela / 2 - $largura_botoes / 2

            ElseIf $numero = $qtde_botoes Then

                $posicao_horizontal     = $largura_janela - 10 - $largura_botoes

            Else

                $posicao_horizontal     = $largura_janela - ( $qtde_botoes - $numero ) * $largura_botoes - 20 - $largura_botoes

            EndIf

            $matriz_botoes [$numero] = GUICtrlCreateButton ( $matriz_botoes [$numero] , $posicao_horizontal _
                                                           , $altura_janela - 35 , $largura_botoes )

        Else

            $matriz_botoes [$numero] = GUICtrlCreateButton ( $matriz_botoes [$numero] , $largura_janela / 2 _
                                                           - $largura_botoes / 2 , $altura_janela - 20 * $proporcao _
                                                           - ( ( $qtde_botoes - $numero + 1 ) * 27 * $proporcao ) _
                                                           , $largura_botoes , 21 * $proporcao )

        EndIf

        Switch GUICtrlRead ( $matriz_botoes [$numero] )

            Case "OK" , "Sim" , "Avançar >"

                $botao_padrao = $numero

        EndSwitch

    Next

    GUICtrlSetState ( $matriz_botoes [$botao_padrao] , $GUI_DEFBUTTON )
    GUISetState     ()

    ; Obtém o botão clicado --------------------------------------------------------------------------------------------------------

    While 1

        $acao = GUIGetMsg ()

        For $numero = 1 to $qtde_botoes

            If $acao = $matriz_botoes [$numero] Then

                $botao_clicado = GUICtrlRead ( $acao )

                Switch $botao_clicado

                    Case "Créditos"

                        GUISetState    ( @SW_HIDE )
                        Obtem_resposta ( $creditos , "OK" , 360 )
                        GUISetState    ( @SW_SHOW )

                    Case "Sair"

                        Aborta ()

                    Case Else

                        ExitLoop 2

                EndSwitch

            EndIf

        Next

    WEnd

    Return ( $botao_clicado )

EndFunc

; =======================================
; Função que calcula a altura de um texto
; =======================================

Func Altura_texto ( $texto , $tam_fonte_texto , $largura_paragrafo )

    $proporcao_texto   = $tam_fonte_texto / 8.5 * ( $ppp / 96 )
    $altura               = 0
    $matriz_paragrafos = StringSplit ( $texto , Chr(13) )

    For $num = 1 To $matriz_paragrafos [0]

        $altura = $altura + ( Ceiling ( StringLen ( $matriz_paragrafos [$num] ) / ( $largura_paragrafo / _
                  ( 5 * $proporcao_texto ) ) ) * 14 * $proporcao_texto )
        If $matriz_paragrafos [$num] = "" Then $altura = $altura + 14 * $proporcao_texto

    Next

    Return ( $altura )

EndFunc

; ============================
; Função que aborta o programa
; ============================

Func Aborta ()

    GUISetState ( @SW_HIDE )
    If Obtem_resposta ( "Q|O programa ainda não foi concluído." & Chr(13) & Chr(13) & "Tem certeza que deseja sair?" _
                      , "Sim|Não" , 280 ) = "Sim" Then Encerra ()
    GUISetState ( @SW_SHOW )

EndFunc

; =============================
; Função que encerra o programa
; =============================

Func Encerra ()

    RunWait ( @ComSpec & " /c " & """" & @ScriptDir & "Arquivos1365VidChng.exe"" " & $res_horizontal & "x" & _
            $res_vertical & "x32@60 -q" )
    Exit

EndFunc
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...