Sign in to follow this  
Followers 0
MNT

How to use AND func

5 posts in this topic

Hi All,

I am a naive when it comes to scripting. I am trying my hands for the first time. I am not able to understand why my script stops working when I use AND in line 21?

I want the notepad to open when both C2641 (from the combo list) and OK button are selected. But its not working.

Can anyone please give me basic examples on how to use the combo list entries?

#include <GUIConstants.au3>

#include <GUIConstantsEx.au3>

local $a, $b, $msg, $comp, $sel, $val

GUICreate ("PING C264")

$a = GUICtrlCreateCombo (" ", 10,20,70,30)

$comp = GUICtrlSetData($a, "C2641|C2642|C2643|C2644|C264S1" , " ")

$b = GUICtrlCreateButton ("PING", 10,50,70,30)

$sel = GUICtrlSetState(-1, $GUI_FOCUS)

$c = GUICtrlCreateLabel ("C264-LIST", 100,25)

$d = GUICtrlCreateButton ("OK", 200,20)

GUISetState()

While 1

$msg = GUIGetMsg()

Select

Case $msg = $d And $a = "C2641"

MsgBox(0, "GUI Event", "You have selected C2641")

Run ("notepad.exe", "", @SW_MAXIMIZE)

Case $msg = $b

RunWait(@ComSpec & " /c " & 'ping 192.168.0.10', "", @SW_MAXIMIZE)

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

EndSelect

WEnd

ping.au3

Share this post


Link to post
Share on other sites



Hi All,

I am a naive when it comes to scripting. I am trying my hands for the first time. I am not able to understand why my script stops working when I use AND in line 21?

I want the notepad to open when both C2641 (from the combo list) and OK button are selected. But its not working.

Can anyone please give me basic examples on how to use the combo list entries?

#include <GUIConstants.au3>

#include <GUIConstantsEx.au3>

local $a, $b, $msg, $comp, $sel, $val

GUICreate ("PING C264")

$a = GUICtrlCreateCombo (" ", 10,20,70,30)

$comp = GUICtrlSetData($a, "C2641|C2642|C2643|C2644|C264S1" , " ")

$b = GUICtrlCreateButton ("PING", 10,50,70,30)

$sel = GUICtrlSetState(-1, $GUI_FOCUS)

$c = GUICtrlCreateLabel ("C264-LIST", 100,25)

$d = GUICtrlCreateButton ("OK", 200,20)

GUISetState()

While 1

$msg = GUIGetMsg()

Select

Case $msg = $d And $a = "C2641"

MsgBox(0, "GUI Event", "You have selected C2641")

Run ("notepad.exe", "", @SW_MAXIMIZE)

Case $msg = $b

RunWait(@ComSpec & " /c " & 'ping 192.168.0.10', "", @SW_MAXIMIZE)

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

EndSelect

WEnd

Select statements may be nested.

The expression can contain the boolean operators of AND, OR, and NOT as well as the logical operators <, <=, >, >=, =, ==, and <> grouped with parentheses as needed.

Share this post


Link to post
Share on other sites

Your data is never read. Try using GUICtrlRead($a) = "C2641" or using an If statement inside the case instead of making it multi-conditional.

Share this post


Link to post
Share on other sites

Case $msg = $d And GUICtrlRead($a) = "C2641"

Share this post


Link to post
Share on other sites

Case $msg = $d And GUICtrlRead($a) = "C2641"
Pretty sure that's what I said about an hour ago. Good practice is to wait to see if the OP understands the information.

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