Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

User-defined Dynamic Hotkeys


  • Please log in to reply
34 replies to this topic
Newbie007
  • Members
  • 82 posts
  • Last active: Sep 30 2011 03:12 PM
  • Joined: 01 Dec 2010
can you post only code, with which all the hotkeys (gui) would able to have that special keys (space, etc)

jaco0646
  • Moderators
  • 3165 posts
  • Last active: Apr 01 2014 01:46 AM
  • Joined: 07 Oct 2006
If you want to edit example #4, the code is pretty modular. You can take out the validate, check, and set functions if you don't want them. Edit: you'll probably want to keep the first three lines of validate, to backup each hotkey in memory.

Newbie007
  • Members
  • 82 posts
  • Last active: Sep 30 2011 03:12 PM
  • Joined: 01 Dec 2010

If you want to edit example #4, the code is pretty modular. You can take out the validate, check, and set functions if you don't want them. Edit: you'll probably want to keep the first three lines of validate, to backup each hotkey in memory.

im really newbie. plz if you have free 2 min, post some stuff, so all hotkeys control declared will be able to receive space, etc.
I dont need validate, check, only want gui control to allow space, Lwin, Rwin, RCtrl, Rshift, tab, mousewheelup, mousewheeldown, mbutoon.

iDrug
  • Members
  • 389 posts
  • Last active: Oct 11 2015 09:24 PM
  • Joined: 13 Oct 2009
bugreport about example 4:
1. This happens sometimes: it throws errors when trying to use letters (without any modifiers) as hotkeys.
2. it doesn't let you choose a hotkey that consists only of modifiers, like ctrl+alt
3. it doesn't let you choose a hotkey that uses 2 non-modifiers, like Space+1 or a+b. Why can't I use an a+b hotkey if I press b not AFTER a, but SIMULTANEOUSLY to it?

iDrug
  • Members
  • 389 posts
  • Last active: Oct 11 2015 09:24 PM
  • Joined: 13 Oct 2009
feature request: is it possible to store the hotkey settings inside the script? I don't want to have any external files for that.

  • Guests
  • Last active:
  • Joined: --

feature request: is it possible to store the hotkey settings inside the script? I don't want to have any external files for that.

Look at the INI example, replace Hotkeys.ini with %A_ScriptFullPath% and add this somewhere in your script, I suggest bottom.
/*
[Hotkeys]




*/
Now your hotkeys will be stored IN your scripts sourcecode. Doesn't work with compiled script of course.

iDrug
  • Members
  • 389 posts
  • Last active: Oct 11 2015 09:24 PM
  • Joined: 13 Oct 2009
Thanks for the tip, but this:

Now your hotkeys will be stored IN your scripts sourcecode. Doesn't work with compiled script of course.

kills the whole idea. I would like to share my scripts with others and I want these scripts to work without AHK installed.

  • Guests
  • Last active:
  • Joined: --
AHK doesn't have to be installed: <!-- m -->http://www.autohotke... ... ortability<!-- m -->
Whats so bad about ini anyway?

iDrug
  • Members
  • 389 posts
  • Last active: Oct 11 2015 09:24 PM
  • Joined: 13 Oct 2009
It doesn't have to be installed, but it have to be present, which makes almost no difference for me. It's easier to distribute separate working scripts/utils/programs than distributing pairs of them.
And ini file is bad, cause it's a separate file: most of all I like portability and I don't like when a small util that could store it's own settings inside itself - uses some external files for that purpose.

nimda
  • Members
  • 4368 posts
  • Last active: Aug 09 2015 02:36 AM
  • Joined: 26 Dec 2010
iDrug, stop spamming this question everywhere. I answered your Ask for Help post :roll:

iDrug
  • Members
  • 389 posts
  • Last active: Oct 11 2015 09:24 PM
  • Joined: 13 Oct 2009
New question: in example 4 what is the name of the variable that 1st hotkey gets stored to?

  • Guests
  • Last active:
  • Joined: --

It's easier to distribute separate working scripts/utils/programs than distributing pairs of them.


You do know that the ini's are created by the exe's on the users machines when needed? They're supposed to be for custom settings for that user, so why would you distribute the ini's along with the apps to start off with? Other people likely aren't interested in your custom settings.

Just put the default settings in the script.

You keep arguing as if AHK is somehow unusual or deficient in this but it's not, this is the norm.

iDrug
  • Members
  • 389 posts
  • Last active: Oct 11 2015 09:24 PM
  • Joined: 13 Oct 2009

It's easier to distribute separate working scripts/utils/programs than distributing pairs of them.


You do know that the ini's are created by the exe's on the users machines when needed?

Yes I do.

They're supposed to be for custom settings for that user, so why would you distribute the ini's along with the apps to start off with? Other people likely aren't interested in your custom settings.

Usually I distribute it across different machines for myself.
+ the only custom setting is a hotkey for 1 action. I'd better change it to some pretty common hotkey before distributing, than making script create extra files.

Just put the default settings in the script.

You keep arguing as if AHK is somehow unusual or deficient in this but it's not, this is the norm.

You keep talking with almost a religious fanaticism. I said I didn't like the "norm" ad would like to have things the other way. And instead of helping me writing the script to work it that way - you try to convince me that it's a bad way.
I do not care what it's usual for you or anyone else. I do not care if what I ask seems impractical for you or anyone else.
I do not like extra files, when it's possible to avoid them.
I also do not like soft that writes to windows registry (the only acceptable exclusion for me is file associations).

evilc
  • Members
  • 340 posts
  • Last active: Oct 27 2015 11:07 PM
  • Joined: 17 Nov 2005

An update to this old (But useful) thread:

I have refined the technique somewhat, with the following improvements:

  • The Hotkey box only captures unmodified keys
  • Modifiers (Ctrl, Shift, Alt) are set by checkboxes
  • Support for mouse buttons via a dropdown.
  • Support for modified mouse buttons (eg CTRL+LButton)
  • Profile support with Load/Save/Add/Delete/Duplicate functionality.
  • "Program Mode" added. When in program mode, all hotkeys are disabled (Prevents hotkeys triggering themselves etc)
  • Fixed bug stopping you from changing a binding properly (Old code did not delete previous binding)
  • Tabbed GUI layout giving the script writer a place to display macro-specific settings.
  • Both key up and key down events triggered for all buttons except MouseWheel U/D/L/R which only sees key down
  • Improved INI handling - options set to default setting are not stored in the INI. If you set an item to the default option, the entry is removed from the INI

https://github.com/e...Dynamic-Hotkeys

 

If you have comments, suggestions, improvements etc please let me know or fork me!



JnLLnd
  • Members
  • 193 posts
  • Last active: Jul 23 2015 02:15 AM
  • Joined: 30 Dec 2007
I've been more lucky than jaco0646 when he started this script a while ago because I found in this thread a lot of info on the "Gui, Add, Hotkey" command. Based on his work and the work of evilc, I wrote my own version that define hotkeys in a loop and read/save them to an .ini file. I hope it can help.

I posted this script on the new AHK forum at this address: http://ahkscript.org...c.php?f=6&t=860

Thanks!