31290

GuiCtrlRead issue?

4 posts in this topic

Hi there :)

I'm writing a cript that need to validate users' credentials.

One simple thing is that if "User" & "Password" fileds are empty, a msgbox pops to ask for credentials.

So far, I have:

Func f_Login()

    Global $LoginfoGUI = GUICreate("Account Info", 300, 300, -1, -1)
    GUISetIcon ($resources & "login.ico")
    GUISetFont(8.5, 700, 0)
    GUICtrlCreatePic ($resources & "\SAClogo.jpg", 30, 10, 240, 80)
    GUISetBkColor ($Color_White)
    GUICtrlCreateLabel("--- SEE UNINSTALLER ---", 85, 100, 150, 25)
    GUICtrlCreateLabel("Please provide _a account:", 10, 130, 250, 25)
    GUICtrlSetColor(-1, $COLOR_RED)
    GUICtrlCreateLabel("-Global ID:", 10, 170, 60, 30)
    GUICtrlCreateLabel("-Password:", 10, 210, 70, 30)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")
    Global $GIDTechInput = GUICtrlCreateInput("", 90, 168, 80, 20)
    Global $PassInput = GUICtrlCreateInput("", 90, 205, 150, 20, $ES_PASSWORD)
    $submitBtn = GUICtrlCreateButton ("Submit", 100, 245, 100, 25, $BS_DEFPUSHBUTTON)
    GUICtrlSetState(-1, $GUI_FOCUS)
    GUICtrlSetOnEvent(-1, "f_UninstallerMainGUI")
    GUISetState()
    If GUICtrlRead($PassInput) <> "" And Not BitAnd(GUICtrlGetState($submitBtn), $GUI_ENABLE) Then GUICtrlSetState($submitBtn, $GUI_ENABLE)
EndFunc

Func f_UninstallerMainGUI()
If (GuiCtrlRead($GIDTechInput)) OR (GUICtrlRead($PassInput)) = "" Then
MsgBox (16, "ACCESS DENIED", "Please provide credentials")
RestartScript()
Else
CODE CONTINUES
EndIf
EndFunc

But even if the fields are not empty, the msgbox pops up and the script no longer execute...

#include <GUIConstantsEx.au3> is declared.

I don't know what's happening here.

Can you please give a hand on this one?

thanks :)

 


~~~ Doom Shall Never Die, Only The Players ~~~

Share this post


Link to post
Share on other sites



31290,

Your comparison statement is wrong - you need to check the contents of both inputs separately:

If (GuiCtrlRead($GIDTechInput) = "") OR (GUICtrlRead($PassInput) = "") Then

M23

1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

If (GuiCtrlRead($GIDTechInput)) OR (GUICtrlRead($PassInput)) = "" Then

Your script evaluates the if and since it does read the input (GuiCtrlRead($GIDTechInput)) it returns true and the popup appears.

just use:

$GIDTechInput = GuiCtrlRead($GIDTechInput)
$PassInput = GuiCtrlRead($PassInput)
If $PassInput = "" OR $GIDTechInput = "" Then
...
EndIF

or

If (GuiCtrlRead($GIDTechInput)) = "" OR (GUICtrlRead($PassInput)) = "" Then

sorry, haven't noticed Melba23 answered already...

Edited by alexandruc
1 person likes this

Share this post


Link to post
Share on other sites

Thanks a lot guys for your inputs!

Now I know that I hav to separate operations for things to work!  

Cheers :)


~~~ Doom Shall Never Die, Only The Players ~~~

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