Jump to content

If Gui Label doesn't exist Gui goes into infinite loop


Recommended Posts

Good Afternoon All :dance:

Let me start by saying... I'm not sure if this belongs in the GUI part of the forum as it's more of a loop / code / dynamic GUI layout issue. I understand if you move it though.

I have been doing some crazy things in AutoIT lately and one of them just so happens to be an accidental infinite loop. :naughty:

I am dynamically populating my GUI labels... so that means if I have a users ip address I create

$L_PP1_WhoISSearch

However, if I assign a function to a non existent label... for instance a user has no ip address or it is invalid, I get an infinite loop / crash.

The While loop below just goes crazy running ShellExecute.  Since the label $L_PP1_WhoISSearch doesn't exist, the function WhoISSearch() just runs ShellExecute to infinity... What should I do differently??? Is there a trigger I can set in the Gui to ignore missing cases??? Sorry, I can only provide "snippets" of my code since it's for work. Thanks you all!!!

; This is my loop of doom if the $L_PP1_WhoISSearch doesn't exist in my gui.
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $L_PP1_DashboardLink
            DashboardLink01()
        Case $L_PP1_WhoISSearch
            WhoISSearch()
        Case $B_PP1_BACK02
            GUIDelete()
            Gui01_PP_INC()
        Case $B_PP1_EXIT02
            Exit
    EndSwitch
WEnd

Func WhoISSearch()

ShellExecute('http://whois.arin.net/rest/nets;q=' & $PP1_SourceIPClick01 & '?showDetails=true&showARIN=false&showNonArinTopLevelNet=false')

;MsgBox (0, "", 'WTF')

EndFunc
; This is my dynamic label for my Gui.
        ElseIf $i = 5 Then

        $L_PP1_SourceIP = GUICtrlCreateLabel($LabelVariable & ' ' & $aArray_Variable_PP_Gui01[$i], 10, $L_PP1_Var_StartHeight, 316, 19)
        GUICtrlSetFont(-1, 10, 800, 0, "Calibri")
        $L_PP1_Var_StartHeight += 22

        $L_PP1_WhoISSearch = GUICtrlCreateLabel('WhoIS Search: ' & $PP1_SourceIPClick01, 10, $L_PP1_Var_StartHeight, 316, 19)
        GUICtrlSetFont(-1, 10, 800, 0, "Calibri")
        GUICtrlSetColor(-1, 0x0000FF)
        $L_PP1_Var_StartHeight += 22

 

"Maybe I'm on a road that ain't been paved yet. And maybe I see a sign that ain't been made yet"
Song Title: I guess you could say
Artist: Middle Class Rut

Link to comment
Share on other sites

Assign a value to the variable $L_PP1_WhoISSearch, 9999 should be sufficient for the initial value. Then the Switch won't action on it.

Are you actually using the label as a button?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Yes, I'm using the label as a button... you're right. I just like the look of it. What does the 9999 do - sorry could you explain a wee bit more :idiot: I don't understand...

UPDATE: Nevermind and Thank you BrewManNH !!!

More from za googlez!

; Predeclare the variables with dummy values to prevent firing the Case statements

I SPENT FOREVER ON THIS... SO THANK YOU AGAIN :sorcerer:

Edited by souldjer777

"Maybe I'm on a road that ain't been paved yet. And maybe I see a sign that ain't been made yet"
Song Title: I guess you could say
Artist: Middle Class Rut

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

×
×
  • Create New...