AcecoolAHK_Framework - Drag&Drop files or exes& my framework loads them for you without need to #include / run manually!

Post your working scripts, libraries and tools
Posts: 37
Joined: 10 Jan 2016, 18:25
Facebook: Acecool
Google: Acecool
GitHub: Acecool

AcecoolAHK_Framework - Drag&Drop files or exes& my framework loads them for you without need to #include / run manually!

15 Dec 2016, 07:07 ... k/overview

This framework is for those of us that want a single environment for multiple scripts, or a way to launch all of our favorite scripts at the click of 1 button... In short you can drag and drop files into the designated folders in the AcecoolAHK_Framework\ directory and when you run AutoHotkey.exe ( which runs Documents\AutoHotkey.ahk )[ you will have had to previously run _assets\_setup\setup.bat in administrator mode for it to generate the Documents\AutoHotkey.ahk file and symbolically linked AcecoolAHK_Framework\libraries to AHK_INSTALL_PATH\Lib ] or framework_launcher.ahk everything will be loaded, dynamically, for you... Simply drag and drop...

It is a simple way to run all of your individual scripts as individually run ahk instances, or for them all to be included under one "banner" / tray-icon ( or a mix of both ).. You can even launch your favorite executables automatically when you launch the framework... ie: Instead of needing to run each script individually or add an include line in your includer file - everything is handled for you.. simply drag'n'drop...

A run-down of what each folder is used for:
  • AcecoolAHK_Framework\_assets\ is an "internal" folder and you'll not likely need to do anything in here other than the initial _setup\setup.bat as admin on each new PC you install this on. You can look at the auto generated files in __load_order_files__\ and change the default template, pre include template section and post include template section from within templates\ ( which simply lets you add your own config, etc.. - I will eventually remove my config from the autoloader\run_framework_base.ahk and move it into the templates folder to make it easier to control.. )
  • AcecoolAHK_Framework\addons_exe\ is a special folder whereby each file you place in here is executed in its own instance similarly to addons_run\ except you can use executables and other "dangerous" file-types in here ( By default and each time you rebuild the inclusion list you'll be asked which files you want to allow -- I will alter this system so once you allow the exe, a hash entry will be made into the configuration file or registry so that you won't have to authorize that file ever again - at least not until it updates / changes ).
  • AcecoolAHK_Framework\addons_run\ All scripts in here are executed as their own AutoHotkey instance; exactly as if you double-clicked each one individually each time the framework loads / is reloaded... I'd recommend forcing single-instance so when you Reload This Script under the Framework Tray Icon, each of these will be reloaded too..
  • AcecoolAHK_Framework\addons_inc\ All scripts in here are INCLUDED into the framework - Useful if it is a small script that doesn't need a tray icon, or anything else special ( such as - display mouse ripple effect when you click mouse buttons or control )
  • AcecoolAHK_Framework\classes\ contains all libraries / classes / etc.. which should be included with the framework - I included a few by default from myself and from others such as Julian Date function by SKAN in order to create a timestamp since Epoch, a math library which moves all math functions into it to make code look cleaner and I added a few helpful math functions too, time library to simplify input / output of time and timestamps, and a configuration library for controlling config.ini ( configuration.SetDefaultValue will only set a key / value if it doesn't exist / configuration.Read/SetValue will read or write a key / value from / to config.ini regardless of whether it exists or not.. On read, if it doesn't exist what is returned is a string: KEY_NOT_FOUND
  • AcecoolAHK_Framework\definitions\ is a folder where you can add your global variables, ENUMeration, CONSTants, etc... This is one of the first inclusion directories and it won't be blocked from running basic code ( and it should be kept this way )
  • AcecoolAHK_Framework\functions\ is a folder where you can put standalone functions which are used in more than one script but there aren't enough of them to create a library for ( I will make a library for all of the string functions, and there will be more, but for now there is String_Safe there and String_Repeat somewhere )
  • AcecoolAHK_Framework\hotkeys\ folder is used for basic hotkey definitions..
  • AcecoolAHK_Framework\libraries\ is symbolically linked from AHK_INSTALL_PATH\Lib\ - this is where all of your #include <xxx> files go...
  • AcecoolAHK_Framework\processes\ is an extra folder where you can place your stand-alone scripts ( or ones that need to piggyback off the framework for functions / config / etc.. ) which are called by a hotkey... For example hotkeys\hotkey_screencapture_current_window__alt_f12.ahk calls processes\process_screenshot_win_and_notification.ahk which captures a screenshot of the active window, creates a clickable toast notification letting you know where it is and the name. On click it will ask if you want to make the screenshot public. If yes or no the screenshot is opened. If yes then the screenshot is moved to your public screenshots directory ( you pick both private and public inside of config.ini ) and a share-link is copied to your clipboard ( if you use DropBox and if you entered your userid in config.ini - note: if you don't use dropbox I will be working on a solution for you soon )...
NOTE: All files that are included into the framework have a function that can be used within ( examples inside most of the included hotkey files ) which is OnInit_<filename>( ) { ... } -- This is so you can have code execute in each individual script instead of setting up a lot of globals inside of definitions, etc... I use it mainly to set up configuration used by each individual hotkey script and so on... Right now the names are not string-protected but that is planned.

I hope this clears things up and makes it easier to understand what it is for ( I will be adding a lot of my own scripts to this such as an application monitor which restarts anything if not running / hung / etc.. and a window management system which is set up like scenes so if all windows are open, they're moved to your preset position so your work-area is always how you want it... and more.. )... Please give it a try and let me know what you think. ... k/overview

Planned: ... tatus=open - and more...
Last edited by Acecool on 25 Dec 2016, 23:02, edited 4 times in total.
-Josh 'Acecool' Moser
I teach various programming languages, game programming, etc... I am also taking on programming jobs as my health allows.
Posts: 37
Joined: 10 Jan 2016, 18:25
Facebook: Acecool
Google: Acecool
GitHub: Acecool

Re: AcecoolAHK_Framework - Drag&Drop files or exes& my framework loads them for you without need to #include / run manua

19 Dec 2016, 11:23

Second post reserved for in the works / planned inclusions....

Planned: Monitor / Window Class to help get Windows unintuitive positions easier ( and so if monitor positions change, etc.. then nothing needs to change in configuation )..

---Original First Post--- Moved here for archive as I am rewriting the readme and how to use / quick-description to let people know what it can be used for...
Pretty straight forward... Drag and drop your ahk files into a useful folder-structure ( which is set up in a certain load-order which may not matter for ahk but the organization is nice ). I just added a few things that lets you run exe files, etc...

Never manually type out an #include again when it comes to running your scripts in an environment... Never manually run your script either.. ( You will still need to include your libraries, but the setup.bat symbolically links it all together so the framework directory sits in a cloud directory of your choice [ best option right now is DropBox unless you want to edit a few files - setup.bat does generate the AutoHotkey.ahk file but there are a few more which need dynamic path support before I'll be done ] so that all of your computers run the same scripts... Run the setup.bat on a new pc after installing AHK and done... Run AutoHotkey.exe and the framework is loaded.

See something new you want to try out? Drag and drop it into the appropriate folder ( addons can work as debug / test area ) and rerun AutoHotkey.exe ( I will add support, once I find the exact way, to be able to dynamically include a file after generating it in the same file which will open the doors for a lot of good - but so far it appears as though the file is cached which is why I do it the way I do it currently )...

If you're like me, you likely have a lot of hotkeys running and some scripts in the background that don't all have their own tray menu. So instead of running each one separately, they've been added to my framework ( I only included a few example scripts in the release but I'll add more later ) so there is one tray icon and all of the other files run within...

Some applications I use I can drop into addons_exe and have the framework run them when it starts. Other scripts that are stand-alone can be dropped into addons_inc or addons_run.. Run will run it in a new instance ( useful for scripts that have their own tray icon, menus, etc.. and are really set up for stand-alone use ) while inc will include the script and it will run with the rest ( I tried mouse ripple effect and it looks good in inc - others work just as well - just drag and drop )...

There are readmes in the folder structure, more information on the overview in addition to the changelog... Take a look and let me know what you think.

The last thing I added was the ability to launch the framework without re-generating the load-order files ( you were able to re-load the script while it was running which did the same thing, but this way you don't have to wait the extra second or 2 that it takes to generate if you haven't added any new files - default message box - choose Yes or tap spacebar when the message box comes up to dive right in - first-launch will auto-generate )... With the EXE folder, it will ask you to confirm each executable ( or whatever file ) if it should be added to the load-list which is another reason why I added the skip regeneration so you don't have to set those up each time you launch... - note you can uncomment one line and comment another ( next to each other ) to allow a blind-allow without any message windows asking if you want to allow a file but.. just in case...
Last edited by Acecool on 25 Dec 2016, 22:30, edited 1 time in total.
-Josh 'Acecool' Moser
I teach various programming languages, game programming, etc... I am also taking on programming jobs as my health allows.
Posts: 156
Joined: 30 Sep 2013, 11:31

Re: AcecoolAHK_Framework - Drag&Drop files or exes& my framework loads them for you without need to #include / run manua

21 Dec 2016, 23:29

Hi Acecool,

You say "Pretty straight forward" but reading your description here or on Github, I still don't know what this is or how it can be used. Could you maybe try to clarify?
Posts: 37
Joined: 10 Jan 2016, 18:25
Facebook: Acecool
Google: Acecool
GitHub: Acecool

Re: AcecoolAHK_Framework - Drag&Drop files or exes& my framework loads them for you without need to #include / run manua

25 Dec 2016, 13:17

Once "installed" all of the folders are dynamically added and utilized - so if you have a hotkey you want to add, you can make a file in hotkeys\ and it will be included the next time you run AutoHotkey.exe or framework_launcher.ahk ( the first time the framework runs, or anytime it runs where the inclusion lists don't exist, the framework will create them.. any subsequent launch you will be asked if you want to run the framework without rebuilding, or not ie rebuild - default answer is yes to simply run it - you can also right click the tray icon and reload this script to update any existing files without any dialogs popping up )

To explain the folder purposes - they're set up to categorize certain aspects of scripts to prevent a blocking call from executing part of a script ( for example if you add a variable above a hotkey in an #include'd file, that variable won't initialize but if you put it into a file in definitions, then it will ).
- _assets\ - This folder contains core elements of scripts to generate autoloader inclusion lists, or those lists, setup files, images and other resources.. Internal and unlikely you'll need to alter or run something in here outside of _setup\setup.bat
- addons_exe\ - This folder contains any type of script or executable that you want to run hen the framework runs ( By default, and you can alter this with config option in next release, you will be asked whether you want to allow the file to run, or not.. if yes it'll be added to the run inclusion list, if not then it is skipped... also in future release you will only have to choose yes per file once and that will be saved in the config.ini file - I will use hash so if the file changes, then you have to choose yes or no again - you can also bypass warnings and have it include all without nagging you )
- addons_inc\ - This folder will #include all scripts here - so if you have a standalone script you want to run without a tray icon ( but have easy access to restart without task manager or whatever ) then you can drop it in here..
- addons_run\ - This folder will use command-prompt to automatically run, as a new instance, each script in here - so if you have a standalone script you want to run with its own icon support, etc... drop it in here and it'll be launched when the framework is launched ( for now there is no checking to see if it already exists so I'd recommend single instance to be enabled for such scripts )
- classes\ - This folder contains libraries or classes / objects to be used in the framework ( such as the configuration library I added, and math, etc.. )
- definitions\ - This folder is for global variables, ENUMeration and CONSTants that the framework should have access to ( In most cases you can have local vars in scripts, or use OnInit_<filename> function to set them up for your scripts - but this folder exists just in case one is needed )
- functions\ - This folder contains files which contain functions... I will make a string library soon for some of the string functions, etc... but standalone functions that have no place elsewhere or are needed in multiple places can be defined here.
- hotkeys\ - This folder is for hotkey files
- libraries\ - Symbolically linked to AHK_INSTALL_PATH\Lib\ so all of your "#include <xxx>" xxx.ahk files will go in here...
- processes\ - Jobs or tasks that are executed from a hotkey ( I added one example which is a screenshot active window process using GDip.. It also creates a clickable Toast notification which asks you whether or not you want to move the screenshot to public screenshots directory or keep it in the private screenshots directory - if you opt not to move it, it is opened. If you opt to move it, it is moved to Dropbox\Public\Screenshots\ and the share-link is automatically copied to your clipboard and the screenshot is opened - you can set the dropbox user id in the config.ini file in the root directory after first launch )..

I hope this helps.... For me, it does because it lets me add all of my portable apps to addons_exe and have them launch when I run the framework ( I still need to add the prevent more than one to open system and hashing system ), and I can have other interesting scripts run with the framework ( such as the script which generates a pulse around your mouse cursor when you click control, or either button in different colors [ majorly useful when using many monitors .. 5 ] ), etc...

ALL included files ( not run ) calls / executes a function if it exists: OnInit_<filename_but_you_have_to_keep_the_name_friendly_for_now>( ){ ... }
You can use this to set up configuration, etc.. some of the example hotkeys I include use this - soon I will add micro-caching to configuration system so it will only read config.ini once per variable per load unless another configuration option is set to allow it to read each time ( as I don't believe AHK automatically caches results )

Example of my config.ini file in the root directory ( created automatically on first launch - you can change any value in here )

Code: Select all

	Author=Josh 'Acecool' Moser
	NUMLOCK_ON=C:\WINDOWS\Media\Speech On.wav
	NUMLOCK_OFF=C:\WINDOWS\Media\Speech Off.wav
	CAPSLOCK_ON=C:\WINDOWS\Media\Speech On.wav
	CAPSLOCK_OFF=C:\WINDOWS\Media\Speech Off.wav
Note: ToggleCapsLockViaShift is a delay in ms for it to toggle - but there is a small issue with the script preventing shift from being seen by anything else and when I use ~ it causes other issues - so this feature isn't enabled at the moment.. it is in the audible_alerts ahk file in hotkeys if you want to play around with it... I also try to keep scripts localized - ie the reason the function is in the hotkey script is because it isn't used anywhere else - whereas String_Safe is ( and I will be adding that to the OnInit_<filename> function calls / checks to make sure no errors pop up if you have a filename with a + or whatever in it... there will be a comment added [ right now only RunFuncIfExists( "name" ) is used - comment may make it easier for some users - or I may make a simple OnInit_function_readme which is autopopulated in the root directory ] to _assets\__load_order_files__\[* excluding run].ahk to show what function name it is trying to call in case you can't figure it out )

Note 2: Seems there may be a slight issue with adding a tab to the beginning of the line.. going to test a few things - but reading it ignores and it detects it fine so I'm not sure why 2 of the same variable ended up there... I'll look into this and post a fix..

Note 3: Example of the Screenshot moved to public directory and then copied link to my clipboard ( I still need to urlencode it ): ... 8_1544.png

Install Insturctions:
Download the source: ... /downloads ( Current as of posting version 0.2.15 : ... )
Extract AcecoolAHK_Framework to your DropBox folder located in C:\Users\<UserName>\DropBox\ ( I still have a bit of work to do to make it fully compatible with all other cloud-based applications - listed below ) so that C:\Users\<UserName>\DropBox\AcecoolAHK_Framework\_assets\_setup\ exists...

Make sure AutoHotkey is installed, then run _assets\_setup\setup.bat in administrator mode ( This will create a new AutoHotkey.ahk script to launch the framework when AutoHotkey.exe is executed and replace the one currently in Documents\ if one exists [ existing will be renamed ], and it will create a symbolic link between AHK_INSTALL_PATH\Lib\ and Dropbox\AcecoolAHK_Framework\libraries\ [ again, if AHK\Lib\ exists, it will be renamed ] ) - note: this will soon be replaced either by an AHK script / gui to make setting up paths easier and if I can't remove the full-paths from the scripts ( unlikely that I won't be able to find some way ) then I will create a template system so all of the scripts that use the full-path will have a bit of code injected into their files ( by replacing a place-holder such as {FULL_PATH} )

To make it compatible with all other cloud-based applications I need to see if SetWorkingDir can accept dynamic paths ( variables which aren't on the #include approved list although I may be able to simply use A_ScriptDir because of how I now make it run ) - there are several files that currently require the full-path ( but as said I am working on removing all of these and looking at other options ):
- Documents\AutoHotkey.ahk ( this file runs when AutoHotkey.exe is launched.. It launches AcecoolAHK_Framework\framework_launcher.ahk which generates the base and full load-order include files and then runs the run_framework_full.ahk file from inside _assets\autoloader\ which loads up the base inclusion lists, and the full inclusion lists [ base is bare minimum such as classes / libraries, functions, definitions and full includes hotkeys and addons on top of base - base exists for scripts that need access to the bare minimum without doubling up on identical hotkeys, etc.. ] )
- framework_launcher.ahk ( Executed by Documents\AutoHotkey.ahk which runs generate base and full, then runs framework full )
- _assets\autoloader\__generate_base__.ahk ( Creates the base inclusion lists located in _assets\__load_order_files__ )
- _assets\autoloader\__generate_full__.ahk ( Creates the full inclusion lists, excluding base, located in _assets\__load_order_files__ )
- _assets\autoloader\run_framework_base.ahk ( Runs the framework in base-only mode for scripts that want access to the classes, functions, etc... without overlapping hotkeys, addons, etc.. )
- _assets\autoloader\run_framework_full.ahk ( runs the full framework with hotkeys, addons, etc.. )

Edit: I forgot I removed the SetWorkingDir from generate base and full files already... The AutoHotkey.ahk one is necessary to point AutoHotkey.exe to load the right script, but from there since the others are executed independently in their respective directory I should be fine using A_ScriptDir - this should clear up everything else and allow other cloud directories to be used ( but the script to capture screenshot won't work - so I'll add configuration for where those should be saved by default, etc.. )

Edit: Version 0.3.17 is now out - 1 step closer to being portable and it removes all connections to forcing you to use DropBox except for the automatically generated file by setup.bat - you can change the path to your cloud directory in that file ( Documents\AutoHotkey.ahk where it was moved / copied to after being generated ) and you won't need to do it anywhere else. You will have to run the framework once to generate the config file and you will want to alter the screenshot private and public folders ( but if you're not using dropbox then the copy public link to clipboard won't work - I'll add options later on for this to either work with different cloud software or to disable auto copy if not using dropbox )...

Edit: Version 0.4.18 out now... A few major improvements and new libraries / classes.. Also an automatically generated copy / paste ready ReadMe_OnInit_base/full.ahk.txt are both generated in the root directory to show the function names to be used for OnInit_<filename>
-Josh 'Acecool' Moser
I teach various programming languages, game programming, etc... I am also taking on programming jobs as my health allows.

Return to “Scripts and Functions”

Who is online

Users browsing this forum: Google [Bot] and 22 guests