Jump to content

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

HParse - Standard to AutoHotkey's hotkey conversion function


  • Please log in to reply
30 replies to this topic
A v i
  • Members
  • 1323 posts
  • Last active: Nov 14 2015 06:56 PM
  • Joined: 30 Jan 2013

Aim -

Convert user shortcuts to autohotkey hotkeys reliably and Vice versa
Like convert (Ctrl + Alt + p) to (^!p) and Vice versa
Recommended - Just see examples to see what it can do.

Use -
The best use can be in ini's OR custom Hotkey edit control that eliminates limitations of the limited ahk hotkey control

 

Features -

  • The function handles spelling errors from users and tries to return the correct ahk hotkey for the corresponding shortcut as far as possible.
  • It can differentiate between Autohotkey hotkey (^!x) and shortcuts (Ctrl+Alt+x) and returns the correct value always.
  • Can convert autohotkey shortcut back to user shortcut using Hparse_rev() func
  • It can manage totally invalid user shortcuts sent to it simply by eliminating the invalid part of the shortcut
  • You can enable/disable [RemoveInvaild] param if you want. Enabling (default) manages invalid parts by removing them, Disabling makes the return value blank when an invalid part in shortcut is occured. This blank return can be checked and used further to perform required measures.
  • If possible the returned hotkey is tried to be kept in the standard without "ampersand" (&) format. If not possible it is returned in the correct (&) format. See the EXAMPLES below for more details.
  • Standard User Shortcuts are by default meant to be separated by either the plus '+' or the dash '-' . eg -- Control + Alt + S , Control - S will work.
  • User shortcut(s) such as (X + Control) will be converted to (^x) and not (x^) via the [ManageOrder] Param which is enabled by default
  • Shortcuts endings in modifiers are auto-detected and returned accordingly. eg -> (Control + Alt) gives ^Alt and not ^!
  • No RegEx, so faster than what it should be.
  • Keys are arranged a/c popularity for maximum speed of the function.
  • Supports all Autohotkey keys including Joystick Keys.

Examples (in a gist) - (Please go-through)

 

DOWNLOAD .ahk

See a Gui hotkey-edit control implementation of Hparse()


Now a CS Undergrad. | My WebsiteAutohotkey Scripts | Softwares

Telegram me : @aviaryan


CodeEater
  • Members
  • 83 posts
  • Last active: Jun 06 2013 03:42 PM
  • Joined: 17 Jun 2012

Hi, A V I

Your function is great!

Hope to see the Parse in in reverse order

 

I used to use those functions:

Spoiler

 



A v i
  • Members
  • 1323 posts
  • Last active: Nov 14 2015 06:56 PM
  • Joined: 30 Jan 2013

Thanks CodeEatergrin.png

Now, you can be assured against spelling mistakes too. You didnt mention that point.confused.png  (Contrl , too works)

 

I will update it soon to include all the keys from the key list in the help file.


Now a CS Undergrad. | My WebsiteAutohotkey Scripts | Softwares

Telegram me : @aviaryan


CodeEater
  • Members
  • 83 posts
  • Last active: Jun 06 2013 03:42 PM
  • Joined: 17 Jun 2012

ohh. I have to say that the way you check spelling mistakes make me impressed!

I also bookmarked your function for future use. ^^



A v i
  • Members
  • 1323 posts
  • Last active: Nov 14 2015 06:56 PM
  • Joined: 30 Jan 2013

Thanks Again!

 

UPDATES (First Revision) :- 

 

•Added more keys (Numpad, Function)

•Fixed a bug when using Function keys in the function
 
 
 
I will add JoyStick keys later, the reason being they do not work with (^!+#) symbols, so I will have to develop an exception for them. Need some timewink.png

Now a CS Undergrad. | My WebsiteAutohotkey Scripts | Softwares

Telegram me : @aviaryan


A v i
  • Members
  • 1323 posts
  • Last active: Nov 14 2015 06:56 PM
  • Joined: 30 Jan 2013

Bump.

 

Can someone tell me how it's working, please ....


Now a CS Undergrad. | My WebsiteAutohotkey Scripts | Softwares

Telegram me : @aviaryan


A v i
  • Members
  • 1323 posts
  • Last active: Nov 14 2015 06:56 PM
  • Joined: 30 Jan 2013

UPDATES:

Revision 2

 

Added all the remaining keys including Joystick keys

•Fixed a last list item bug
•Improved algorithm for better speeds.

Now a CS Undergrad. | My WebsiteAutohotkey Scripts | Softwares

Telegram me : @aviaryan


MSD
  • Members
  • 2 posts
  • Last active: May 09 2013 08:41 AM
  • Joined: 04 May 2013

very very useful . now i can safly switch to inis

thank youtongue.png



A v i
  • Members
  • 1323 posts
  • Last active: Nov 14 2015 06:56 PM
  • Joined: 30 Jan 2013

Thank you for replying and m glad you find it useful.

 

Please feel free to report bugs and/or give suggestions.


Now a CS Undergrad. | My WebsiteAutohotkey Scripts | Softwares

Telegram me : @aviaryan


DataLife
  • Members
  • 1022 posts
  • Last active: Nov 27 2015 01:09 AM
  • Joined: 27 Apr 2008

I haven't the time at the moment to test Hparse, but could I use it in the following way.

 

Read a hotkey from an INI, run Hparse on it, if it returns blank then it is an invalid hotkey?

 

If so, this is great, as an ugly error occurs if the hotkey is invalid and this could prevent that.

 

thanks


Check out my scripts.  (MyIpChanger) (XPSnap) (SavePictureAs) All my scripts are tested on Windows 7, AutoHotkey 32 bit Ansi unless otherwise stated.

A v i
  • Members
  • 1323 posts
  • Last active: Nov 14 2015 06:56 PM
  • Joined: 30 Jan 2013

Read a hotkey from an INI, run Hparse on it, if it returns blank then it is an invalid hotkey?

If so, this is great, as an ugly error occurs if the hotkey is invalid and this could prevent that.

Absolutely right . 

It will first check the ini hotkey for spelling errors and try to bypass them, then check for syntax errors and mend them if possible and then finally return it to you.

In rare cases will you have it give the <blank> return . So, ya it makes the INI more dependable .  


Now a CS Undergrad. | My WebsiteAutohotkey Scripts | Softwares

Telegram me : @aviaryan


DataLife
  • Members
  • 1022 posts
  • Last active: Nov 27 2015 01:09 AM
  • Joined: 27 Apr 2008

great, I will try it tonight. I use GUIs to get and store user settings in an ini including Hotkeys using the Hotkey command. So the hotkeys will always be valid unless someone messes with the ini or the ini becomes corrupt for whatever reason. I like to be able to validate anything I read from the ini.

 

So, this script will be perfect to validate the hotkeys read from the ini.

 

thanks


Check out my scripts.  (MyIpChanger) (XPSnap) (SavePictureAs) All my scripts are tested on Windows 7, AutoHotkey 32 bit Ansi unless otherwise stated.

A v i
  • Members
  • 1323 posts
  • Last active: Nov 14 2015 06:56 PM
  • Joined: 30 Jan 2013

great, I will try it tonight. I use GUIs to get and store user settings in an ini including Hotkeys using the Hotkey command. So the hotkeys will always be valid unless someone messes with the ini or the ini becomes corrupt for whatever reason. I like to be able to validate anything I read from the ini.

If you use GUIs to transfer data to ini ' s, I think then the script is not for you . 

As you see in examples , it is designed to convert Ctrl + Alt + X to ^!x and not validate ^!x which will be actually saved in ini if you use the Hotkey Control in GUI .

If you are not using the Hotkey control and making user write Ctrl + Alt + X in a text control or so , then it's fine.

 

The main aim of this script is to make ini's secure for those users who dont create GUIs for their applications and make their customers write theit hotkeys in the ini itself.

 

Sorry

 

EDIT :-

The next version [Rev. 3] does offer some hope . It now takes in hotkeys of both [Ctrl + alt +X] AND [^!x] forms . 


Now a CS Undergrad. | My WebsiteAutohotkey Scripts | Softwares

Telegram me : @aviaryan


A v i
  • Members
  • 1323 posts
  • Last active: Nov 14 2015 06:56 PM
  • Joined: 30 Jan 2013

Revision 3

  • Improved [Autohotkey] Modifiers handling . Will accept keys of the form [PageUp & PageDown] and [^!x]
  • Fixed problems with certain keys

Now a CS Undergrad. | My WebsiteAutohotkey Scripts | Softwares

Telegram me : @aviaryan


DataLife
  • Members
  • 1022 posts
  • Last active: Nov 27 2015 01:09 AM
  • Joined: 27 Apr 2008

Revision 3

  • Improved [Autohotkey] Modifiers handling . Will accept keys of the form [PageUp & PageDown] and [^!x]
  • Fixed problems with certain keys


Great, I will try it out as soon as I get some free time.
Check out my scripts.  (MyIpChanger) (XPSnap) (SavePictureAs) All my scripts are tested on Windows 7, AutoHotkey 32 bit Ansi unless otherwise stated.