Edits not enable via checkbox Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Liaxim
Posts: 35
Joined: 09 Jan 2020, 05:14

Edits not enable via checkbox

09 Apr 2020, 20:19

Hey guys, I save a checkbox in the ini and enable or disable the two edit boxes which are controlled by the Checkbox..
So I wanted that if the Checkbox is checked, that the Edit boxes are visible and writeable.. but my problem is that the Checkbox will be enabled but the edit boxes won´t after I saved and restart...
Hope someone can help me..

Code: Select all

Gui, EmailServices: Default

IniRead,WebCheckBox,Settings.ini, Email, WebCheckBox ; Reads what the Checkbox is (1 or 0)
Gui, Add, CheckBox, x10 y9 w70 h30 vWebCheckBox checked%WebCheckBox% gWebCheckBox, Webmail ; The Checkbox which should enable or disable the edits...
Gui, Add, Edit, x82 y13 w100 h20 disabled vWebEmail, Email
Gui, Add, Edit, x192 y13 w100 h20 disabled vWebPassword, Password
Gui, Add, Button, x300 y13 w35 h20 gWebsave, Save ; save the Edits..

Gui, Show, NA x5 y5 w750 h345
return

;Label to activate or deactivate the Edits...
WebCheckBox:
guicontrolget, WebCheckBox
if WebCheckBox = 1
{
IniWrite, %WebCheckBox%, Settings.ini, Settings, WebCheckBox
IniRead, tempWebEmail, Settings.ini, Email, tempWebEmail
IniRead, tempWebPassword, Settings.ini, Email, tempWebPassword
WebEmail := b64Decode(tempWebEmail)
WebPassword := b64Decode(tempWebPassword)
guicontrol, Enable, WebEmail
guicontrol, ,  WebEmail
guicontrol, ,  WebEmail, %WebEmail%
guicontrol, Enable,  WebPassword
guicontrol, +Password,  WebPassword
guicontrol, ,  WebPassword, %WebPassword%
}
else
{
IniWrite, %WebCheckBox%, Settings.ini, Settings, WebCheckBox
guicontrol, -Password,  WebEmail
guicontrol, Disable,  WebEmail
guicontrol, ,  WebEmail, Email
guicontrol, -Password,  WebPassword
guicontrol, Disable,  WebPassword
guicontrol, ,  WebPassword, Password
}
return
; Saves the Edits...
Websave:
Gui, Submit,NoHide
tempWebEmail := b64Encode(WebEmail)
tempWebPassword := b64Encode(WebPassword)
IniWrite, %tempWebEmail%, Settings.ini, Email, tempWebEmail
IniWrite, %tempWebPassword%, Settings.ini, Email, tempWebPassword
IniRead, tempWebEmail, Settings.ini, Email, tempWebEmail
IniRead, tempWebPassword, Settings.ini, Email, tempWebPassword
Return

;Encrypt the Edit data...
b64Encode(string)
{
    VarSetCapacity(bin, StrPut(string, "UTF-8")) && len := StrPut(string, &bin, "UTF-8") - 1 
    if !(DllCall("crypt32\CryptBinaryToString", "ptr", &bin, "uint", len, "uint", 0x1, "ptr", 0, "uint*", size))
        throw Exception("CryptBinaryToString failed", -1)
    VarSetCapacity(buf, size << 1, 0)
    if !(DllCall("crypt32\CryptBinaryToString", "ptr", &bin, "uint", len, "uint", 0x1, "ptr", &buf, "uint*", size))
        throw Exception("CryptBinaryToString failed", -1)
    return StrGet(&buf)
}

;Decrypt the Edit data...
b64Decode(string)
{
    if !(DllCall("crypt32\CryptStringToBinary", "ptr", &string, "uint", 0, "uint", 0x1, "ptr", 0, "uint*", size, "ptr", 0, "ptr", 0))
        throw Exception("CryptStringToBinary failed", -1)
    VarSetCapacity(buf, size, 0)
    if !(DllCall("crypt32\CryptStringToBinary", "ptr", &string, "uint", 0, "uint", 0x1, "ptr", &buf, "uint*", size, "ptr", 0, "ptr", 0))
        throw Exception("CryptStringToBinary failed", -1)
    return StrGet(&buf, size, "UTF-8")
}
just me
Posts: 9574
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Edits not enable via checkbox  Topic is solved

10 Apr 2020, 05:36

Code: Select all

IniRead,WebCheckBox,Settings.ini, Email, WebCheckBox ; Reads what the Checkbox is (1 or 0)
EditDisabled := !WebCheckBox
Gui, Add, CheckBox, x10 y9 w70 h30 vWebCheckBox checked%WebCheckBox% gWebCheckBox, Webmail ; The Checkbox which should enable or disable the edits...
Gui, Add, Edit, x82 y13 w100 h20 Disabled%EditDisabled% vWebEmail, Email
Gui, Add, Edit, x192 y13 w100 h20 Disabled%EditDisabled% vWebPassword, Password
Gui, Add, Button, x300 y13 w35 h20 gWebsave, Save ; save the Edits..
...
?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], peter_ahk and 396 guests