{"id":6855,"date":"2021-04-01T13:53:32","date_gmt":"2021-04-01T13:53:32","guid":{"rendered":"https:\/\/max-drake.cc\/?p=6855"},"modified":"2021-04-01T20:01:30","modified_gmt":"2021-04-01T20:01:30","slug":"ahk-time-capture-app-development","status":"publish","type":"post","link":"https:\/\/max-drake.cc\/?p=6855","title":{"rendered":"AHK Time Capture App development"},"content":{"rendered":"\n<p>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. <\/p>\n\n\n\n<p>The challange being that you need to give it project &#8220;names&#8221; and &#8220;codes&#8221; 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. <\/p>\n\n\n\n<h3 class=\"alignwide wp-block-heading\">Using .ini file to populate pulldown list<\/h3>\n\n\n\n<p>I found this a handy start to using .ini file:<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe title=\"How to use ini file to Save &amp; Retrieve settings with AutoHotkey\" width=\"678\" height=\"381\" data-src=\"https:\/\/www.youtube.com\/embed\/ebQvOCYyBks?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" data-load-mode=\"1\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>The video below is good for ini file with GUI:<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe title=\"AutoHotKey INI Files 1 (Intro to variable storing)\" width=\"678\" height=\"381\" data-src=\"https:\/\/www.youtube.com\/embed\/BEd88xI-tTo?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" data-load-mode=\"1\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>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. <\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>This could be a button in the gui for updating project list. At present, I have a hotkey to do this, !4. <\/p>\n\n\n\n<p>I&#8217;v got this part working now, in the ini file I&#8217;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 &#8220;ERROR&#8221; on the end of my project code list. <\/p>\n\n\n\n<p>Also, the file that you upload from, a .txt file has a code on each line, but it must be enclosed in quotes &#8220;Project-A&#8221; otherwise it errors out. <\/p>\n\n\n\n<p>This is now working. I blow away the inin file at the start so that it&#8217;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<\/p>\n\n\n\n<h3 class=\"alignwide wp-block-heading\">New FileName to store to another .ini file<\/h3>\n\n\n\n<p>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). <\/p>\n\n\n\n<p>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 &amp; .CSV as a file type (maybe a link to video on example of csv and either google sheets or excel?<\/p>\n\n\n\n<p>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. <\/p>\n\n\n\n<h4 class=\"alignwide wp-block-heading\">Backup file<\/h4>\n\n\n\n<p>This took a while to get sorted using the string SubSt() function on the chosen file name and adding ina &#8220;Backup&#8221; 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. <\/p>\n\n\n\n<h4 class=\"alignwide wp-block-heading\">Run File<\/h4>\n\n\n\n<p>This was in the original program and I couldn&#8217;t figure why you&#8217;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&#8217;d start a !3 open and set start of a job, then work away, then when you changed tasks, you&#8217;d write what task you were doing. You could then go back and re-edit the first task and add other items that you&#8217;d done to the script. <\/p>\n\n\n\n<h3 class=\"alignwide wp-block-heading\">Daynamic Hotkeys-HotKey Remapping <\/h3>\n\n\n\n<p>Re-assigning hotkeys is apparently called Dynamic hotkeys, after a long search for all sorts of terms before I got to the topic. <\/p>\n\n\n\n<p>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 &nbsp;<em><strong>#IfWinActive,FastRecordTime<\/strong><\/em> and the Labels from the hotkeys would not be called, they just didn&#8217;t work, no warnings or errors, but as soon as I reinstated the <strong>!3::<\/strong> hotkey it worked fine. I&#8217;d almost given up on it. <\/p>\n\n\n\n<p>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. <\/p>\n\n\n\n<p>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<\/p>\n\n\n\n<h4 class=\"alignwide wp-block-heading\">Compiling<\/h4>\n\n\n\n<p>I have most of the items that I need working now, so I thought I&#8217;d test compiling the program to see that it worked as I&#8217;d designed it to do. It does, I now have an icon and on activation, it works. <\/p>\n\n\n\n<p>One thing I&#8217;d coded was the long path to a specific subdirectory for my ini files, I realised that this would not work on other PC&#8217;s so I used <strong>%A_ScriptDir%<\/strong> to write the ini files to. I could add it to something like C:\/\/AppData &#8230;&#8230;. and hide the files, but I think I&#8217;d like to be transparent with where I locate the files. <\/p>\n\n\n\n<h3 class=\"alignwide wp-block-heading\">Help File &amp; Context menu<\/h3>\n\n\n\n<p>Thius one below, about 7 minutes in, for context menu<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-4-3 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe title=\"AutoHotKey GUI 5 - Transparent GUIs and Context Menus\" width=\"678\" height=\"509\" data-src=\"https:\/\/www.youtube.com\/embed\/6qRxkWo1fSo?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" data-load-mode=\"1\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>This one is for icons and stuff, handy.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe title=\"AutoHotkeys - Adding Icons to EXE, Context Menus, Tray Menu\" width=\"678\" height=\"381\" data-src=\"https:\/\/www.youtube.com\/embed\/0f3Yhr_cpIM?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" data-load-mode=\"1\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<p> SO what I want in the tray menu are a few items:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Exit app. I want to hide the standard items and so I need to be able to exit the app. <\/li><li>Option on list to Set file name<\/li><li>Option on List to load project file<\/li><li>Option on List to Reassign Keys<\/li><li>Option on list to look at file <\/li><li>Help link- to Help page &#8211; 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<\/li><\/ol>\n\n\n\n<h4 class=\"alignwide wp-block-heading\">Github page<\/h4>\n\n\n\n<p>I want to setup a Github page where the code and notes can be stored and uploaded by others. <\/p>\n\n\n\n<p>This was a bit of a challenge as I&#8217;d forgotten how to sync between a couple of PC&#8217;s and Github (after doing it daily when I was doing covid map last year). <\/p>\n\n\n\n<p>I created a Readme.md file to explain the code and that needs to be updated with the video link now. <\/p>\n\n\n\n<p>Here is the <strong><a href=\"https:\/\/github.com\/drakemax\/Time-Capture\" target=\"_blank\" rel=\"noreferrer noopener\">Github link<\/a><\/strong>. <\/p>\n\n\n\n<h3 class=\"alignwide wp-block-heading\">End comment<\/h3>\n\n\n\n<p>Overall the process took a lot longer than I&#8217;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. <\/p>\n\n\n\n<p>A fun project and a bit of learning. I think I&#8217;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. <\/p>\n\n\n\n<p>I&#8217;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&#8217;ve other things that I want to address first. <\/p>\n\n\n\n<p>If there is not that much response to the app I may let it RIP. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 &#8220;names&#8221; and &#8220;codes&#8221; that are relevant [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":6864,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[204,42],"tags":[],"class_list":["post-6855","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-automation","category-productivity"],"featured_image_src":"https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/04\/2021-03-30-12_11_16-\u23f1\ufe0f-Stopwatch-Emoji-\u2014-Mozilla-Firefox-600x400.jpg","featured_image_src_square":"https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/04\/2021-03-30-12_11_16-\u23f1\ufe0f-Stopwatch-Emoji-\u2014-Mozilla-Firefox-600x600.jpg","author_info":{"display_name":"Max Drake","author_link":"https:\/\/max-drake.cc\/?author=1"},"_links":{"self":[{"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/posts\/6855","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6855"}],"version-history":[{"count":0,"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/posts\/6855\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/media\/6864"}],"wp:attachment":[{"href":"https:\/\/max-drake.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6855"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6855"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6855"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}