Jump to content

AND operator and work with if statement


Queener
 Share

Go to solution Solved by JLogan3o13,

Recommended Posts

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.")
Link to comment
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

 

Link to comment
Share on other sites

  • Moderators
  • Solution

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

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...