Rhazz

How to configure a GUI Progress Bar by a double "for" loop

8 posts in this topic

#1 ·  Posted (edited)

Hello again, my second post in 24 hs! :P

It's my first GUI... and my first progress bar also! Sorry if I make a newbie mistake.

I want to configure a GUI Progress Bar by a double "for" loop.

Here is my code with a specific annotation with what I want to do:

Edit: new problem, I have no idea how can I continue with the next $a as if the current $a, I do not skip it because the line is an element less (I need help with both problems):

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <WinAPI.au3>
#include <File.au3>
#include <String.au3>
#include <Array.au3>


Local $idGUI = GUICreate("ProgressBar", 220, 130, 100, 200)
Opt("GUIOnEventMode", 1)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEButton")
Local $idInput = GUICtrlCreateInput("",80,20,60,20,$ES_NUMBER)
Local $idProgressBar = GUICtrlCreateProgress(10, 60, 200, 20)
Local $idButton1 = GUICtrlCreateButton("Start",85,100,50)
GUICtrlSetOnEvent($idButton1, "StartProgressBar")
Local $aFileOpen = _WinAPI_GetOpenFileName("Open a text file", "Text Files (*.txt)")
Local $idCountLines = _FileCountLines($aFileOpen[2])
Local $idInputValue, $idSomething, $aFileResult, $idStringBetween

GUISetState(@SW_SHOW, $idGUI)
While 1
    Sleep(20000)
WEnd

Func StartProgressBar()
    If StringInStr($aFileOpen[2], ".txt") = True Then
        $idInputValue = Int(GUICtrlRead($idInput))
        If IsFloat($idCountLines/$idInputValue) = 1 Then
            $idStringBetween = _StringBetween(String($idCountLines/$idInputValue),"", ".")
            $idSomething = Number($idStringBetween[0]) + 1
        Else
            $idSomething = $idCountLines/$idInputValue
        EndIf
        For $i = 1 To $idSomething
            $aFileResult = @ScriptDir & "\result-" & $i & ".txt"
            _FileCreate($aFileResult)
            FileOpen($aFileResult,2)
            For $a = ( ( ( $i - 1 ) * $idInputValue ) + 1 ) To ( $i * $idInputValue )
                If FileReadLine($aFileOpen[2], $a) = "" Then
                    ; Here I have no idea how can I continue with the next $a as if the current $a, I do not skip it because the line is an element less
                EndIf
                FileWrite($aFileResult,FileReadLine($aFileOpen[2], $a) & " - ")
                ;Here I want to set the progress bar value = current percentage (line that it is currently reading) of the 100% (total of lines in the file opened)
            Next
            FileClose($aFileResult)
        Next
        MsgBox(0,"Done","Done")
        GUICtrlSetData($idProgressBar,0)
    Else
        MsgBox(0,"Hello :)","Please open a file :D")
    EndIf
EndFunc

Func CLOSEButton()
    Exit
EndFunc

 

Thanks in advance.

 

Edited by Rhazz
New problem added

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

First you need to get the percentage based on the multiplication of loop ($i*$a) real loops.  then divide  progressbar size by that multiplication.

100/($i*$a) that will result that number of necessary movement that you will use on loop. Finally you will get something like this.

#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 374, 115, 192, 124)
$Progress1 = GUICtrlCreateProgress(16, 24, 345, 49)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Local $i=300-100
Local $a=200
Local $imove=100/($i*$a)
Local $itemp=0


For $i= 100 to 300
    For $a=1 to 200
        $itemp+=$imove
        GUICtrlSetData($Progress1,$itemp)
        ;for continue with the next $a just use ContinueLoop
    Next
    $itemp+=$imove
    GUICtrlSetData($Progress1,$itemp)

Next

ConsoleWrite($itemp & @CRLF)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd
 

Saludos

Edited by Danyfirex

Share this post


Link to post
Share on other sites

First you need to get the percentage based on the multiplication of loop ($i*$a) real loops.  then divide  progressbar size by that multiplication.

100/($i*$a) that will result that number of necessary movement that you will use on loop. Finally you will get something like this.

#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 374, 115, 192, 124)
$Progress1 = GUICtrlCreateProgress(16, 24, 345, 49)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Local $i=300-100
Local $a=200
Local $imove=100/($i*$a)
Local $itemp=0


For $i= 100 to 300
    For $a=1 to 200
        $itemp+=$imove
        GUICtrlSetData($Progress1,$itemp)
        ;for continue with the next $a just use ContinueLoop
    Next
    $itemp+=$imove
    GUICtrlSetData($Progress1,$itemp)

Next

ConsoleWrite($itemp & @CRLF)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd
 

Saludos

Spanish: Veo que hablás español, así que hola! "ContinueLoop" salta la linea del primer archivo y no la agrega a la linea del segundo archivo, ejemplo:

  • Línea 1 - Línea 2 - Línea 3 -
  • Línea 5 - Línea 6 - Línea 7- Línea 8 -

Si te fijas, saltó la línea 4 (suponiendo que está vacía). Igualmente tengo que mirarlo con detenimiento para ver qué puedo hacer, pero no he tenido tiempo.

 

English: Hi, with ContinueLoop the script skips the empty line (of the first file) and therefore there is an element less in the line of the second file (the empty line of the first file becomes into empty space in the second file). e.g. the user wants four lines (of the 1st file) per line (of the 2nd file) and the fourth line (of the 1st file) is empty:

  • Line 1 - Line 2 - Line 3 -
  • Line 5 - Line 6 - Line 7 - Line 8

In the first line there is an element less.Whatever, I have to try it again, these days I didn't have much time.

Share this post


Link to post
Share on other sites

Si fijate en la ayuda y notaras un ejemplo que continueloop esquiva un determinado loop.

Yes look into help file and you will notice an example that continuwloop avoid a determined loop.

 

Saludos

Share this post


Link to post
Share on other sites

Si fijate en la ayuda y notaras un ejemplo que continueloop esquiva un determinado loop.

Yes look into help file and you will notice an example that continuwloop avoid a determined loop.

 

Saludos

I said that ContinueLoop doesn't work, I want to skip a line, not skip a loop. Sorry if I didn't explain me well. Here are another example with the code:

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <WinAPI.au3>
#include <File.au3>
#include <String.au3>
#include <Array.au3>


Local $idGUI = GUICreate("ProgressBar", 220, 130, 100, 200)
Opt("GUIOnEventMode", 1)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEButton")
Local $idInput = GUICtrlCreateInput("",80,20,60,20,$ES_NUMBER)
Local $idProgressBar = GUICtrlCreateProgress(10, 60, 200, 20)
Local $idButton1 = GUICtrlCreateButton("Start",85,100,50)
GUICtrlSetOnEvent($idButton1, "StartProgressBar")
Local $aFileOpen = _WinAPI_GetOpenFileName("Open a text file", "Text Files (*.txt)")
Local $idCountLines = _FileCountLines($aFileOpen[2])
Local $idInputValue, $idSomething, $aFileResult, $idStringBetween

GUISetState(@SW_SHOW, $idGUI)
While 1
    Sleep(20000)
WEnd

Func StartProgressBar()
    If StringInStr($aFileOpen[2], ".txt") = True Then
        $idInputValue = Int(GUICtrlRead($idInput))
        If IsFloat($idCountLines/$idInputValue) = 1 Then
            $idStringBetween = _StringBetween(String($idCountLines/$idInputValue),"", ".")
            $idSomething = Number($idStringBetween[0]) + 1
        Else
            $idSomething = $idCountLines/$idInputValue
        EndIf
        For $i = 1 To $idSomething
            $aFileResult = @ScriptDir & "\result-" & $i & ".txt"
            _FileCreate($aFileResult)
            FileOpen($aFileResult,2)
            For $a = ( ( ( $i - 1 ) * $idInputValue ) + 1 ) To ( $i * $idInputValue )
                If FileReadLine($aFileOpen[2], $a) = "" Then
                    ; ContinueLoop
                    ; Here I have no idea how can I continue with the next $a as if the current $a, I do not skip it because the line is an element less
                EndIf
                GUICtrlSetData($idProgressBar, (100/($i*$a)))
                MsgBox(0,"",(100/($i*$a)))
                FileWrite($aFileResult,FileReadLine($aFileOpen[2], $a) & " - ")
                ; Here I want to set the progress bar value = current percentage (line that it is currently reading) of the 100% (total of lines in the file opened)
            Next
            FileClose($aFileResult)
        Next
        MsgBox(0,"Done","Done")
        Sleep(5000)
        GUICtrlSetData($idProgressBar,0)
    Else
        MsgBox(0,"Hello :)","Please open a file :D")
    EndIf
EndFunc

Func CLOSEButton()
    Exit
EndFunc

With a first text file that contains:

Line1
Line2
Line3
Line4

Line6
Line7
Line8
Line9
Line10
Line11
Line12

And if the user introduces "6" the result is:

  • result-1.txt --> Line1 - Line2 - Line3 - Line4 - Line6 - (five lines, the user wants six)
  • result-2.txt --> Line7 - Line8 - Line9 - Line10 - Line11 - Line12 - (six lines, great)

I have been reading the Help File and I think that there are two options that might work:

  1. Read the text file and create a temporary file without blank lines, and use it to create the final text file.
  2. Try to use _FileReadToArray

What do you think about it? What is most effectively? Are there a better option?

And with that code, the progress bar works wrong :s I didn't find the correct operation, I think that might it works with _FileReadToArray (the total of it would be 100% and the current row/position would be the current percentage).

PS: I also think maybe using _FileReadToArray might be too much work for big text files... I'm wrong?

Share this post


Link to post
Share on other sites

Simply check for a not empty line. also create a variable counter to plus one every time that is not emply line instead using $i.

 

Saludos

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Simply check for a not empty line. also create a variable counter to plus one every time that is not emply line instead using $i.

 

Saludos

That doesn't work because I need to exclude the empty lines, but what you say will return the numbers of non-empty lines and the script will read that numbers of lines but without skip the blank lines.

A good news: Finally I could set the progress bar! It works now! I used "Total Of Lines" / ("Current Line" * 100)

Finally I got the solution!!!!

I created another variable to set what line have to read the script. Here is my full code, I hope be helpful for somebody :)

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <WinAPI.au3>
#include <File.au3>
#include <String.au3>
#include <Array.au3>


Local $idGUI = GUICreate("ProgressBar", 220, 130, 100, 200)
Opt("GUIOnEventMode", 1)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEButton")
Local $idInput = GUICtrlCreateInput("",80,20,60,20,$ES_NUMBER)
Local $idProgressBar = GUICtrlCreateProgress(10, 60, 200, 20)
Local $idButton1 = GUICtrlCreateButton("Start",85,100,50)
GUICtrlSetOnEvent($idButton1, "StartProgressBar")
Local $aFileOpen = _WinAPI_GetOpenFileName("Open a text file", "Text Files (*.txt)")
Local $idCountLines = _FileCountLines($aFileOpen[2])
Local $idInputValue, $idSomething, $aFileResult, $idStringBetween, $LineToRead, $totalNonEmptyLines
For $y = 1 To $idCountLines
    If FileReadLine($aFileOpen[2],$y) <> "" Then $totalNonEmptyLines += 1
Next


GUISetState(@SW_SHOW, $idGUI)
While 1
    Sleep(20000)
WEnd

Func StartProgressBar()
    If StringInStr($aFileOpen[2], ".txt") = True Then
        $idInputValue = Int(GUICtrlRead($idInput))
        If IsFloat($totalNonEmptyLines/$idInputValue) = 1 Then
            $idStringBetween = _StringBetween(String($totalNonEmptyLines/$idInputValue),"", ".")
            $idSomething = Number($idStringBetween[0]) + 1
        Else
            $idSomething = $totalNonEmptyLines/$idInputValue
        EndIf
        For $i = 1 To $idSomething
            $aFileResult = @ScriptDir & "\result-" & $i & ".txt"
            _FileCreate($aFileResult)
            FileOpen($aFileResult,2)
            For $a = ( ( ( $i - 1 ) * $idInputValue ) + 1 ) To ( $i * $idInputValue )
                $LineToRead += 1
                While FileReadLine($aFileOpen[2], $LineToRead) = ""
                    $LineToRead += 1
                    If $a = $idCountLines Then ExitLoop
                WEnd
                GUICtrlSetData($idProgressBar, (($LineToRead*100)/$totalNonEmptyLines))
                FileWrite($aFileResult,FileReadLine($aFileOpen[2], $LineToRead) & " - ")
            Next
            FileClose($aFileResult)
        Next
        MsgBox(0,"Done","Done")
        GUICtrlSetData($idProgressBar,0)
    Else
        MsgBox(0,"Hello :)","Please open a file :D")
    EndIf
EndFunc

Func CLOSEButton()
    Exit
EndFunc

 

Edited by Rhazz
Finally solved!

Share this post


Link to post
Share on other sites

This is an Old post but anyways here an Advise:

Why you dont use Round(), you will avoid unnecessary call to _StringBetween?
Your Code:

If IsFloat($totalNonEmptyLines/$idInputValue) = 1 Then
            $idStringBetween = _StringBetween(String($totalNonEmptyLines/$idInputValue),"", ".")
            $idSomething = Number($idStringBetween[0]) + 1

What I would probably do:
 

If IsFloat($totalNonEmptyLines/$idInputValue) = 1 Then
            $id = Round($totalNonEmptyLines/$idInputValue),0)
            $idnum = Number($id + 1)

This is just an Idea but I think is more efficient.

Kind Regards
Alien
 

Share this post


Link to post
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

  • Similar Content

    • Lights_On
      By Lights_On
      Hi all,

      I am having a little trouble with ‘GUICtrlSetResizing’ an hoping someone could push me in the direction of best practice.

      I have a basic GUI created to a set size with the enabled abilities to resize it:

      GUICreate("Test", 500, 450, -1, -1, BitOR($WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX))

      Inside this I have an image and label:

      GUICtrlCreateLabel($Image1StampInfo, 10, 395, 480, 20, $SS_CENTER) GUICtrlCreatePic($TheImage, 25, 25, 450, 350)

      Using:

      Case ($GUI_EVENT_MAXIMIZE or $GUI_EVENT_RESTORE or $GUI_EVENT_RESIZED)

      I activate:

       
      GUICtrlSetResizing($TheImageBox, $GUI_DOCKAUTO) GUICtrlSetResizing($Image1Stamp, $GUI_DOCKAUTO)

      This works fine with the image but not with the label – the label after a bit of resizing seems to get stuck in different places in the GUI as if the $GUI_DOCKAUTO has not worked properly.

      So 2 questions if I may. 

      1)    Have I used $GUI_DOCKAUTO incorrectly for use with lables?

      2)    I am happy to manually set new sizes dynamically but how? I can get the size of the window with ‘WinGetPos()’ but how do I set new size parameters for the ‘label’ and ‘image’?

      Thank you in advance.

    • FrancescoDiMuro
      By FrancescoDiMuro
      Good evening guys ( almost good night here in Italy )  
      How are you? Hop you're fine  
      I'm trying to do a Login Form ( I did, but I'm missing something in the management ), that allows the user to login when the script is launched, and, when the main GUI is opened, the user can Logout and Login with another username and password.
      The username and password "checking" I do is done by a text file, which in there are username and password, crypted through _Crypt_EncryptData().
      The "issue" I'm having at the moment, is to manage the Login form when the user hasn't already done the login, and so, the main GUI is not visible, but is created...
      I create the main GUI after the Login form... I tried with WinActive, WinGetState, but nothing changed ( even at the first Login, the script says ( through a MsgBox ) that the Win does exists ( or is active... ) and, as I want, it is not shown again...

      I really don't know If I missed something, or, I don't know...
      I'm going crazy for this thing...
      If someone could help me, I'd really appreaciate it!
      Thanks for the reading
      #Region ### START Koda GUI section ### Form=C:\Users\Portatile-60\Documents\Documenti Lavoro\AutoIt\Gestione_Magazzino_v2\form_Login.kxf Global $form_Login = GUICreate("Effettua il Login per continuare:", 405, 120, @DesktopWidth/2 - 202.5, @DesktopHeight/2 - 150) ; 302, 218 GUISetOnEvent($GUI_EVENT_CLOSE, "GUIDeleteLogin") Global $combo_Username = GUICtrlCreateCombo("Di Muro Francesco", 104, 64, 217, 25) GUICtrlSetFont(-1, 10, 400, 0, "Arial") GUICtrlSetData($combo_Username, "somedata") Global $input_Password = GUICtrlCreateInput("", 104, 89, 217, 25, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD)) GUICtrlSetFont(-1, 10, 400, 0, "Arial") $button_VerificaDati = GUICtrlCreateButton("", 328, 66, 42, 42, $BS_ICON) GUICtrlSetImage(-1, "C:\Users\Portatile-60\Documents\Documenti Lavoro\AutoIt\Gestione_Magazzino_v2\Icone\icon_check.ico", -1) GUICtrlSetOnEvent($button_VerificaDati, "CheckLogin") $label_Titolo = GUICtrlCreateLabel("Login", 167, 14, 71, 33) GUICtrlSetFont(-1, 18, 800, 0, "Arial") $label_Username = GUICtrlCreateLabel("Username :", 24, 64, 76, 20) GUICtrlSetFont(-1, 10, 800, 0, "Arial") $label_Password = GUICtrlCreateLabel("Password :", 24, 89, 73, 20) GUICtrlSetFont(-1, 10, 800, 0, "Arial") #EndRegion ### END Koda GUI section ### Func CheckLogin() Local $sUsername = GUICtrlRead($combo_Username) Local $sPassword = GUICtrlRead($input_Password) MsgBox($MB_ICONINFORMATION, "", "Username: " & $sUsername & @CRLF & "Password: " & $sPassword) Local $sFileUtenti = @ScriptDir & "\utenti.txt" If @error Then MsgBox($MB_ICONERROR, "Errore!", "Errore durante la lettura del file!") Exit Else Local $hFileUtenti = FileOpen($sFileUtenti, $FO_READ) If @error Then MsgBox($MB_ICONERROR, "Errore!", "Errore durante l'apertura del file " & $sFileUtenti & "." & @CRLF & "Errore: " & @error) Else Local $sDatiUtente, $aDatiUtente Local $bUtenteTrovato = False Local $iLinea = 1 Local $sControlloWin = "" Local $sWin = WinGetState($form_GestioneMagazzino) MsgBox($MB_ICONINFORMATION, "", $sWin) If @error Then MsgBox($MB_ICONERROR, "Errore!", "Errore durante la verifica della GUI attiva." & @CRLF & "Errore: " & @error) EndIf If($sWin == 5) Then MsgBox($MB_ICONINFORMATION, "", "La GUI esiste!") Do $sDatiUtente = FileReadLine($hFileUtenti, $iLinea) $aDatiUtente = StringSplit($sDatiUtente, "|", $STR_NOCOUNT) If(BinaryToString(_Crypt_DecryptData($aDatiUtente[0], "CRYPT", $CALG_RC4)) = $sUsername And BinaryToString(_Crypt_DecryptData($aDatiUtente[1], "CRYPT", $CALG_RC4)) = $sPassword) Then $sControlloWin = "ESISTE" $bUtenteTrovato = True ExitLoop Else $iLinea+=1 If($sDatiUtente = "" And $bUtenteTrovato = False) Then MsgBox($MB_ICONWARNING, "Attenzione!", "Username o Password errati.") ExitLoop EndIf EndIf Until $bUtenteTrovato = True Else MsgBox($MB_ICONINFORMATION, "", "La GUI esiste!") Do $sDatiUtente = FileReadLine($hFileUtenti, $iLinea) $aDatiUtente = StringSplit($sDatiUtente, "|", $STR_NOCOUNT) If(BinaryToString(_Crypt_DecryptData($aDatiUtente[0], "CRYPT", $CALG_RC4)) = $sUsername And BinaryToString(_Crypt_DecryptData($aDatiUtente[1], "CRYPT", $CALG_RC4)) = $sPassword) Then $sControlloWin = "NON ESISTE" $bUtenteTrovato = True ExitLoop Else $iLinea+=1 If($sDatiUtente = "" And $bUtenteTrovato = False) Then MsgBox($MB_ICONWARNING, "Attenzione!", "Username o Password errati.") ExitLoop EndIf EndIf Until $bUtenteTrovato = True EndIf If($sControlloWin = "ESISTE") Then MsgBox($MB_ICONINFORMATION, "Login effettuato!", "Hai effettuato l'accesso come: " & @CRLF & $sUsername & ".") ; Setta come "non-cliccabile" il bottone di Login GUICtrlSetState($button_Login, $GUI_DISABLE) GUICtrlSetState($button_VisualizzaGiacenze, $GUI_ENABLE) GUICtrlSetState($button_AggiungiProdotto, $GUI_ENABLE) GUICtrlSetState($button_PrelevaProdotto, $GUI_ENABLE) GUICtrlSetState($button_RicercaProdotto, $GUI_ENABLE) GUICtrlSetState($button_CreaDDT, $GUI_ENABLE) GUICtrlSetState($button_MostraGiacenzeAZero, $GUI_ENABLE) GUICtrlSetState($combo_Magazzino, $GUI_ENABLE) GUICtrlSetState($button_Logout, $GUI_ENABLE) ; Setta come "non-cliccabile" il bottone di Login GUICtrlSetState($button_Login, $GUI_DISABLE) ; Setta l'utente che ha effettuato l'accesso nella label $label_CaptionUtente GUICtrlSetData($label_CaptionUtente, $sUsername) ; "Distruggi" la GUI Login GUIDelete($form_Login) FileClose($hFileUtenti) Else MsgBox($MB_ICONINFORMATION, "", "La GUI non esiste!") MsgBox($MB_ICONINFORMATION, "Login effettuato!", "Hai effettuato l'accesso come: " & @CRLF & $sUsername & ".") ; Mostra la GUI Principale GUISetState(@SW_SHOW, $form_GestioneMagazzino) ; Setta come "non-cliccabile" il bottone di Login GUICtrlSetState($button_Login, $GUI_DISABLE) ; Setta l'utente che ha effettuato l'accesso nella label $label_CaptionUtente GUICtrlSetData($label_CaptionUtente, $sUsername) ; "Distruggi" la GUI Login GUIDelete($form_Login) FileClose($hFileUtenti) EndIf EndIf EndIf EndFunc Func Logout() GUICtrlSetData($label_CaptionUtente, "") MsgBox($MB_ICONINFORMATION, "Logout effettuato!", "Effettua nuovamente il Login per utilizzare il programma.") ; Disabilita tutti i bottoni della GUI Principale GUICtrlSetState($button_VisualizzaGiacenze, $GUI_DISABLE) GUICtrlSetState($button_AggiungiProdotto, $GUI_DISABLE) GUICtrlSetState($button_PrelevaProdotto, $GUI_DISABLE) GUICtrlSetState($button_RicercaProdotto, $GUI_DISABLE) GUICtrlSetState($button_CreaDDT, $GUI_DISABLE) GUICtrlSetState($button_MostraGiacenzeAZero, $GUI_DISABLE) GUICtrlSetState($combo_Magazzino, $GUI_DISABLE) GUICtrlSetState($button_Logout, $GUI_DISABLE) ; Abilita il Login GUICtrlSetState($button_Login, $GUI_ENABLE) EndFunc EDIT:
      Solved, making an "integrated" Login form... 
    • AnonymousX
      By AnonymousX
      Hello, 
      I'm wondering if it is possible to read a radio button off a GUI running by another program? 
      Someone created these Outlook emails that when open appear to be in a GUI format. I could easily come up with a way of navigating these fields by using tab inputs, and then copying specific fields that I need. However there is a spot on the form that has 4 choices of radio buttons, asking for what the status of the task is, and I have no idea how to store which one of these was pressed. 
      End game is to be able to go through thousands of these forms, take input from specific fields from this GUI form in outlook and copy into cells in an excel spreadsheet. I believe I could create a script to do everything I need, if I could just obtain the value from which radio button was pressed.
      Any advice on how to obtain which radio button was press in this outlook form would be appreciated.
      Thanks,
      If I knew VBA better Outlook might have its own functions for figuring this out.
       
      Example:

      In this example I'd want to be able to know that the 2nd or Assigned radio button was selected. Only 1 button is able to be selected at a time. I'm assuming the way to do this would be to tab through the form get to the first box and then run some command to check if pressed then if no, keep checking till I find which of the 4 were pressed.
    • FrancescoDiMuro
      By FrancescoDiMuro
      Good morning guys
      How are you? Hope you're fine
      I'm doing some field checking...
      Can you suggest me something? Something like: If the user doesn't prompt anything in a field, MsgBox and focus on the "blank" field, else, keep up with the script.
      I thought on a nested If...Else, but I have something like 10+ edit to control...
      Thanks guys! 
      EDIT:
      And I would like to know either how to retrieve all listview item ( 2 columns ) from a ListView...
      Column A|Column B
      abcd         | 1234
      bcda         | 1432
      How can I retrieve an array with abcd|1234|bcda|1432 ?
      Thanks  
       
    • triodz
      By triodz
      I want the number in a file to be overwritten with the next number up each time a button is pressed. 
      So it is pressed once, the number '1' is written to the file. It is pressed again and the number '2' overwrites the first number.
      At the moment I get the number 1 written, but can't get it to overwrite. What I have so far:
      #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> #Region ### START Koda GUI section ### Form=C:\Users\soulf\Desktop\CalcGui\RLCalc.kxf $Form1 = GUICreate("Form1", 615, 437, 426, 141) $One = GUICtrlCreateButton("1", 32, 72, 25, 25) GUICtrlSetBkColor(-1, 0xFF0000) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Func First ()     $fPath = "C:\temp\First.txt"     $fOpen = FileOpen ($fPath, 2)     $Counter = FileReadLine ($fpath)     $counter = $counter + 1     $fWrite = filewriteline ($fPath, $counter)     FileClose ($fpath) EndFunc While 1     $nMsg = GUIGetMsg()     Switch $nMsg         Case $GUI_EVENT_CLOSE             Exit         Case $One             Call ("First")     EndSwitch WEnd I tried a Do Until statement, but that just puts the numbers 1 to 5 in the file.
      Any help would be greatly appreciated!