maqleod Posted September 14, 2005 Share Posted September 14, 2005 (edited) Ok, here's the deal, I had this script working beautifully and then I added a fileopendialog option to send data from the dialog to an input control just to make things a little easier on the operator. After getting this working I tested it and a completely unrelated error popped up (or at least I don't see why it's related)The script is as follows:#include <GUIConstants.au3>Break(1)Assign("name","LaunchDock 0.2")$background = IniReadSection("config.ini", "Background")$xy = IniReadSection("config.ini", "Position")$tips = IniReadSectionNames("config.ini")$parent = GUICreate($name, 210, 210, $xy[1][1], $xy[2][1],-1)$contextmenu = GUICtrlCreateContextMenu ()Opt("GUICoordMode",2)Opt("RunErrorsFatal", 0)Opt("GUICloseOnESC", 0)Opt("WinTitleMatchMode", 2)$fileopt = GUICtrlCreateMenu ("&File")$ontopitem = GUICtrlCreateMenuitem ("Always On Top",$fileopt)$top = IniReadSection("config.ini", "AlwaysOnTop")if $top[1][1] = 0 thenGUICtrlSetState(-1,$GUI_UNCHECKED)elseif $top[1][1] = 1 thenGUICtrlSetState(-1,$GUI_CHECKED)WinSetOnTop($name, "", 1)endif$restartitem = GUICtrlCreateMenuitem ("Restart",$fileopt)$exititem = GUICtrlCreateMenuitem ("Exit",$fileopt)$configopt = GUICtrlCreateMenu ("Configure")$toggleitem = GUICtrlCreateMenuitem ("Start On Boot",$configopt)$reg = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "LaunchDock")if $reg = @ScriptFullPath thenGUICtrlSetState(-1,$GUI_CHECKED)elseif $reg <> @ScriptFullPath thenGUICtrlSetState(-1,$GUI_UNCHECKED)endif$strtpositem = GUICtrlCreateMenuitem ("Startup Position",$configopt)$buttonsitem = GUICtrlCreateMenuitem ("Buttons",$configopt)$bkcoloritem = GUICtrlCreateMenuitem ("Background Color",$configopt)$transitem = GUICtrlCreateMenuitem ("Set Transparency",$configopt)$helpopt = GUICtrlCreateMenu ("About")$aboutitem = GUICtrlCreateMenuitem ("About",$helpopt)$configmenu = GUICtrlCreateMenu ("Configure", $contextmenu)$toggle = GUICtrlCreateMenuItem ("Toggle Startup", $configmenu)$strtpos = GUICtrlCreateMenuItem ("Startup Position", $configmenu)$buttons = GUICtrlCreateMenuItem ("Buttons", $configmenu)$bkcolor = GUICtrlCreateMenuItem ("Background Color", $configmenu)$trans = GUICtrlCreateMenuItem ("Set Transparency", $configmenu)$ontop = GUICtrlCreateMenuItem ("Toggle Always On Top", $contextmenu)$about = GUICtrlCreateMenuItem ("About", $contextmenu)$restart = GUICtrlCreateMenuItem ("Restart", $contextmenu)$exit = GUICtrlCreateMenuItem ("Exit", $contextmenu)$but1opt1 = IniReadSection("config.ini", "Button 1")$but2opt1 = IniReadSection("config.ini", "Button 2")$but3opt1 = IniReadSection("config.ini", "Button 3")$but4opt1 = IniReadSection("config.ini", "Button 4")$but5opt1 = IniReadSection("config.ini", "Button 5")$but6opt1 = IniReadSection("config.ini", "Button 6")$but7opt1 = IniReadSection("config.ini", "Button 7")$but8opt1 = IniReadSection("config.ini", "Button 8")$but9opt1 = IniReadSection("config.ini", "Button 9")$but1 = GUICtrlCreateButton ("1", 35, 35, 32, 32,$BS_ICON)GUICtrlSetImage (-1, $but1opt1[2][1])GUICtrlSetTip(-1, $tips[1] & ": " & $but1opt1[1][1])$but2 = GUICtrlCreateButton ("2", 20, -32, 32, 32,$BS_ICON)GUICtrlSetImage (-1, $but2opt1[2][1])GUICtrlSetTip(-1, $tips[2] & ": " & $but2opt1[1][1])$but3 = GUICtrlCreateButton ("3", 20, -32, 32, 32,$BS_ICON)GUICtrlSetImage (-1, $but3opt1[2][1])GUICtrlSetTip(-1, $tips[3] & ": " & $but3opt1[1][1])$but4 = GUICtrlCreateButton ("4", -137, 15, 32, 32,$BS_ICON)GUICtrlSetImage (-1, $but4opt1[2][1])GUICtrlSetTip(-1, $tips[4] & ": " & $but4opt1[1][1])$but5 = GUICtrlCreateButton ("5", 20, -32, 32, 32,$BS_ICON)GUICtrlSetImage (-1, $but5opt1[2][1])GUICtrlSetTip(-1, $tips[5] & ": " & $but5opt1[1][1])$but6 = GUICtrlCreateButton ("6", 20, -32, 32, 32,$BS_ICON)GUICtrlSetImage (-1, $but6opt1[2][1])GUICtrlSetTip(-1, $tips[6] & ": " & $but6opt1[1][1])$but7 = GUICtrlCreateButton ("7", -137, 15, 32, 32,$BS_ICON)GUICtrlSetImage (-1, $but7opt1[2][1])GUICtrlSetTip(-1, $tips[7] & ": " & $but7opt1[1][1])$but8 = GUICtrlCreateButton ("8", 20, -32, 32, 32,$BS_ICON)GUICtrlSetImage (-1, $but8opt1[2][1])GUICtrlSetTip(-1, $tips[8] & ": " & $but8opt1[1][1])$but9 = GUICtrlCreateButton ("9", 20, -32, 32, 32,$BS_ICON)GUICtrlSetImage (-1, $but9opt1[2][1])GUICtrlSetTip(-1, $tips[9] & ": " & $but9opt1[1][1])HotKeySet("+!1","Button1")HotKeySet("+!2","Button2")HotKeySet("+!3","Button3")HotKeySet("+!4","Button4")HotKeySet("+!5","Button5")HotKeySet("+!6","Button6")HotKeySet("+!7","Button7")HotKeySet("+!8","Button8")HotKeySet("+!9","Button9")Func Button1()Run($but1opt1[2][1])EndFuncFunc Button2()Run($but2opt1[2][1])EndFuncFunc Button3()Run($but3opt1[2][1])EndFuncFunc Button4()Run($but4opt1[2][1])EndFuncFunc Button5()Run($but5opt1[2][1])EndFuncFunc Button6()Run($but6opt1[2][1])EndFuncFunc Button7()Run($but7opt1[2][1])EndFuncFunc Button8()Run($but8opt1[2][1])EndFuncFunc Button9()Run($but9opt1[2][1])EndFuncGUISetBkColor($background[1][1])GUISetState()Do$transdata = IniReadSection("config.ini", "Transparency")WinSetTrans($name,"", $transdata[1][1])$msg = GUIGetMsg()if $msg = $ontop or $msg = $ontopitem thenif BitAnd(GUICtrlRead($ontopitem),$GUI_CHECKED) = $GUI_CHECKED ThenGUICtrlSetState($ontopitem,$GUI_UNCHECKED)IniWrite("config.ini", "AlwaysOnTop", "Value", "0")WinSetOnTop("", "", 0)elseGUICtrlSetState($ontopitem,$GUI_CHECKED)IniWrite("config.ini", "AlwaysOnTop", "Value", "1")WinSetOnTop("", "", 1)endifendifif $msg = $toggle or $msg = $toggleitem thenif BitAnd(GUICtrlRead($toggleitem),$GUI_CHECKED) = $GUI_CHECKED ThenGUICtrlSetState($toggleitem,$GUI_UNCHECKED)RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "LaunchDock")elseGUICtrlSetState($toggleitem,$GUI_CHECKED)RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "LaunchDock", "REG_SZ", @ScriptFullPath)endIfendifif $msg = $strtpos or $msg = $strtpositem then$child1 = GUICreate("Configure Startup", 275, 175, -1, -1, -1, $parent)Opt("RunErrorsFatal", 0)GUICtrlCreateLabel ("X Coordinates:", 20, 40, 70,70)$xchange = GUICtrlCreateInput( $xy[1][1], 20, -75, 75, 20)GUICtrlCreateLabel ("Y Coordinates:", -165, 20, 70,70)$ychange = GUICtrlCreateInput( $xy[2][1], 20, -75, 75, 20)$xychange = GUICtrlCreateButton ("OK", 10, 20, 75)GUISetState()Do$msg1 = GUIGetMsg()if $msg1 = $xychange thenIniWrite("config.ini", "Position", "x", GUICtrlRead($xchange))IniWrite("config.ini", "Position", "y", GUICtrlRead($ychange))MsgBox(64,"Notice","You must restart LaunchDock for changes to take effect")ExitLoopendifUntil $msg1 = $GUI_EVENT_CLOSEGUIDelete()endifif $msg = $buttons or $msg = $buttonsitem then$child2 = GUICreate("Configure Buttons", 275, 175, -1, -1, -1, $WS_EX_ACCEPTFILES, $parent)Opt("RunErrorsFatal", 0)GUICtrlCreateLabel ("Choose a Button:", 20, 10, 70,70)$buttonchange = GUICtrlCreateCombo ("Button 1", 10, -55, 75, 20,$CBS_DROPDOWNLIST)GUICtrlSetData(-1,"Button 2|Button 3|Button 4|Button 5|Button 6|Button 7|Button 8|Button 9","Button 1")GUICtrlCreateLabel ("Enter The Program Name:", -155, 10, 70,70)$namechange = GUICtrlCreateInput( "", 10, -55, 75, 20)GUICtrlCreateLabel ("Enter The Program Path:", -155, 10, 70,70)$pathchange = GUICtrlCreateInput( "", 10, -55, 75, 20)GUICtrlSetState(-1,$GUI_ACCEPTFILES)$fileopen = GUICtrlCreateButton ("...", 5, -20, 25,25)$change = GUICtrlCreateButton ("OK", -35, 10, 75,25 )GUISetState()Do$msg2 = GUIGetMsg()if $msg2 = $fileopen then$file = FileOpenDialog("Select Program", "C:\Program Files\", "Executables (*.exe;*.bat;*.com;*.pif)", 5)GUICtrlSetData($pathchange,$file,"")endifif $msg2 = $change thenIniWrite("config.ini", GUICtrlRead($buttonchange), "Button Name", GUICtrlRead($namechange))IniWrite("config.ini", GUICtrlRead($buttonchange), "Path", GUICtrlRead($pathchange))MsgBox(64,"Notice","You must restart LaunchDock for changes to take effect")ExitLoopendifUntil $msg2 = $GUI_EVENT_CLOSEGUIDelete()endifif $msg = $bkcolor or $msg = $bkcoloritem then$child5 = GUICreate("Change Background Color", 275, 175, -1, -1, -1, $WS_EX_ACCEPTFILES, $parent)Opt("RunErrorsFatal", 0)GUICtrlCreateLabel ("Choose a Color:", 40, 50, 110,70)$bkcolorchange = GUICtrlCreateCombo ("Black", 10, -65, 75,20,$CBS_DROPDOWNLIST)GUICtrlSetData(-1,"Blue|Red|Green|Yellow|Purple|Gray|White|Orange","Button 1")$colorok = GUICtrlCreateButton ("OK", -70, 40, 75,25)GUISetState()Do$msg5 = GUIGetMsg()if $msg5 = $colorok then$newcolour = GUICtrlRead($bkcolorchange)if $newcolour = "Black" thenAssign("newcolor","0x000000")elseif $newcolour = "Blue" thenAssign("newcolour","0x0000FF")elseif $newcolour = "Red" thenAssign("newcolor","0xFF0000")elseif $newcolour = "Green" thenAssign("newcolor","0x009900")elseif $newcolour = "Yellow" thenAssign("newcolor","0xFFFF00")elseif $newcolour = "Purple" thenAssign("newcolor","0x660099")elseif $newcolour = "Gray" thenAssign("newcolor","0x999999")elseif $newcolour = "White" thenAssign("newcolor","0xFFFFFF")elseif $newcolour = "Orange" thenAssign("newcolor","0xFF9900")endifIniWrite("config.ini", "Background", "Color", $newcolor)MsgBox(64,"Notice","You must restart LaunchDock for changes to take effect")ExitLoopendifUntil $msg5 = $GUI_EVENT_CLOSEGUIDelete()endifif $msg = $trans or $msg = $transitem then$child3 = GUICreate("Set Transparency", 275, 175, -1, -1, -1, $parent)Opt("RunErrorsFatal", 0)GUICtrlCreateLabel ("Enter Transparency Value (0-254):", 40, 50, 110,70)$settrans = GUICtrlCreateInput($transdata[1][1], 10, -65, 75,20)$transok = GUICtrlCreateButton ("OK", -70, 40, 75,25)GUISetState()Do$msg3 = GUIGetMsg()if $msg3 = $transok thenIniWrite("config.ini", "Transparency", "Value", GUICtrlRead($settrans))WinSetTrans($name,"", $transdata[1][1])ExitLoopendifUntil $msg3 = $GUI_EVENT_CLOSEGUIDelete()endifif $msg = $about or $msg = $aboutitem then$child4 = GUICreate("About", 275, 175, -1, -1, -1, $parent)$font = "Ariel"Opt("RunErrorsFatal", 0)GUICtrlCreateLabel ($name, 90, 20, 150,30)GUICtrlSetFont (-1,10, 400, $font)GUICtrlCreateLabel ("by Jared Epstein", -140, 10, 150,30)GUICtrlSetFont (-1,10, 400, $font)$aboutok = GUICtrlCreateButton ("OK", -140, 30, 75,25)GUISetState()Do$msg4 = GUIGetMsg()if $msg4 = $aboutok thenExitLoopendifUntil $msg4 = $GUI_EVENT_CLOSEGUIDelete()endifif $msg = $restart or $msg = $restartitem thenRun(@ScriptFullPath)ExitLoopendifif $msg = $exit or $msg = $exititem thenExitLoopendifif $msg = $but1 thenRun($but1opt1[2][1])endifif $msg = $but2 thenRun($but2opt1[2][1])endifif $msg = $but3 thenRun($but3opt1[2][1])endifif $msg = $but4 thenRun($but4opt1[2][1])endifif $msg = $but5 thenRun($but5opt1[2][1])endifif $msg = $but6 thenRun($but6opt1[2][1])endifif $msg = $but7 thenRun($but7opt1[2][1])endifif $msg = $but8 thenRun($but8opt1[2][1])endifif $msg = $but9 thenRun($but9opt1[2][1])endifUntil $msg = $GUI_EVENT_CLOSEThe error message is as follows:Line 143 (File "C:\...\Launchdock.au3)WinSetTrans($name,"",$transdata[1][1])WinSetTrans($name,"",$transdata^ERRORError: Subscript used with non-Array VariableNow I only get this error when I open up the script and open up the configuration gui and actually use the fileopendialog within the gui. I don't know why I'm getting an error that says that $transdata[1][1] a non-array variable because it's being pulled from here: $transdata = IniReadSection("config.ini", "Transparency"), nor do I know why the error is related to the fileopendialog function.Any help would be greatly appreciatedmaqleodhere's the config.ini details:[button 1]Button Name=Path=[button 2]Button Name=Path=[button 3]Button Name=tPath=[button 4]Button Name=Path=[button 5]Button Name=Path=[button 6]Button Name=Path=[button 7]Button Name=Path=[button 8]Button Name=Path=[button 9]Button Name=Path=[Position]x=0y=25[AlwaysOnTop]Value=0[Transparency]Value=254Color=0x999999 Edited September 14, 2005 by maqleod [u]You can download my projects at:[/u] Pulsar Software Link to comment Share on other sites More sharing options...
therks Posted September 14, 2005 Share Posted September 14, 2005 Just running on assumption here... The FileOpenDialog will change your working directory. Since you don't supply a path to the IniReadSection, it's probably defaulting to the script directory. After using your FileOpenDialog, the working directory changes to the directory to whatever file you opened, and can't find the "config.ini", and spits an error back at you. After this line: $transdata = IniReadSection("config.ini", "Transparency") Try doing some error checking. (Also, try wrapping your code with the [ code ] bbtags) My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
maqleod Posted September 14, 2005 Author Share Posted September 14, 2005 yup, that was it, I just added FileChangeDir(@ScriptDir) after the fileopendialog section and it works just fine, thanks [u]You can download my projects at:[/u] Pulsar Software Link to comment Share on other sites More sharing options...
jksmurf Posted March 15, 2011 Share Posted March 15, 2011 Hi, I've been trying to run kylomas script lodged here and I'm getting the same error.as in this thread. >"N:\JKMPrivate\Utils\AutoIT\SciTe\..\autoit3.exe" /ErrorStdOut "D:\Profiles\kristian\Desktop\Setanta\kylomasRevisedScriptMod01.au3" D:\Profiles\kristian\Desktop\Setanta\kylomasRevisedScriptMod01.au3 (107) : ==> Subscript used with non-Array variable.: local $fl = fileopen("C:\Users\Kristian\Desktop\Setanta\cache\TVxb-setanta.hk-" & stringright($savedate[0],6),2) local $fl = fileopen("C:\Users\Kristian\Desktop\Setanta\cache\TVxb-setanta.hk-" & stringright($savedate^ ERROR >Exit code: 1 Time: 31.964 This thread was the only one with a fix. So I added FileChangeDir(@ScriptDir) after each of the 3# fileopendialog sections but it still bombs out with the same error message?kylomasRevisedScriptMod01.au3 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 15, 2011 Moderators Share Posted March 15, 2011 jksmurf,Why reopen a thread over 5 years old when you already have a thread running on the very code you are trying to debug? And what on earth makes you think that your error has anything to do with FileOpenDialog? The error message shows quite clearly that the error occurs because $savedate is not an array. Looking at the code you are using (assuming it is that posted in the other thread) shows that the variable is created by this line:$savedate = stringregexp($shtml, 'class=selected><A(.+?)'', ''Tab-Date',3)The SRE is obviously failing (you can check for @error to find out why) and so you do not get an array to use in the line which produces the error when it tries to read the array element. You should always use errorcheck code to check that you have an array before trying to access its elements to prevent crashes like this. I suggest you go back to the thread you were using and ask the author to help you debug his code. And do not resurrect off-topic ancient history threads again. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
jksmurf Posted March 16, 2011 Share Posted March 16, 2011 Hi Melba23, I'm really sorry for that, the example scripts thread make it clear it's not a support forum, so could not post there and I wanted to show I really had tried to look for the solution myself before asking. I will open a new thread next time, I promise! I assume it's OK to continue this now though? I guess the reason why I thought it was with the FileOpenDialog was simply that mines appeared (to me) was the same error that this fellow got, with the same FileOpenDialog command. Will check with the author, Cheers k. 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