Sign in to follow this  
Followers 0
Queener

AND operator and work with if statement

4 posts in this topic

I'm not getting what I wanted... I'm not sure if I used the And operator correctly as well. If you have other suggestion rather than using the AND operator; let me know. Here, no matter how I format, it will always run the code:

ShellExecute($TV, "-i " & $keys & " --Password 9999")

 

I tried to swapping the code:

ShellExecute($TV, "-i " & $keys & " --Password " & GUICtrlRead($pwdinput))
 
to
 
ShellExecute($TV, "-i " & $keys & " --Password 9999")

 

it still execute the code with Password 9999.

Here's how I use my IF and AND statement together.

if GUICtrlRead($pwdinput) <> "" And GUICtrlRead($pwdinput) <> $pwlableled And GUICtrlRead($namelist) = $bArray[1] then
    ShellExecute($TV, "-i " & $keys & " --Password " & GUICtrlRead($pwdinput))
Else
    ShellExecute($TV, "-i " & $keys & " --Password 9999")
EndIf

 


Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.")

Share this post


Link to post
Share on other sites



You'll need to post a reproducer script, as we can't test what you have created to understand what is potentially going wrong.

Usually this will help you figure out what is going wrong as well. ;)


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

As MikahS pointed out, it is a bit irritating having to first guess at what you're doing, and then troubleshoot the problem. Workable, running code is always best. Try something like this and see if it works for you:

If $pwdinput is blank, fails. If $pwdinput does not equal $pwlabeled, fails.

If $pwdinput is not blank, and equals $pwlabeled, then if $namelist equals $bArray[1], succeeds.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

GUICreate("Test", 300, 300)
$pwdinput = GUICtrlCreateInput("", 10, 10, 280, 40)
$namelist = GUICtrlCreateInput("", 10, 60, 280, 40)
$button = GUICtrlCreateButton("Go", 10, 120, 40, 40)
$pwlabeled = 1
Local $bArray[2] = ["Sue","Henry"]

GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $button
                If GUICtrlRead($pwdinput) <> "" And GUICtrlRead($pwdinput) <> $pwlabeled Then
                    If GUICtrlRead($namelist) = $bArray[1] Then MsgBox(0, "", "Worked")
                Else
                    MsgBox(0, "", "Failed")
                EndIf
        EndSwitch
    WEnd

GUIDelete()
Edited by JLogan3o13
1 person likes this

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

that worked... Thanks!


Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.")

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