Jump to content

Naming convention for _Singleton


 Share

Recommended Posts

Has anyone considered establishing - or suggesting - a naming convention for _Singleton identifier strings? I have a few scripts that use HotKeySet to bind various activities to keypresses, typically including {Esc} to terminate the script. If I run two of these scripts, only one of them gets the key binding and the other then cannot be terminated using the key, which can be pretty inconvenient if it's moving the mouse around clicking on things that it shouldn't be.

So, I should set a _Singleton string for every key that a script binds. What to put in these strings, though? I think it would be nice if everyone used compatible strings for their scripts, so if I download someone else's script that needs to bind {Esc}, it does not conflict with one that I am running.

*Update*: One challenge that this naming convention would face is what the string should be for a binding of the \ key...

Edited by PhilHibbs
Link to comment
Share on other sites

whatever Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

I think you're partially missing the point of singleton and you're asking for something that's never going to happen. The point of _Singleton is to only allow one instance of an application to run. Trying to shoe-horn _Singleton into what you wish is just fraught with headaches. A much simpler (relative term) is to create a file mapping backed by the page file. Keep track of which hotkeys are registered and provide a wrapper around HotKeySet() which can return an error or do whatever whenever an attempt is made to register over an existing hotkey. Since the file mapping can be shared cross-process any script using the wrapper function (which will presumably initialize the file mapping, if necessary) will play nice with each other. It's really not as hard as it sounds. However, convincing others to use it would be. But this is a perfectly simple solution that would work for your own scripts, at least.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...