Sign in to follow this  
Followers 0
stealth

Send GUICtrlRead results =>1 with Case Select / If Then Else / If(Or(And...))

5 posts in this topic

#1 ·  Posted (edited)

Hello. I would like to send the results of GUICtrlRead with Case Select / If Then Else / If(Or(And...)) / other way to Notepad.

I want to Send only the results greater than 1.

If user skips an input, then the Message box should show all totals, i.e., **0 ANTELOPE/0 DEER/1 FISH/**

My code will send **0 ANTELOPE/0 DEER/1 FISH/**, but I want to only send **1 FISH/**

The only correct iteration sent is if all 3 are greater than 1.

I looked in help File, on the forums, and on the AutoIt wiki, but I can't figure out the appropriate iteration for the desired results.

(I want to keep the "/" out of view in the GUICreateInputs.)

#include <GUIConstantsEx.au3>
HowManyAnimals()

Func HowManyAnimals()
#include <EditConstants.au3.>
Dim $a1, $d1, $f1, $btn, $msg, $a2, $d2, $f2

GUICreate("Input Animal Count", 280, 120, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1, 0x00000018)
$a1 = GUICtrlCreateInput("",75, 5, 30, 20,$ES_NUMBER)
$a2 = GUICtrlCreateInput(" ANTELOPE/",150,5,65,20,$ES_READONLY)

$d1 = GUICtrlCreateInput("",75, 35, 30, 20,$ES_NUMBER)
$d2 = GUICtrlCreateInput(" DEER/",150,37,38,20,$ES_READONLY)

$f1 = GUICtrlCreateInput("",75, 65, 30, 20,$ES_NUMBER)
$f2 = GUICtrlCreateInput(" FISH/",150,67,33,20,$ES_READONLY)

$btn = GUICtrlCreateButton("OK", 100, 95, 60, 20)

GUISetState()

$msg = 0
While $msg <> $GUI_EVENT_CLOSE
$msg = GUIGetMsg()
Select
Case $msg = $btn
ExitLoop
EndSelect
WEnd
MsgBox(4096, "There are...", "**"&Int(GUICtrlRead($a1))&GUICtrlRead($a2)&Int(GUICtrlRead($d1))&GUICtrlRead($d2)&Int(GUICtrlRead($f1))&GUICtrlRead($f2)&"**")

Select
Case $msg = $btn
If $a1<>0 And $d1<>0 And $f1<>0 Then
WinActivate("AnimalNumber")
Send("**"& GUICtrlRead($a1)&GUICtrlRead($a2)&GUICtrlRead($d1)&GUICtrlRead($d2)&GUICtrlRead($f1)&GUICtrlRead($f2)&"**")
ElseIf $d1="0" And $f1="0" Then
WinActivate("AnimalNumber")
Send("**"&GUICtrlRead($1)&GUICtrlRead($a2)&"**")
ElseIf $a1="" And $f1=""
WinActivate("AnimalNumber")
Send("**"&GUICtrlRead($d1)&GUICtrlRead($d2)&"**")
ElseIf $a1="" And $d1=""
WinActivate("AnimalNumber")
Send("**"&GUICtrlRead($f1)&GUICtrlRead($f2)&"**")
ElseIf $f1=""
WinActivate("AnimalNumber")
Send("**"&GUICtrlRead($a1)&GUICtrlRead($a2)&GUICtrlRead($d1)&" "&GUICtrlRead($d2)&"**")
ElseIf $d1=""
WinActivate("AnimalNumber")
Send("**"&GUICtrlRead($a1)&GUICtrlRead($a2)&GUICtrlRead($f1)&" "&GUICtrlRead($f2)& "**")
ElseIf $a1=""
WinActivate("AnimalNumber")
Send("**"&GUICtrlRead($d1)&GUICtrlRead($d2)&GUICtrlRead($f1)&" "&GUICtrlRead($f2)&"**")
EndIf
EndSelect
EndFunc ;==>AnimalNumber


;possible outcomes
;**x ANTELOPE/x DEER/x FISH**
;**x DEER/x FISH**
;**x ANTELOPE/x FISH**
;**x ANTELOPE/x DEER**
;using uncountable nouns, so I don't care about '1 deers' [sic] '2 deer' etc.
;Notepad Titled AnimalNumber must be open prior to running script

If someone could point me in the right direction, I'd appreciate it very much. Thank you in advance.

Edited by Jos

Share this post


Link to post
Share on other sites



sorry double post please disregard

Share this post


Link to post
Share on other sites

Edit: I want to Send only the results greater than 1. =>1.

Share this post


Link to post
Share on other sites

Answering my own question here after thinking about it...make another variable $a3 to concatenate $a1 and $a2 If $a1 is greater than 0 (duh).

#include <GUIConstantsEx.au3>
HowManyAnimals()

Func HowManyAnimals()
#include <EditConstants.au3.>
Dim $a1, $d1, $f1, $btn, $msg, $a2, $d2, $f2, $a3, $d3, $f3

GUICreate("Input Animal Count", 280, 120, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1, 0x00000018)
$a1 = GUICtrlCreateInput("",75, 5, 30, 20,$ES_NUMBER)
$a2 = GUICtrlCreateInput(" ANTELOPE/",150,5,65,20,$ES_READONLY)

$d1 = GUICtrlCreateInput("",75, 35, 30, 20,$ES_NUMBER)
$d2 = GUICtrlCreateInput(" DEER/",150,37,38,20,$ES_READONLY)

$f1 = GUICtrlCreateInput("",75, 65, 30, 20,$ES_NUMBER)
$f2 = GUICtrlCreateInput(" FISH/",150,67,33,20,$ES_READONLY)

$btn = GUICtrlCreateButton("OK", 100, 95, 60, 20)

GUISetState()

$msg = 0
While $msg <> $GUI_EVENT_CLOSE
$msg = GUIGetMsg()
Select
Case $msg = $btn
ExitLoop
EndSelect
WEnd

If Int(GUICtrlRead($a1)) > 0 Then
$a3 = GUICtrlRead($a1)&GUICtrlRead($a2)
Else
$a3 = ""
EndIf
If Int(GUICtrlRead($d1)) > 0 Then
$d3 = GUICtrlRead($d1)&GUICtrlRead($d2)
Else
$d3 = ""
EndIf
If Int(GUICtrlRead($f1)) > 0 Then
$f3 = GUICtrlRead($f1)&GUICtrlRead($f2)
Else
$f3 = ""
EndIf

MsgBox(4096, "There are...","**"&$a3&$d3&$f3&"**")

Select
Case $msg = $btn
     WinActivate("AnimalNumber")
     Send("**"&$a3&$d3&$f3&"**")
EndSelect
EndFunc ;==>AnimalNumber


;possible outcomes
;**x ANTELOPE/x DEER/x FISH**
;**x DEER/x FISH**
;**x ANTELOPE/x FISH**
;**x ANTELOPE/x DEER**
;using uncountable nouns, so I don't care about '1 deers' [sic] '2 deer' etc.
;Notepad Titled AnimalNumber must be open prior to running script

Is there a more elegant way to script the same code as above?

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