Sign in to follow this  
Followers 0
Schoening

Multiple Select Case Problem {SOLVED}

17 posts in this topic

#1 ·  Posted (edited)

While i am waiting for Better Solutions for Finding Multiple @error Cases and React according to them, i am hoping that some1 could explain me what my problem in this (time consuming) function is..

The Idea is that i check for @Errors from the 3 PixelSearch i am doing, and give Message according to it.

I am changing Colors In Paint for Every Loop To Test If the Color Searches Are Correct.

All Cases are Working Fine, and the Right MsgBoxes are Triggered, Except the Case where all 3 Colors are Missing:

HotKeySet("{ESC}", "End")
Global $pixelSearchError1 = @error
Global $pixelSearchError2 = @error
Global $pixelSearchError3 = @error
While 1
Sleep(10)
$pixelsearch1 = PixelSearch(100,300,200,512,0x0000ff,10) ;Blue
$pixelSearchError1 = @error
$pixelsearch2 = PixelSearch(250,310,400,512,0xfa0000,10) ;Red
$pixelSearchError2 = @error
$pixelsearch3 = PixelSearch(500,300,600,512,0x00ff00,10) ;Green
$pixelSearchError3 = @error
Call("_errorcheck")
WEnd
Func _errorcheck()
    Sleep(100)
Select                                                        ;Check for Blue Color, Then Proceed.
        Case Not $pixelSearchError1                              ;Found Blue
            MsgBox(0,"Message","Blue Pixel Found!")
   Select                                                 ;Blue Found.  Now check for Red
    Case Not $pixelSearchError2                           ;Found Blue and Red
     MsgBox(0,"Message","Blue and Red Pixel Found!")
     Select                                       ;Blue and Red found. Now check for Green
      Case Not $pixelSearchError3                     ;Found Blue, Red and Green
        MsgBox(0,"Message","Blue,Red and Green Pixel Found!")
      Case $pixelSearchError3                             ;Blue, Red  But not Green
        MsgBox(0,"Message","Found Blue, Red But Not Green")
      EndSelect
    Case $pixelSearchError2          ;Blue Found, But Not Red
      MsgBox(0,"Message","Blue Found, But Not Red")
         Select                                       ;Blue and Red found. Now check for Green
          Case Not $pixelSearchError3                     ;Found Blue, Green But not Red
        MsgBox(0,"Message","Found Blue, Green But Not Red")
       Case $pixelSearchError3                          ;Blue, But not Red or Green
        MsgBox(0,"Message","Could only Find Blue")
      EndSelect
    EndSelect
  Case $pixelSearchError1                                    ;Blue Not Found
         MsgBox(0,"Message","Blue Pixel Not Found")
            Select                                                ;Blue Not Found.  Now check for Red
    Case Not $pixelSearchError2                           ;Found Red, But not Blue
     MsgBox(0,"Message","Found Red, But not Blue")
     Select                                       ;Found Red, But not Blue Now check for Green
      Case Not $pixelSearchError3                     ;Red and Green, but not Blue
        MsgBox(0,"Message","Red,Green But not Blue")
      Case $pixelSearchError3                             ;Red, But not  Blue or Green
        MsgBox(0,"Message","Could only Find Red")
      EndSelect
    Case $pixelSearchError2          ;Could not find Blue or Red
      MsgBox(0,"Message","Could not Find Blue and Red")
     Select                                       ;Blue and Red Not found. Now check for Green
      Case Not $pixelsearch3                      ;Only found Green
        MsgBox(0,"Message","Only found Green")
      Case $pixelSearchError3                           ;Did not Find Blue,Red or Green
        MsgBox(0,"Message","No Color was found")
     EndSelect
            EndSelect
    EndSelect
    Sleep(10)
EndFunc

I Made a Picture that should make it far easier to see where one Select Case Starts and Ends :D Check the Link Below.

http://imageshack.us/f/9/selectcasegreenerror.gif/

I can't see why the Last Case is not working.. When Blue,Red AND Green are Missing i still get the "Only found Green"

Please Help :)

Also, Building the Cases Like this takes up allot of Time and Space, so if you have a Easier way please Tell :)

Like:

If Not @error 1 And @error 2  And @error 3 Then

But i don't think that Works.

I probably want to run 5 PixelSearches and that would mean 5 Select an 32 Cases !!!1!!11

So it would be Great if there was another way of doing this ;)

If not, Please do still tell what the problem of my Function is ;)

Edited by Schoening

Share this post


Link to post
Share on other sites



Just Click the Picture from the Link :)

Makes it far easier to figure out ;)

Share this post


Link to post
Share on other sites

I usually don't work with pixels -- but perhaps something like this with a numbering system might give you an idea.

HotKeySet('{ESC}', 'End')
;
Local $aBlue, $aGreen, $aRed, $number, $string
;
While 1
    $number = 0

    $aBlue = PixelSearch(100, 300, 200, 512, 0x0000ff, 10); Blue
    If @error = 0 Then $number += 1
    $aRed = PixelSearch(250, 310, 400, 512, 0xfa0000, 10); Red
    If @error = 0 Then $number += 2
    $aGreen = PixelSearch(500, 300, 600, 512, 0x00ff00, 10); Green
    If @error = 0 Then $number += 4

    Switch $number
        Case 1
            $string = 'Blue'
        Case 2
            $string = 'Red'
        Case 3
            $string = 'Blue and Red'
        Case 4
            $string = 'Green'
        Case 5
            $string = 'Blue and Green'
        Case 6
            $string = 'Red and Green'
        Case 7
            $string = 'Blue, Red and Green'
        Case Else
            $string = 'No Matching Color'
    EndSwitch

    MsgBox(0, '', $string, 1)

    Sleep(10)
WEnd
;
Func End()
    Exit
EndFunc
;

"Today's scientists have substituted mathematics for experiments, and they wander off through equation after equation, and eventually build a structure which has no relation to reality." ~ Nikola Tesla

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Where?

Look when you typed your Message, and when i had my Last Edit o.O i can't see it

Edited by Schoening

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Ah hah, look at the word in the first tab. "Bot".

If you can proof this topic is directly related to that file ... otherwise ... you just jumped the gun.

Where?

Screenshot. "*bot.1.au3" Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites

Aha.:) Not related, found the code in attempt to find Pixelsearch information. I don't think i should link to it here since it is source code of Bot.

Though.. i can't prove that either can i ;)

Share this post


Link to post
Share on other sites

Guys,

While we are grateful that you all try to keep this forum the kind of place we all want it to be, please do not be too aggressive - particularly to newer members. If there is some doubt as to the legality of the subject (which does not seem to be the case here) just report the thread so that a Mod can take a look - that is why we are here. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Thx Melba ^^

Uhm... can any1 find my Error ? xD Now that i even have drawn a Helpful Picture !

Share this post


Link to post
Share on other sites

Nice picture indeed.

Although I'm not really getting the problem. I suggest you take a look at how to use" Not( And Or )" and maybe also take a look at ContinueCase. That should allow you to flatten than monster (eek!) of nested selects. :)

Note the Not($var1 And/or $varN+1) use. The brackets are important here.

http://www.autoitscript.com/autoit3/docs/keywords/ContinueCase.htm

http://www.autoitscript.com/autoit3/docs/intro/lang_operators.htm


"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites

Forgive me for asking this but would you mind posting a true picture of the app you are wanting to work with instead of an generic example? It may be helpful in that we may see a better way to optimize your search method.

This is all i got so far..

The only problem is that the Select Case @error Blue @error Red and @error Green Triggers Only Green ! And Not No Color Found.

I have Run all possibilities a few times.. and dont get it to work.

Share this post


Link to post
Share on other sites

Could PixelSearch be a bit bugged?

I have now added a "Reset" after the Function:

While 1
Sleep(10)
$pixelsearch1 = PixelSearch(100,300,200,512,0x0000ff,10) ;Blue
$pixelSearchError1 = @error
$pixelsearch2 = PixelSearch(250,310,400,512,0xfa0000,10) ;Red
$pixelSearchError2 = @error
Call("_errorcheck")
$pixelSearchError1 = 0
$pixelSearchError2 = 0
$pixelSearchError3 = 0
$pixelsearch1 = 0
$pixelsearch2 = 0
$pixelsearch3 = 0
WEnd

But still the same problem

Share this post


Link to post
Share on other sites

FIXET ! ;) I knew it was a simple Error xD

Just Used a Wrong Variable !

Typical !

Thx for all the Support, like allways ! :D and thx

MvGulik

i Look into Flattening the Code Down :)

Any Admin may {Solved} this one

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

Good to see you found the problem.

Any Admin may {Solved} this one

You got the post count to do it yourself. Just go to your first post in this topic, switch to full edit mode for that post, and change the title to your liking. Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites

Ty :)

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

  • Similar Content

    • Miliardsto
      By Miliardsto
      Im creating a tab
      Global $Tab1 = GUICtrlCreateTab(30, 30, 600, 420, $TCS_BUTTONS, -1) And what we see in the function reference:
      https://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateTab.htm
      GUICtrlCreateTab ( left, top [, width [, height [, style = -1 [, exStyle = -1]]]] ) ok in 5 arg I got $TCS_BUTTONS
      But How can I use multiple args like this below
      Global $Tab1 = GUICtrlCreateTab(30, 30, 600, 420, [$TCS_BUTTONS, $TCS_MULTILINE], -1)  
    • XinYoung
      By XinYoung
      Hello all,
      I've been working on 4 standalone scripts. They each have their own GUI and are now independent .exe's. But instead of having 4 separate icons on my computer, is it possible to put them all together into one .exe?
      What I want is one interface with tabs. Each script's GUI would be on their own respective tab. Is this possible?
      The different scripts don't need to communicate with one another. I just want them all in one .exe.
      I can't find this anywhere... Any help would be greatly appreciated. Thank you!
    • Jibberish
      By Jibberish
      I am working on a Video Player Test Script. I am reading a text file into a 3d array to be displayed in a GUI.
      Array Content:
      [x][0]FileName.mp4
      [x][1]UsageCount -> Up to a 4 digit number
      [x][2]EnableUsageCount (True/False)
      In the GUI the user can check the filename box, edit the number of usages and check EnableUsageCount to turn on the UsageCount control using the UsageCount number for the maximum number of plays.
      To make this easier to deal with I have removed the EnableUsageCount section, and am just concentrating on getting a method to put the edited (or unchanged) UsageCount in the array. Currently nothing is read into the array, due to my using the wrong method in the Case statement.
      Here are code snippets of what I am trying to do:
      ; Snippets from script ; I read the text file at the bottom and put the .mp4 filenames in $aManifest[x][0] and UsageCount in $aManifest[x][1] ; Then I create a GUI to display the .mp4 filenames with checkboxes and the UsageCount to the right. UsageCount is editable by the user. ; If the filename is checked, I want to read the filename into $aCheckedVideos[x][0] and the updated UsageCount in $aCheckedVideos[x][1] ; The GUICtrlRead($aVideoName[$i]) with Case $GUI_CHECKED & UNCHECKED works for the checkboxes ; This section puts the filenames in the GUI with a checkbox For $i = 0 to $iMMCount Step 1 $sMP4Text = $aManifest[$i][0] $iMP4Length = StringLen($sMP4Text) $aVideoName[$i] = GUICtrlCreateCheckbox($sMP4Text,$iLeft, $iTop) $iTop += 30 Next ; This section reads numbers from the Manifest array, and I want to be able to change the number and have them saved. ; So the Case $GUI_CHECKED & UNCHECKED won't work here, and I can't figure out what I should be doing here. For $i = 0 to $iMMCount Step 1 $sUsageText = $aManifest[$i][1] $aUsageCount[$i] = GUICtrlCreateInput($sUsageText,$iLeft, $iTop, 50,18, $GUI_DOCKAUTO) GUICtrlSetPos($aUsageCount[$i],200) $iTop += 30 Next While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $idCloseGUI For $i = 0 To $iMMNewCount Step 1 Switch GUICtrlRead($aVideoName[$i]) Case $GUI_CHECKED $aCheckedVideos[$i][0] = $aManifest[$i][0] ; If checked, I put the results into a two D array Case $GUI_UNCHECKED ; where Video Name is $aCheckedVideos[x][0] EndSwitch Switch GUICtrlRead($aUsageCounter[$i]) Case $GUI_CHECKED $aCheckedVideos[$i][1] = $aUsageCount[$i] ;I want to put the text (numbers) in $aCheckedVideos[x][1] Case $GUI_UNCHECKED ;but what is returned is blank, probably due to EndSwitch ; $GUI_CHECKED being the wrong thing. Next ExitLoop EndSwitch WEnd ;The txt file I'm reading has the following: ;~ /** Title #1: Big Buck Bunny 1080p **/ ;~ "Name": "Big Buck Bunny", ;~ "URI": "..\\MediaFiles\\bbb_1080_60s.mp4", ;~ "UsageCount": 9999, ;~ "URI": "..\\MediaFiles\\bbb_1080_60s_enc1.mp4", ;~ "UsageCount": 45, ;~ "URI": "..\\MediaFiles\\bbb_1080_60s_enc1.mp4", ;~ "UsageCount": 2, ;~ /** Title #2: Tears of Steel 4K **/ ;~ "Name": "Tears of Steel 4K", ;~ "URI": "..\\MediaFiles\\tos_4K_60s_HEVC.mp4", ;~ "UsageCount": 9876, ;~ "URI": "..\\MediaFiles\\tos_4K_60s_HEVC_enc2.mp4", ;~ "UsageCount": 0, ;~ "URI": "..\\MediaFiles\\tos_4K_60s_HEVC_enc2.mp4", ;~ "UsageCount": 5, I am certain that the section
                          Switch GUICtrlRead($aUsageCounter[$i])
                              Case $GUI_CHECKED
                                  $aCheckedVideos[$i][1] = $aUsageCount[$i]    ;I want to put the text (numbers) in $aCheckedVideos[x][1]
                              Case $GUI_UNCHECKED                                ;but what is returned is blank, probably due to
                          EndSwitch                                            ; $GUI_CHECKED being the wrong thing.

      is wrong, and this is what I am looking for help with. Instead of $GUI_CHECKED what should I be looking for?
      The worst part of this is I had this working late last night, and then lost my changes and cannot for the life of me remember how I had this working.
      Help is truly appreciated!
      Jibberish
       
    • argumentum
      By argumentum
      UDF to intercept the error window of AutoIt, showing more details about the error, including ability to save and send by email!
    • kawliga751
      By kawliga751
      I am trying to script the opening of multiple tabs in IE with each tab having a separate login/password. I have been able to make a successful script that will open 3 separate IE sessions with the correct webpage and login or a script that will open 3 tabs in one session (which I want) but will not login. I have tried _IECreate, IEAttach etc. This is the script I am currently using . 
      #include <IE.au3> Const $navOpenInNewTab = 0x0800 Dim $oIE = _IECreate('http://asag.xxxxxxx.com/AAAA/index.htm') ;$o_IE.Navigate2('http://asag.xxxxxxx.com/apps/yyyyyyy/LogInSAG/login.asp', $navOpenInNewTab) ;$o_IE.Navigate2('http://asag.xxxxxxx.com/apps/yyyyyyy/LogInSAG/login.asp', $navOpenInNewTab) Call ("YYYYYYYSignIn") Func YYYYYYYSignIn () Local $username = _IEGetObjByName ($oIE,"uname") Local $password = _IEGetObjByName ($oIE,"pword") $oIE.Navigate2('http://asag.xxxxxxx.com/apps/xxxxxxx/LogInSAG/login.asp',2048) _IEFormElementSetValue ($username, "xxxxxxx") _IEFormElementSetValue ($password, "xxxxxxx") Send('{Enter}') EndFunc Call ("xxxxxxxSignIn") Func xxxxxxxSignIn () __IENavigate($oIE, "https://soa1gui.xxxxxxx.biz/gateway/NFServlet;jsessionid=1E3B8F6520DE0A1EC914A8ABB7E86341?NFH_MessageId=&NFH_Page=%2fpages%2fsearch%2fsearch.jsp", 1, 0x800) Local $domain = _IEGetObjByName ($oIE,"NF_CustomerID") Local $User_Name = _IEGetObjByName ($oIE,"NF_UserName") Local $Password = _IEGetObjByName ($oIE,"NF_Password") _IEFormElementSetValue ($domain, xxxxxxx") _IEFormElementSetValue ($User_Name, "xxxxxxx") _IEFormElementSetValue ($Password, "xxxxxxx") ;Send('{Enter}') EndFunc