supadodger Posted November 21, 2010 Share Posted November 21, 2010 (edited) expandcollapse popup$top = 10 for $r = 1 to 35 $Label[$r] = GUICtrlCreateLabel("http://www.google.com", 30), 0, $top, 209, 20) $Link[$r] = "http://www.google.com" $top = $top + 15 Next While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Label[1] ShellExecute($Link[1]) Case $Label[2] ShellExecute($Link[2]) Case $Label[3] ShellExecute($Link[3]) Case $Label[4] ShellExecute($Link[4]) Case $Label[5] ShellExecute($Link[5]) Case $Label[6] ShellExecute($Link[6]) Case $Label[7] ShellExecute($Link[7]) Case $Label[8] ShellExecute($Link[8]) Case $Label[9] ShellExecute($Link[9]) Case $Label[10] ShellExecute($Link[10]) Case $Label[11] ShellExecute($Link[11]) Case $Label[12] ShellExecute($Link[12]) Case $Label[13] ShellExecute($Link[13]) Case $Label[14] ShellExecute($Link[14]) Case $Label[15] ShellExecute($Link[15]) Case $Label[16] ShellExecute($Link[16]) Case $Label[17] ShellExecute($Link[17]) Case $Label[18] ShellExecute($Link[18]) Case $Label[19] ShellExecute($Link[19]) Case $Label[20] ShellExecute($Link[20]) Case $Label[21] ShellExecute($Link[21]) Case $Label[22] ShellExecute($Link[22]) Case $Label[23] ShellExecute($Link[23]) Case $Label[24] ShellExecute($Link[24]) Case $Label[25] ShellExecute($Link[25]) Case $Label[26] ShellExecute($Link[26]) Case $Label[27] ShellExecute($Link[27]) Case $Label[28] ShellExecute($Link[28]) Case $Label[29] ShellExecute($Link[29]) Case $Label[30] ShellExecute($Link[30]) Case $Label[31] ShellExecute($Link[31]) Case $Label[32] ShellExecute($Link[32]) Case $Label[33] ShellExecute($Link[33]) Case $Label[34] ShellExecute($Link[34]) Case $Label[35] ShellExecute($Link[35]) EndSwitch Wend during this loop its constantly shell executing even if i dont click anything... Edited November 21, 2010 by supadodger Link to comment Share on other sites More sharing options...
taietel Posted November 21, 2010 Share Posted November 21, 2010 You have to exit from the function or put an ExitLoop at the end of the statement. Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
supadodger Posted November 21, 2010 Author Share Posted November 21, 2010 You have to exit from the function or put an ExitLoop at the end of the statement.they shouldnt shellexecute unless i click one of them though... Link to comment Share on other sites More sharing options...
taietel Posted November 21, 2010 Share Posted November 21, 2010 Something like this? expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> GUICreate("Form", 625, 443, 192, 124) Global $Label[11], $Link[11] $top = 10 for $r = 1 to 10 $Link[$r]="http://www.google.com" $Label[$r] = GUICtrlCreateLabel($Link[$r], 30, $top, 209, 20,$SS_NOTIFY) $top = $top + 25 Next GUISetState(@SW_SHOW) While 1 Sleep(10) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Label[1] ShellExecute($Link[1]) Case $Label[2] ShellExecute($Link[2]) Case $Label[3] ShellExecute($Link[3]) Case $Label[4] ShellExecute($Link[4]) Case $Label[5] ShellExecute($Link[5]) Case $Label[6] ShellExecute($Link[6]) Case $Label[7] ShellExecute($Link[7]) Case $Label[8] ShellExecute($Link[8]) Case $Label[9] ShellExecute($Link[9]) Case $Label[10] ShellExecute($Link[10]) EndSwitch Wend Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
BrewManNH Posted November 21, 2010 Share Posted November 21, 2010 Does that piece of code even work for you? As it's written, your label create line is written wrong you have a rogue parentheses in it, and your $top variable is in the wrong place. Adding this snippet to a GUI and declaring the arrays, and it works just fine for me. Except I get an error for some reason, that it's trying to find a file with the name of your link, even though the link opens in my browser. 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 GudeHow 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 More sharing options...
taietel Posted November 21, 2010 Share Posted November 21, 2010 For me, not at first time. After correcting/adding the GUI stuff, fixing the arrays, it worked. BrewManNH, the error was from the $Link array (wasn't declared either). supadodger, it is much easier for other users that you post a functional code and see why it's not working, than adding variables etc. Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
BrewManNH Posted November 21, 2010 Share Posted November 21, 2010 @taietel I was referring to the OP, your's was posted while I was responding to him. 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 GudeHow 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 More sharing options...
taietel Posted November 21, 2010 Share Posted November 21, 2010 @BrewManNH, I know you were referring to the OP. That error with the link took me some time to figure it out. M.I. Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
MvGulik Posted November 21, 2010 Share Posted November 21, 2010 General: If your using a lot of cases in a gui-msgloop you might like to add a empty "case 0" at the top of it. (little cpu saver) "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 ... Link to comment Share on other sites More sharing options...
GEOSoft Posted November 21, 2010 Share Posted November 21, 2010 General: If your using a lot of cases in a gui-msgloop you might like to add a empty "case 0" at the top of it. (little cpu saver)Or a "Case Else" at the bottom of it. Also don't forget that the Msg moop has a built in delay to save the cpu usage anyway. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
MvGulik Posted November 21, 2010 Share Posted November 21, 2010 (edited) Or a "Case Else" at the bottom of it.No. As zero is the most common return value the point is to cut the switch process short when there is nothing to do in the first place. Edited November 21, 2010 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 ... Link to comment Share on other sites More sharing options...
Mat Posted November 21, 2010 Share Posted November 21, 2010 The most common reason for a case in a message loop being triggered when you don't want it to is when creating a control fails. As a result, zero is returned. As a result, whenever there is no message, it triggers the code for that control. In this case I won't even bother pointing out all the improvements that can be made in the code, other than to say that i'd use a FOR loop in a Case Else for all the labels. AutoIt Project Listing Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now