Sign in to follow this  
Followers 0
XiaolinDraconis

Controls not keeping previous settings

6 posts in this topic

Don't see why it won't keep the settings when Options() gets called, keeps reverting to unchecked radios and slider at 100 of 255. It should be reading the INI for those values each time it's called.

#NoTrayIcon
#include <Misc.au3>
#include <MsgBoxConstants.au3>
#include <TrayConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <SliderConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode.
Opt("TrayOnEventMode", 1) ; Enable TrayOnEventMode.

HotKeySet("^{SPACE}", "TapTimer")

If FileExists(".\OTPT.ini") Then
    Sleep(1000)
Else
    IniWrite("OTPT.ini", "AOT", "True", "1" & @CRLF)
    IniWrite("OTPT.ini", "Transparency", "Value", "204" & @CRLF & @CRLF & "Max Transparency Value = 255")
EndIf

$Toggle = 0
$AOT = IniRead("OTPT.ini", "AOT", "True", "1")
$Transparency = IniRead("OTPT.ini", "Transparency", "Value", "204")


TrayMenu()

Func TrayMenu()
    TrayCreateItem("Settings")
    TrayItemSetOnEvent(-1, "Options")

    TrayCreateItem("About")
    TrayItemSetOnEvent(-1, "About")

    TrayCreateItem("") ; Create a separator line.

    TrayCreateItem("Exit")
    TrayItemSetOnEvent(-1, "ExitScript")

    TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE, "Options") ; Display the About MsgBox when the tray icon is double clicked on with the primary mouse button.

    TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu.
EndFunc   ;==>TrayMenu

While 1
    Sleep(100) ; An idle loop.
WEnd

Func TapTimer()
    HotKeySet("^{SPACE}")
    $TapTime = 0
    While _IsPressed("20")
        Sleep(1000)
        $TapTime += 1
    WEnd
    If $TapTime < 3 Then
        OnTop()
        Sleep(500)
    Else
        Options()
        Sleep(500)
    EndIf
    HotKeySet("^{SPACE}", "TapTimer")
EndFunc   ;==>TapTimer

Func Options()

    $Form1 = GUICreate("Settings", 290, 142)
    $Radio1 = GUICtrlCreateRadio("", 119, 32, 17, 17)
    If $AOT = 1 Then
        GUICtrlSetData($Radio1, $GUI_CHECKED, $GUI_CHECKED)
    Else
        GUICtrlSetData($Radio1, $GUI_UNCHECKED, $GUI_UNCHECKED)
    EndIf
    $Radio2 = GUICtrlCreateRadio("", 168, 32, 17, 17)
    $Label1 = GUICtrlCreateLabel("ON", 96, 32, 20, 17)
    $Label2 = GUICtrlCreateLabel("OFF", 142, 30, 24, 17)
    $Slider = GUICtrlCreateSlider(13, 72, 255, 25)
    GUICtrlSetData(-1, $Transparency)
    GUICtrlSetLimit(-1, 255, 0)
    $Label3 = GUICtrlCreateLabel("-", 8, 72, 15, 17)
    $Label4 = GUICtrlCreateLabel("+", 269, 70, 10, 17)
    $Label5 = GUICtrlCreateLabel("Always On Top", 102, 3, 89, 17)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $Label6 = GUICtrlCreateLabel("Transparency", 106, 56, 81, 17)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $OK = GUICtrlCreateButton("OK", 128, 104, 33, 33)
    GUISetState(@SW_SHOW)
    WinSetOnTop("Settings", "", 1)

    While 1
        WinActivate("Settings")
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                GUISetState(@SW_HIDE)
                ExitLoop
            Case $OK
                While GUICtrlRead($Radio1) = $GUI_UNCHECKED And GUICtrlRead($Radio2) = $GUI_UNCHECKED
                    Sleep(100)
                    ToolTip("Please Select ON/OFF State")
                    WinActivate("Settings")
                WEnd
                If GUICtrlGetState($Radio1) = $GUI_CHECKED Then
                    $AOT = 1
                    $Transparency = GUICtrlRead($Slider)
                Else
                    $AOT = 0
                    $Transparency = GUICtrlRead($Slider)
                EndIf
                IniWrite("OTPT.ini", "AOT", "True", $AOT)
                IniWrite("OTPT.ini", "Transparency", "Value", $Transparency)
                ToolTip("")
                GUISetState(@SW_HIDE)
                ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>Options

Func About()
    MsgBox($MB_OK, "About", "OnTopPeekThrough" & @CRLF & @CRLF & _
            "Press CTRL+SPACE to toggle" & @CRLF & _
            "Or hold 3 seconds for Options" & @CRLF & @CRLF & _
            "By: XiaolinDraconis")
EndFunc   ;==>About

Func OnTop()
    If $Toggle = 0 Then
        $Toggle = 1
        Set()
    Else
        $Toggle = 0
        Unset()
    EndIf
EndFunc   ;==>OnTop

Func Set()
    $WinTitle = WinGetTitle("[active]")
    WinSetOnTop($WinTitle, "", 1)
    WinSetTrans($WinTitle, "", $Transparency)
EndFunc   ;==>Set

Func Unset()
    $WinTitle = WinGetTitle("[active]")
    WinSetOnTop($WinTitle, "", 0)
    WinSetTrans($WinTitle, "", 255)
EndFunc   ;==>Unset

Func ExitScript()
    Exit
EndFunc   ;==>ExitScript

Share this post


Link to post
Share on other sites



Managed to fix the slider. Now working on radio buttons.

Share this post


Link to post
Share on other sites

apparently i didnt entirely fix it.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

apparently i didnt entirely fix it.

Try: 

If $AOT = 1 Then
        GUICtrlSetState($Radio1, $GUI_CHECKED)
    Else
        GUICtrlSetState($Radio1, $GUI_UNCHECKED)
    EndIf

Edit: A more elegant way to handle having a Tray menu and a GUI would be to have a single While loop where you listen for messages from Tray and from the GUI and handle it that way:

P.S. I fixed the issues you were having with the ini not updating and also added a label to the Transparency slider to show the selected number.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <SliderConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>

Opt("TrayMenuMode", 3)
HotKeySet("^{SPACE}", "TapTimer")

Global $inifile = @ScriptDir & "\OTPT.ini", $transparency = 204, $AOT = 1, $Toggle = 0

If FileExists($inifile) Then
    $AOT = IniRead($inifile, "AOT", "True", "1")
    $transparency = IniRead($inifile, "Transparency", "Value", "204")
Else
    IniWrite($inifile, "AOT", "True", $AOT & @CRLF)
    IniWrite($inifile, "Transparency", "Value", $transparency & @CRLF & @CRLF & "Max Transparency Value = 255")
EndIf

#Region ### START $optionsGUI ###
$optionsGUI = GUICreate("Options", 365, 200, @DesktopWidth/2 - 365/2, @DesktopHeight/2 - 200/2)
$RadioON = GUICtrlCreateRadio("ON", 128, 40, 49, 17)
If $AOT = 1 Then GUICtrlSetState(-1, $GUI_CHECKED)
$RadioOFF = GUICtrlCreateRadio("OFF", 184, 40, 49, 17)
If $AOT = 0 Then GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlCreateLabel("Always on top:", 116, 8, 120, 24)
GUICtrlSetFont(-1, 12, 800, 0)
GUICtrlCreateLabel("Transparency:", 96, 74, 117, 24)
GUICtrlSetFont(-1, 12, 800, 0)
$tlabel = GUICtrlCreateLabel($transparency, 216, 74, 117, 24)
GUICtrlSetFont(-1, 12, 800, 0)
$tSlider = GUICtrlCreateSlider(24, 112, 318, 45)
GUICtrlSetLimit(-1, 255, 0)
GUICtrlSetData(-1, $transparency)
$optionsBtn_okay = GUICtrlCreateButton("OK", 136, 160, 75, 25)
#EndRegion ### END $optionsGUI ###

$options = TrayCreateItem("Settings")
$about = TrayCreateItem("About")
TrayCreateItem("") ; Create a separator line.
$exit = TrayCreateItem("Exit")

While 1

    Local $tMsg = TrayGetMsg()
    Switch $tMsg
        Case $options
            GUISetState(@SW_SHOW, $optionsGUI)
        Case $about
            MsgBox(0, "About", "OnTopPeekThrough" & @CRLF & @CRLF & _
                    "Press CTRL+SPACE to toggle" & @CRLF & _
                    "Or hold 3 seconds for Options" & @CRLF &  @CRLF & _
                    "By: XiaolinDraconis")
        Case $exit
            Exit
    EndSwitch

    Local $gMsg = GUIGetMsg()
    Switch $gMsg
        Case $optionsBtn_okay
            If GUICtrlRead($RadioON) = $GUI_CHECKED Then
                IniWrite($inifile, "AOT", "True", 1)
            ElseIf GUICtrlRead($RadioOFF) = $GUI_CHECKED Then
                IniWrite($inifile, "AOT", "True", 0)
            EndIf
            IniWrite($inifile, "Transparency", "Value", GUICtrlRead($tlabel))
            GUISetState(@SW_HIDE, $optionsGUI)
        Case $tSlider
            $val = GUICtrlRead($tSlider)
            GUICtrlSetData($tlabel, $val)
        Case $GUI_EVENT_CLOSE
            GUISetState(@SW_HIDE, $optionsGUI)
    EndSwitch

WEnd

Func TapTimer()
    HotKeySet("^{SPACE}")
    $TapTime = 0
    While _IsPressed("20")
        Sleep(1000)
        $TapTime += 1
    WEnd
    If $TapTime < 3 Then
        OnTop()
    Else
        GUISetState(@SW_SHOW, $optionsGUI)
    EndIf
    HotKeySet("^{SPACE}", "TapTimer")
EndFunc   ;==>TapTimer

Func OnTop()
    If $Toggle = 0 Then
        $Toggle = 1
        Set()
    Else
        $Toggle = 0
        Unset()
    EndIf
EndFunc   ;==>OnTop

Func Set()
    $WinTitle = WinGetTitle("[active]")
    WinSetOnTop($WinTitle, "", 1)
    WinSetTrans($WinTitle, "", $Transparency)
EndFunc   ;==>Set

Func Unset()
    $WinTitle = WinGetTitle("[active]")
    WinSetOnTop($WinTitle, "", 0)
    WinSetTrans($WinTitle, "", 255)
EndFunc   ;==>Unset

I'll be honest I am not 100% sure with HotKeys and the way you have gone about handling the way the Hot Keys work to set window transparency etc, but it seems to work, albeit somewhat choppy.

Edited by mpower

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Try: 

If $AOT = 1 Then
        GUICtrlSetState($Radio1, $GUI_CHECKED)
    Else
        GUICtrlSetState($Radio1, $GUI_UNCHECKED)
    EndIf

Edit: A more elegant way to handle having a Tray menu and a GUI would be to have a single While loop where you listen for messages from Tray and from the GUI and handle it that way:

P.S. I fixed the issues you were having with the ini not updating and also added a label to the Transparency slider to show the selected number.

I'll be honest I am not 100% sure with HotKeys and the way you have gone about handling the way the Hot Keys work to set window transparency etc, but it seems to work, albeit somewhat choppy.

 

Very nice, thank you. I know the Hotkey thing is sloppy, but I didn't see another way to go about having the delay for opening the options. Think I'll turn that into a double tap instead of holding it. 

The double tap method I'm gonna use is still choppy, but also I need to work out some more issues. It doesn't seem to be saving the transparency setting properly, also it is applying the transparency setting to the Settings GUI. Pretty sure some of that if not all is coming from the way I setup the Hotkey.

I'll work it out, then post what I did when I'm done.

Edited by XiaolinDraconis

Share this post


Link to post
Share on other sites

Ok so the transparency issue was due to a mix up in the variables, and the hotkey method I chose was with If Then statements and that just didn't work well so I went with a Switch Case.

And TADA! Thanks again, oh and if you notice the hotkey has a variable now, that's for future adjustments, going to make it so the key can be changed.

Near Perfection

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <SliderConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>

Opt("TrayMenuMode", 3)

Global $inifile = @ScriptDir & "\OTPT.ini", $val = IniRead($inifile,"Transparency","Value","204"), $transparency = 204, $AOT = 1, $Toggle = 0, $TapCount = 0, $Hotkey = "^{SPACE}"

HotKeySet($Hotkey, "TapTimer")

If FileExists($inifile) Then
    $AOT = IniRead($inifile, "AOT", "True", "1")
    $transparency = IniRead($inifile, "Transparency", "Value", "204")
Else
    IniWrite($inifile, "AOT", "True", $AOT & @CRLF)
    IniWrite($inifile, "Transparency", "Value", $transparency & @CRLF & @CRLF & "Max Transparency Value = 255")
EndIf

$optionsGUI = GUICreate("Options", 365, 200, @DesktopWidth / 2 - 365 / 2, @DesktopHeight / 2 - 200 / 2)
$RadioON = GUICtrlCreateRadio("ON", 128, 40, 49, 17)
If $AOT = 1 Then GUICtrlSetState(-1, $GUI_CHECKED)
$RadioOFF = GUICtrlCreateRadio("OFF", 184, 40, 49, 17)
If $AOT = 0 Then GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlCreateLabel("Always on top:", 116, 8, 120, 24)
GUICtrlSetFont(-1, 12, 800, 0)
GUICtrlCreateLabel("Transparency:", 96, 74, 117, 24)
GUICtrlSetFont(-1, 12, 800, 0)
$tlabel = GUICtrlCreateLabel($transparency, 216, 74, 117, 24)
GUICtrlSetFont(-1, 12, 800, 0)
$tSlider = GUICtrlCreateSlider(24, 112, 318, 45)
GUICtrlSetLimit(-1, 255, 0)
GUICtrlSetData(-1, $transparency)
$optionsBtn_okay = GUICtrlCreateButton("OK", 136, 160, 75, 25)

$options = TrayCreateItem("Settings")
$about = TrayCreateItem("About")
TrayCreateItem("") ; Create a separator line.
$exit = TrayCreateItem("Exit")

While 1
    Local $tMsg = TrayGetMsg()
    Switch $tMsg
        Case $options
            GUISetState(@SW_SHOW, $optionsGUI)
        Case $about
            MsgBox(0, "About", "OnTopPeekThrough" & @CRLF & @CRLF & _
                    "Press" & $Hotkey & "to toggle" & @CRLF & _
                    "Or double tap for Options" & @CRLF & @CRLF & _
                    "By: AutoIt V3")
        Case $exit
            Exit
    EndSwitch

    Local $gMsg = GUIGetMsg()
    Switch $gMsg
        Case $optionsBtn_okay
            If GUICtrlRead($RadioON) = $GUI_CHECKED Then
                IniWrite($inifile, "AOT", "True", 1)
            ElseIf GUICtrlRead($RadioOFF) = $GUI_CHECKED Then
                IniWrite($inifile, "AOT", "True", 0)
            EndIf
            IniWrite($inifile, "Transparency", "Value", GUICtrlRead($tlabel))
            GUISetState(@SW_HIDE, $optionsGUI)
        Case $tSlider
            $val = GUICtrlRead($tSlider)
            GUICtrlSetData($tlabel, $val)
            WinSetTrans($optionsGUI,"",$val)
            Sleep(666)
            WinSetTrans($optionsGUI,"",255)
        Case $GUI_EVENT_CLOSE
            GUISetState(@SW_HIDE, $optionsGUI)
    EndSwitch
WEnd

Func TapTimer()
    $TapCount += 1
    Sleep(500)
    Switch $TapCount
    Case 2
        GUISetState(@SW_SHOW, $optionsGUI)
        WinSetOnTop($optionsGUI, "", 1)
        WinSetTrans($optionsGUI, "", 255)
        $TapCount = 0
    Case 1
        OnTop()
        $TapCount = 0
    Case Else
        GUISetState(@SW_SHOW, $optionsGUI)
        WinSetOnTop($optionsGUI, "", 1)
        WinSetTrans($optionsGUI, "", 255)
        $TapCount = 0
    EndSwitch
EndFunc   ;==>TapTimer

Func OnTop()
    If $Toggle = 0 Then
        $Toggle = 1
        Set()
    Else
        $Toggle = 0
        Unset()
    EndIf
EndFunc   ;==>OnTop

Func Set()
    $WinTitle = WinGetTitle("[active]")
    WinSetOnTop($WinTitle, "", 1)
    WinSetTrans($WinTitle, "", $val)
EndFunc   ;==>Set

Func Unset()
    $WinTitle = WinGetTitle("[active]")
    WinSetOnTop($WinTitle, "", 0)
    WinSetTrans($WinTitle, "", 255)
EndFunc   ;==>Unset

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
Sign in to follow this  
Followers 0

  • 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!