SxyfrG Posted January 18, 2008 Share Posted January 18, 2008 For the past few weeks me and a friend of mine have been developing an application which allows you to easily launch games from the system tray. The application reads from a .ini file ( config.ini ) located in the same directory which tells the application how many tray menu's to create and how many menu items within those menu's to make. So far we've had a few minor hiccups, but nothing we can't deal with, but recently when adding a new option to the applicaion ( add/remove group ), we've run into a bit of trouble. Adding a group is fine and works well, but when you remove the group and restart the application, things go a bit haywire... When the application is loading, it reads the number of groups you have created (e.g. 3). If you remove the first group, it will create 2 group's after it restarts. This is all well and good BUT the first group will have no name and instead of showing the 2 remaining groups, it will only show the first of the two as the second group due to an IniRead problem. ;Groups ------------------------------------------------------------------------------------------- $GroupCheck = IniRead ( @ScriptDir & "\config.ini" , "Groups" , "Number" , "Not Found" ) if $GroupCheck = "Not Found" Then IniWrite ( @ScriptDir & "\config.ini" , "Groups" , "Number" , "0" ) Else EndIf ;Group name checking and menu and menu item creation $GroupNumber = IniRead ( @ScriptDir & "\config.ini" , "Groups" , "Number" , "" ) For $N = 1 To $GroupNumber Step 1 $GroupName[$N][0] = IniRead ( @ScriptDir & "\config.ini" , "Group"&$N , "Name" , "" ) Next For $G = 1 To $GroupNumber Step 1 TrayCreateItem ( "" ) $Group[$G][0] = TrayCreateMenu ( $GroupName[$G][0] ) $GroupOptions[$G][0] = TrayCreateMenu ( "Options" , $Group[$G][0] ) $GroupOptRemove[$G][0] = TrayCreateItem ( "Remove Group" , $GroupOptions[$G][0] ) $GroupOptChangeName[$G][0] = TrayCreateItem ( "Change Group Name" , $GroupOptions[$G][0] ) EndIf Next ;-------------------------------------------------------------------------------------------------- And the ini style: [Groups] Number=3 [Group1] Name=Games [Group2] Name=Applications [Group3] Name=Text Documents After removing the group "Games": [Groups] Number=2 [Group2] Name=Applications [Group3] Name=Text Documents What i'm basically trying to say (in the most confusing way possible) is that the problem is math related. I need some kind of function that scans the ini file in the 'groups' bit for a gap between numbers ( e.g. [Group1] [Group3] ) and fixes it by re-writing those ini entries as a number lower so the ini file will read [Group1] [Group2] etc at the start of the script. It's really late over here and my head is hurting from thinking all day and working with other scripts so if anyone here has deciphered my mess of a help request, please help me, the only reward i can offer is brownie points P.S. Script included (as well as the Restart.au3 script)GameLauncherTRAY.rar My scripts:AppLauncherTRAY - Awesome app launcher that runs from the system tray NEW VERSION! | Run Length Encoding - VERY simple compression in pure autoit | Simple Minesweeper Game - Fun little game :)My website Link to comment Share on other sites More sharing options...
martin Posted January 18, 2008 Share Posted January 18, 2008 For the past few weeks me and a friend of mine have been developing an application which allows you to easily launch games from the system tray. The application reads from a .ini file ( config.ini ) located in the same directory which tells the application how many tray menu's to create and how many menu items within those menu's to make. So far we've had a few minor hiccups, but nothing we can't deal with, but recently when adding a new option to the applicaion ( add/remove group ), we've run into a bit of trouble. Adding a group is fine and works well, but when you remove the group and restart the application, things go a bit haywire... When the application is loading, it reads the number of groups you have created (e.g. 3). If you remove the first group, it will create 2 group's after it restarts. This is all well and good BUT the first group will have no name and instead of showing the 2 remaining groups, it will only show the first of the two as the second group due to an IniRead problem. And the ini style: After removing the group "Games": What i'm basically trying to say (in the most confusing way possible) is that the problem is math related. I need some kind of function that scans the ini file in the 'groups' bit for a gap between numbers ( e.g. [Group1] [Group3] ) and fixes it by re-writing those ini entries as a number lower so the ini file will read [Group1] [Group2] etc at the start of the script. It's really late over here and my head is hurting from thinking all day and working with other scripts so if anyone here has deciphered my mess of a help request, please help me, the only reward i can offer is brownie points P.S. Script included (as well as the Restart.au3 script) Maybe you could simplify it, though you would need to change your script a bit. Instead of having the ini file the way you do, hav it like this [Groups] Names = Games|Applications|Text documents| Then when you read it $AllGroups = IniRead( @ScriptDir & "\config.ini" , "Groups" , "Names" , "" ) $Groups = StringSplit($AllGroups,'|') $GroupNumber = $Groups[0] - 1 When you remove a group like games then $AllGroups = StringReplace($AllGroups,"Games|","") Then write the Names in the ini file again and remove the Games section. Instead of calling the sections "Group1", "Group2" etc I would call them "Games", "Applications"... and the Names key is effectively an index Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
SxyfrG Posted January 18, 2008 Author Share Posted January 18, 2008 Thanks martin, i'm trying it now (fingers, toes and eyes crossed). Hopefully i won't have to change anything else, the entire script is over 3000 lines long My scripts:AppLauncherTRAY - Awesome app launcher that runs from the system tray NEW VERSION! | Run Length Encoding - VERY simple compression in pure autoit | Simple Minesweeper Game - Fun little game :)My website Link to comment Share on other sites More sharing options...
SxyfrG Posted January 18, 2008 Author Share Posted January 18, 2008 YES!!!! Adding groups works, removing groups works and creating the tray menu items also works, THANK YOU MARTIN!!!! My scripts:AppLauncherTRAY - Awesome app launcher that runs from the system tray NEW VERSION! | Run Length Encoding - VERY simple compression in pure autoit | Simple Minesweeper Game - Fun little game :)My website 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