Jump to content

logic operators


 Share

Recommended Posts

so i was wondering if any could tell me the logic operators used in autoit.

some scripts use <=, >=, !=, ==, &, |

for less than or equal to, greater than or equal to, not equal to, equal to, AND, OR, respectively

are these the same in autoit, they dont seem to work correctly for me if so.

also if i create a picture after the button has been pushed, when i bring up another picture after a different button is pushed then my first picture flashes for a moment. how can i clear the first picture from the GUI console?

<><><><><

SCRIPT

<><><><><

#include <GuiConstants.au3>

GuiCreate("Pictures", 500, 550) ;Titles my GUIconsole "Pictures"

$button1=GuiCtrlCreateButton("Pic1!", 10 , 10 , 100 , 30) ;Creates my 8 buttons, for the 8 different pictures i have in my 3 sets

$button2=GuiCtrlCreateButton("Pic2!", 10 , 60, 100 , 30)

$button3=GuiCtrlCreateButton("Pic3!", 10 , 110 , 100 , 30)

$button4=GuiCtrlCreateButton("Pic4!", 10 , 160 , 100 , 30)

$button5=GuiCtrlCreateButton("Pic5!", 10 , 210 , 100 , 30)

$button6=GuiCtrlCreateButton("Pic6!", 10 , 260 , 100 , 30)

$button7=GuiCtrlCreateButton("Pic7!", 10 , 310 , 100 , 30)

$button8=GuiCtrlCreateButton("Pic8!", 10 , 360 , 100 , 30)

GuiSetState()

GUICtrlCreatePic("Directions.jpg", 120, 10, 370, 480) ;Brings up a picture with the instructions on it

$set1=GUICtrlCreateButton("A", 130, 510, 100, 30) ;Creates my buttons to determine what set i want to view, A, B, or C

$set2=GUICtrlCreateButton("B", 240, 510, 100, 30)

$set3=GUICtrlCreateButton("C", 350, 510, 100, 30)

$set=1

While 1

$msg = GUIGetMsg()

If $msg = $set1 Then ;Determines what set button has been clicked, then sets $set to that

$set=1

ElseIf $msg = $set2 Then

$set=2

ElseIf $msg = $set3 Then

$set=3

EndIf

$msg = GUIGetMsg()

If $msg = $button1 Then ;Determines what picture of the predetermined set the user wants to view

If $set=1 Then ;If the set button "A" was chosen it displays the first picture in that set

GUICtrlCreatePic("A1.jpg", 120 , 10 , 370 , 480)

ElseIf $set=2 Then

GUICtrlCreatePic("B1.jpg", 120, 10 , 370 , 480)

ElseIf $set=3 Then

GUICtrlCreatePic("C1.jpg", 120, 10, 370, 480)

EndIf

ElseIf $msg = $button2

If $set=1 Then

GUICtrlCreatePic("A2.jpg", 120 , 10 , 370 , 480)

ElseIf $set=2 Then

GUICtrlCreatePic("B2.jpg", 120, 10 , 370 , 480)

ElseIf $set=3 Then

GUICtrlCreatePic("C2.jpg", 120, 10, 370, 480)

EndIf

ElseIf $msg = $button3

If $set=1 Then

GUICtrlCreatePic("A3.jpg", 120 , 10 , 370 , 480)

ElseIf $set=2 Then

GUICtrlCreatePic("B3.jpg", 120, 10 , 370 , 480)

ElseIf $set=3 Then

GUICtrlCreatePic("C3.jpg", 120, 10, 370, 480)

EndIf

ElseIf $msg = $button4

If $set=1 Then

GUICtrlCreatePic("A4.jpg", 120 , 10 , 370 , 480)

ElseIf $set=2 Then

GUICtrlCreatePic("B4.jpg", 120, 10 , 370 , 480)

ElseIf $set=3 Then

GUICtrlCreatePic("C4.jpg", 120, 10, 370, 480)

EndIf

ElseIf $msg = $button5

If $set=1 Then

GUICtrlCreatePic("A5.jpg", 120 , 10 , 370 , 480)

ElseIf $set=2 Then

GUICtrlCreatePic("B5.jpg", 120, 10 , 370 , 480)

ElseIf $set=3 Then

GUICtrlCreatePic("C5.jpg", 120, 10, 370, 480)

EndIf

ElseIf $msg = $button6

If $set=1 Then

GUICtrlCreatePic("A6.jpg", 120 , 10 , 370 , 480)

ElseIf $set=2 Then

GUICtrlCreatePic("B6.jpg", 120, 10 , 370 , 480)

ElseIf $set=3 Then

GUICtrlCreatePic("C6.jpg", 120, 10, 370, 480)

EndIf

ElseIf $msg = $button7

If $set=1 Then

GUICtrlCreatePic("A7.jpg", 120 , 10 , 370 , 480)

ElseIf $set=2 Then

GUICtrlCreatePic("B7.jpg", 120, 10 , 370 , 480)

ElseIf $set=3 Then

GUICtrlCreatePic("C7.jpg", 120, 10, 370, 480)

EndIf

ElseIf $msg = $button8

If $set=1 Then

GUICtrlCreatePic("A8.jpg", 120 , 10 , 370 , 480)

ElseIf $set=2 Then

GUICtrlCreatePic("B8.jpg", 120, 10 , 370 , 480)

ElseIf $set=3 Then

GUICtrlCreatePic("C8.jpg", 120, 10, 370, 480)

EndIf

ElseIf $msg = $GUI_EVENT_CLOSE Then

Exitloop ;Not sure what this does but it seems to work, aqcuired from a script given from the help forums

EndIf

Wend

Exit

Edited by harrisms
Link to comment
Share on other sites

so i was wondering if any could tell me the logic operators used in autoit.

some scripts use <=, >=, !=, ==, &, |

for less than or equal to, greater than or equal to, not equal to, equal to, AND, OR, respectively

are these the same in autoit, they dont seem to work correctly for me if so.

Operators

The single "=" sign can mean both comparison AND assignment, though most use the double "==" for comparison and the single "=" for assignment.

Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

also if i create a picture after the button has been pushed, when i bring up another picture after a different button is pushed then my first picture flashes for a moment. how can i clear the first picture from the GUI console?

You'll generally find that you need to post the code you're having trouble with in order for people on the forum to be able to help you out.

No Code=No Help

Edited by PaulIA
Auto3Lib: A library of over 1200 functions for AutoIt
Link to comment
Share on other sites

  • Moderators

He did Post the code. He just didn't use [auto it] along with the [/autoit]

space added to [autoit] to show code

He posted his code 2 minutes after PaulIA mentioned it.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Operators

The single "=" sign can mean both comparison AND assignment, though most use the double "==" for comparison and the single "=" for assignment.

Hi,

I'd like to add that == and = have different afects because of case sensitive when camparing strings!

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

#include <GuiConstants.au3>

GuiCreate("Pictures", 500, 550) ;Titles my GUIconsole "Pictures"

$button1=GuiCtrlCreateButton("Pic1!", 10 , 10 , 100 , 30) ;Creates my 8 buttons, for the 8 different pictures i have in my 3 sets
$button2=GuiCtrlCreateButton("Pic2!", 10 , 60, 100 , 30)
$button3=GuiCtrlCreateButton("Pic3!", 10 , 110 , 100 , 30)
$button4=GuiCtrlCreateButton("Pic4!", 10 , 160 , 100 , 30)
$button5=GuiCtrlCreateButton("Pic5!", 10 , 210 , 100 , 30)
$button6=GuiCtrlCreateButton("Pic6!", 10 , 260 , 100 , 30)
$button7=GuiCtrlCreateButton("Pic7!", 10 , 310 , 100 , 30)
$button8=GuiCtrlCreateButton("Pic8!", 10 , 360 , 100 , 30)

GuiSetState()

GUICtrlCreatePic("Directions.jpg", 120, 10, 370, 480) ;Brings up a picture with the instructions on it

$set1=GUICtrlCreateButton("A", 130, 510, 100, 30) ;Creates my buttons to determine what set i want to view, A, B, or C
$set2=GUICtrlCreateButton("B", 240, 510, 100, 30)
$set3=GUICtrlCreateButton("C", 350, 510, 100, 30)
$set=1

While 1

$msg = GUIGetMsg()

If $msg = $set1 Then ;Determines what set button has been clicked, then sets $set to that
$set=1
ElseIf $msg = $set2 Then
$set=2
ElseIf $msg = $set3 Then
$set=3
EndIf

$msg = GUIGetMsg()

If $msg = $button1 Then ;Determines what picture of the predetermined set the user wants to view
If $set=1 Then ;If the set button "A" was chosen it displays the first picture in that set
GUICtrlCreatePic("A1.jpg", 120 , 10 , 370 , 480)
ElseIf $set=2 Then
GUICtrlCreatePic("B1.jpg", 120, 10 , 370 , 480)
ElseIf $set=3 Then
GUICtrlCreatePic("C1.jpg", 120, 10, 370, 480)
EndIf

ElseIf $msg = $button2
If $set=1 Then
GUICtrlCreatePic("A2.jpg", 120 , 10 , 370 , 480)
ElseIf $set=2 Then
GUICtrlCreatePic("B2.jpg", 120, 10 , 370 , 480)
ElseIf $set=3 Then
GUICtrlCreatePic("C2.jpg", 120, 10, 370, 480)
EndIf

ElseIf $msg = $button3
If $set=1 Then
GUICtrlCreatePic("A3.jpg", 120 , 10 , 370 , 480)
ElseIf $set=2 Then
GUICtrlCreatePic("B3.jpg", 120, 10 , 370 , 480)
ElseIf $set=3 Then
GUICtrlCreatePic("C3.jpg", 120, 10, 370, 480)
EndIf

ElseIf $msg = $button4
If $set=1 Then
GUICtrlCreatePic("A4.jpg", 120 , 10 , 370 , 480)
ElseIf $set=2 Then
GUICtrlCreatePic("B4.jpg", 120, 10 , 370 , 480)
ElseIf $set=3 Then
GUICtrlCreatePic("C4.jpg", 120, 10, 370, 480)
EndIf

ElseIf $msg = $button5
If $set=1 Then
GUICtrlCreatePic("A5.jpg", 120 , 10 , 370 , 480)
ElseIf $set=2 Then
GUICtrlCreatePic("B5.jpg", 120, 10 , 370 , 480)
ElseIf $set=3 Then
GUICtrlCreatePic("C5.jpg", 120, 10, 370, 480)
EndIf

ElseIf $msg = $button6
If $set=1 Then
GUICtrlCreatePic("A6.jpg", 120 , 10 , 370 , 480)
ElseIf $set=2 Then
GUICtrlCreatePic("B6.jpg", 120, 10 , 370 , 480)
ElseIf $set=3 Then
GUICtrlCreatePic("C6.jpg", 120, 10, 370, 480)
EndIf

ElseIf $msg = $button7
If $set=1 Then
GUICtrlCreatePic("A7.jpg", 120 , 10 , 370 , 480)
ElseIf $set=2 Then
GUICtrlCreatePic("B7.jpg", 120, 10 , 370 , 480)
ElseIf $set=3 Then
GUICtrlCreatePic("C7.jpg", 120, 10, 370, 480)
EndIf

ElseIf $msg = $button8
If $set=1 Then
GUICtrlCreatePic("A8.jpg", 120 , 10 , 370 , 480)
ElseIf $set=2 Then
GUICtrlCreatePic("B8.jpg", 120, 10 , 370 , 480)
ElseIf $set=3 Then
GUICtrlCreatePic("C8.jpg", 120, 10, 370, 480)
EndIf

ElseIf $msg = $GUI_EVENT_CLOSE Then
Exitloop ;Not sure what this does but it seems to work, aqcuired from a script given from the help forums
EndIf

Wend
Exit

Link to comment
Share on other sites

Well...hmm....

I see that you're creating the picture every time the button is pressed and overlaying the existing picture. Not always the best idea.

What I do in my GUI code is create the pictures all at the same time as the rest of the GUI. That way, it's all in memory and instant access. In this case, GUICtrlSetState() will be your best friend.

Example of my code.

Part of GUI creation block:

If FileExists($imgLocation & "clicktop.gif") And FileExists($imgLocation & "clickright.gif") _
        And FileExists($imgLocation & "clickbottom.gif") And FileExists($imgLocation & "clickleft.gif") Then
    ; if the images are found, use them.
    $imgFiles = 1
    $guiTemp = ControlGetPos($frmMainGUI, "", $rbtnGroup02)
    $imgClickZone[1] = GUICtrlCreatePic($imgLocation & "clicktop.gif", $guiTemp[0] + $guiTemp[2] + 10, $guiTemp[1] + 12, 136, 96)
    $imgClickZone[2] = GUICtrlCreatePic($imgLocation & "clickright.gif", $guiTemp[0] + $guiTemp[2] + 10, $guiTemp[1] + 12, 136, 96)
    $imgClickZone[3] = GUICtrlCreatePic($imgLocation & "clickbottom.gif", $guiTemp[0] + $guiTemp[2] + 10, $guiTemp[1] + 12, 136, 96)
    $imgClickZone[4] = GUICtrlCreatePic($imgLocation & "clickleft.gif", $guiTemp[0] + $guiTemp[2] + 10, $guiTemp[1] + 12, 136, 96)
    For $x = 1 To 4
        GUICtrlSetState($imgClickZone[$x], $GUI_HIDE)
        If GUICtrlRead($rbtnClickZone[$x]) = $GUI_CHECKED Then GUICtrlSetState($imgClickZone[$x], $GUI_SHOW)
    Next
Else
    ; otherwise, use text labels
    $guiTemp = ControlGetPos($frmMainGUI, "", $rbtnGroup02)
    $lblClickZone[1] = GUICtrlCreateLabel("The script will send a single left click in the top area of the monitor, 30 pixels from the edge, avoiding a 30x30 pixel square at the corners.", _
            $guiTemp[0] + $guiTemp[2] + 10, $guiTemp[1] + 12, 136, 96)
    $lblClickZone[2] = GUICtrlCreateLabel("The script will send a single left click in the right area of the monitor, 30 pixels from the edge, avoiding a 30x30 pixel square at the corners.", _
            $guiTemp[0] + $guiTemp[2] + 10, $guiTemp[1] + 12, 136, 96)
    $lblClickZone[3] = GUICtrlCreateLabel("The script will send a single left click in the bottom area of the monitor, 30 pixels from the edge, avoiding a 30x30 pixel square at the corners." & @LF & "NOT RECOMMENDED", _
            $guiTemp[0] + $guiTemp[2] + 10, $guiTemp[1] + 12, 136, 96)
    $lblClickZone[4] = GUICtrlCreateLabel("The script will send a single left click in the left area of the monitor, 30 pixels from the edge, avoiding a 30x30 pixel square at the corners.", _
            $guiTemp[0] + $guiTemp[2] + 10, $guiTemp[1] + 12, 136, 96)
    For $x = 1 To 4
        GUICtrlSetState($lblClickZone[$x], $GUI_HIDE)
        If GUICtrlRead($rbtnClickZone[$x]) = $GUI_CHECKED Then GUICtrlSetState($lblClickZone[$x], $GUI_SHOW)
    Next
EndIf
 oÝ÷ Øö«¶é®)¯!!Ö­jZ(¥«­¢+Ø(
ÍÀÌØíÕ¥5MôÀÌØíÉѹ
±¥­i½¹lÅt=ÈÀÌØíÕ¥5MôÀÌØíÉѹ
±¥­i½¹lÉt=ÈÀÌØíÕ¥5MôÀÌØíÉѹ
±¥­i½¹lÍt=ÈÀÌØíÕ¥5MôÀÌØíÉѹ
±¥­i½¹lÑt(½ÈÀÌØíé±½½ÀôÄQ¼Ð(%U%
ÑɱI ÀÌØíÉѹ
±¥­i½¹lÀÌØíé±½½Át¤ôÀÌØíU%}
!
-Q¡¸(
±¥­i½¹ È°ÀÌØíé±½½À°ÀÌØí¥µ¥±Ì¤(%¹¥]É¥Ñ ÀÌØí¥¹¥¥±°ÅÕ½Ðí5%8ÅÕ½Ðì°ÅÕ½Ðí
±¥­M¥ÅÕ½Ðì°ÀÌØíé±½½À¤ìѽÀ Ĥ½É¥¡Ð Ȥ½½Ñѽ´ ̤½±Ð Ф(¹%(9áÐ(oÝ÷ Ø)brFhçîËb¢{ajÛ0j-è¦jºÚ"µÍ[ÈÛXÚÖÛJ   ÌÍÚQÜÝ ÌÍÚS[K   ÌÍÚR[XYÙÊBÙ[XÝØÙH  ÌÍÚQÜÝHBÜ ÌÍØÛÝ[HHÈÂÕRPÝÙ]Ý]J  ÌÍÛÙ[^ÉÌÍØÛÝ[K    ÌÍÑÕRWÒQJB^ÕRPÝÙ]Ý]J   ÌÍÛÙ[^ÉÌÍÚS[WK  ÌÍÑÕRWÔÒÕÊBØÙH    ÌÍÚQÜÝHY   ÌÍÚR[XYÙÈHH[ÈÝØH[XYÙÂÜ   ÌÍØÛÝ[HHÈ
ÕRPÝÙ]Ý]J   ÌÍÚ[YÐÛXÚÖÛVÉÌÍØÛÝ[K  ÌÍÑÕRWÒQJB^ÕRPÝÙ]Ý]J   ÌÍÚ[YÐÛXÚÖÛVÉÌÍÚS[WK    ÌÍÑÕRWÔÒÕÊB[ÙBÈY[XYÙÈÛÌÎNÝ^ÝÝØHX[ËÜ    ÌÍØÛÝ[HHÈ
ÕRPÝÙ]Ý]J   ÌÍÛÛXÚÖÛVÉÌÍØÛÝ[K  ÌÍÑÕRWÒQJB^ÕRPÝÙ]Ý]J   ÌÍÛÛXÚÖÛVÉÌÍÚS[WK    ÌÍÑÕRWÔÒÕÊB[Y[Ù[XÝ[[ÈÏOIÝÐÛXÚÖÛB

Hope that helps!

Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

FYI: ExitLoop will terminate a loop early.

Because I was feeling bored....I've basically rewritten your GUI. Please, study it and learn from it. If I've made any mistakes, feel free to correct them.

By the way...the "directions.jpg" has never been hidden. You may want to write an adhoc or something to hide it after X seconds or so.

opt("MustDeclareVars", 1); All variables must be declared before use.
#include <GuiConstants.au3>
Global $hwndPicturesGUI, $button1, $button2, $button3, $button4, $button5, $button6, $button7, $button8
Global $directions, $set1, $set2, $set3, $set, $msg, $temp, $x, $y, $filename
Global $guiPic[4][9]
#region GUI Creation
$hwndPicturesGUI = GUICreate("Pictures", 500, 550) ;Titles my GUIconsole "Pictures"
$button1 = GUICtrlCreateButton("Pic1!", 10, 10, 100, 30) ;Creates my 8 buttons, for the 8 different pictures i have in my 3 sets
$button2 = GUICtrlCreateButton("Pic2!", 10, 60, 100, 30)
$button3 = GUICtrlCreateButton("Pic3!", 10, 110, 100, 30)
$button4 = GUICtrlCreateButton("Pic4!", 10, 160, 100, 30)
$button5 = GUICtrlCreateButton("Pic5!", 10, 210, 100, 30)
$button6 = GUICtrlCreateButton("Pic6!", 10, 260, 100, 30)
$button7 = GUICtrlCreateButton("Pic7!", 10, 310, 100, 30)
$button8 = GUICtrlCreateButton("Pic8!", 10, 360, 100, 30)
$directions = GUICtrlCreatePic("Directions.jpg", 120, 10, 370, 480) ;Brings up a picture with the instructions on it
$set1 = GUICtrlCreateButton("A", 130, 510, 100, 30) ;Creates my buttons to determine what set i want to view, A, B, or C
$set2 = GUICtrlCreateButton("B", 240, 510, 100, 30)
$set3 = GUICtrlCreateButton("C", 350, 510, 100, 30)
For $x = 1 To 3
    For $y = 1 To 8
        Select
            Case $x = 1
                $filename = "A" & $y & ".jpg"
            Case $x = 2
                $filename = "B" & $y & ".jpg"
            Case $x = 3
                $filename = "C" & $y & ".jpg"
        EndSelect
        $guiPic[$x][$y] = GUICtrlCreatePic($filename, 120, 10, 370, 480)
    Next
Next
$set = 1
GUISetState()
#endregion
#region Primary Data Loop
While 1
    Sleep(10)
    $msg = GUIGetMsg()
    Select
        Case $msg = $set1 ; Determines what set
            $set = 1
        Case $msg = $set2
            $set = 2
        Case $msg = $set3
            $set = 3
        Case $msg = $button1 ;Determines what picture of the predetermined set the user wants to view
            _ClickZone($set, 1)
        Case $msg = $button2
            _ClickZone($set, 2)
        Case $msg = $button3
            _ClickZone($set, 3)
        Case $msg = $button4
            _ClickZone($set, 4)
        Case $msg = $button5
            _ClickZone($set, 5)
        Case $msg = $button6
            _ClickZone($set, 6)
        Case $msg = $button7
            _ClickZone($set, 7)
        Case $msg = $button8
            _ClickZone($set, 8)
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
WEnd
#endregion
#region Function List
Func _ClickZone($intSet, $intButton)
    Local $intLoopX, $intLoopY
    For $intLoopX = 1 To 3
        For $intLoopY = 1 To 8
            GUICtrlSetState($guiPic[$intLoopX][$intLoopY], $GUI_HIDE)
        Next
    Next
    GUICtrlSetState($guiPic[$intSet][$intButton], $GUI_SHOW)
EndFunc   ;==>_ClickZone
#endregion

>C:\Documents and Settings\user\Desktop\AutoIt\SciTe\CompileAU3\CompileAU3.exe /prod /AU3Check /in "C:\Documents and Settings\user\Desktop\AutoIt\User Scripts\temp04.au3"
>Running AU3Check...C:\Documents and Settings\user\Desktop\AutoIt\SciTe\Defs\Production\Au3Check\au3check.dat
>AU3Check Ended. No Error(s).
>Exit code: 0   Time: 0.417

Edit: Fixed a logic error.

Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

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...