I want to create a AHK exe file that does timesheets for others. The idea being that I can create a simple timesheet app that writes to a file but is compiled as an exe so can be shared.
The challange being that you need to give it project “names” and “codes” that are relevant to people using it. So it has to be a bit dumb in that people just set it up and go with it.
Using .ini file to populate pulldown list
I found this a handy start to using .ini file:
The video below is good for ini file with GUI:
The combination of the above 2 videos was useful in making the ini file I wanted for people to create their own porject list for the Timesheet app.
A double script is envisaged. First you setup project names and codes, maybe in a .csv file or .txt file then these are uploaded into the programme .inI file so that those projects and codes are ready to share.
This could be a button in the gui for updating project list. At present, I have a hotkey to do this, !4.
I’v got this part working now, in the ini file I’ve had to include a Total_Line_Count so that you can use an if statement when looping through that the loops do not exceed the line count as I was getting additional lines reading “ERROR” on the end of my project code list.
Also, the file that you upload from, a .txt file has a code on each line, but it must be enclosed in quotes “Project-A” otherwise it errors out.
This is now working. I blow away the inin file at the start so that it’s a new file when creating the data, otherwise there could be overwrite issues (adding a new shorter list to an existing longer one will keep some of the older ones). As I blow away ini file I may need a separate ini file for other items. So 2 ini files
New FileName to store to another .ini file
I think people would like to name their own files so that: 1/ They know unique file name (may update file name every week or delete and create a new one), 2/ Save it to a specific place on the PC (or network).
So you need to ask them where they want to place the file and what to name it. A popup GUI would be good then you could also put a little help file to explain about .TXT & .CSV as a file type (maybe a link to video on example of csv and either google sheets or excel?
This took a while to get going, but it works. One issue was the Folder option, it initially gave you a start in My PC so you had to drill down each time to selected plce. I found an option setting (3 , 2 added to 1) that will allow you to cut/paste from Explorer to give folder location, much faster.
This took a while to get sorted using the string SubSt() function on the chosen file name and adding ina “Backup” text and new extension. It took a few runs at doing it before I finally got there, but I think its worth doing just to keep a backup copy if the main one crashes.
This was in the original program and I couldn’t figure why you’d need it. The !4 key opens the fie that is being written to. On reflection I realised that the program was being used as a timer, you’d start a !3 open and set start of a job, then work away, then when you changed tasks, you’d write what task you were doing. You could then go back and re-edit the first task and add other items that you’d done to the script.
Daynamic Hotkeys-HotKey Remapping
Re-assigning hotkeys is apparently called Dynamic hotkeys, after a long search for all sorts of terms before I got to the topic.
This drove me cracked. I could get the hoykeys running outside of the main file but as soon as I put then into the file they did not work. I had to go through the code block by block until I could isolate it, it was at the very end of the original code where there was a #IfWinActive,FastRecordTime and the Labels from the hotkeys would not be called, they just didn’t work, no warnings or errors, but as soon as I reinstated the !3:: hotkey it worked fine. I’d almost given up on it.
I had to write a separate file and do a lot of testing , only with the hotkeys and the pop-up GUI for them. A few sneaky things, if there was a blank in the box then no hotkey was assigned and the code would break, so I had to do a check to make sure, if the box was empty, then it just kept the old fast key.
I also had to initialise the hotkey ini file first or else there would be no keys to use at all, so I do this right at the beginning of the program
I have most of the items that I need working now, so I thought I’d test compiling the program to see that it worked as I’d designed it to do. It does, I now have an icon and on activation, it works.
One thing I’d coded was the long path to a specific subdirectory for my ini files, I realised that this would not work on other PC’s so I used %A_ScriptDir% to write the ini files to. I could add it to something like C://AppData ……. and hide the files, but I think I’d like to be transparent with where I locate the files.
Help File & Context menu
Thius one below, about 7 minutes in, for context menu
This one is for icons and stuff, handy.
SO what I want in the tray menu are a few items:
Exit app. I want to hide the standard items and so I need to be able to exit the app.
Option on list to Set file name
Option on List to load project file
Option on List to Reassign Keys
Option on list to look at file
Help link- to Help page – or popup menu- This requires that you make a GUI window that pops up (so not a menu,tray item but a window on the screen, that way you can use GUI link
I want to setup a Github page where the code and notes can be stored and uploaded by others.
This was a bit of a challenge as I’d forgotten how to sync between a couple of PC’s and Github (after doing it daily when I was doing covid map last year).
I created a Readme.md file to explain the code and that needs to be updated with the video link now.
Overall the process took a lot longer than I’d expected. I was getting a little bored with it by the end , but I persevered as I wanted a pretty robust application to put out there.
A fun project and a bit of learning. I think I’m best pleased with the de-bug of the hotkeys breaking in the program where I commented out the whole code and then slowly worked through until I identified the element that was causing the fault.
I’m pleased with the final outcome, its quite rounded. There are other things I can add to this to extend the project, like making multiple projects show and switch timer between them, but I’ve other things that I want to address first.
If there is not that much response to the app I may let it RIP.