Sign in to follow this  
Followers 0
mark2004

Setting Hotkey to run script

7 posts in this topic

I would like to be able to attach a hotkey to a particular script so that pressing

the key executes the script. I read over the info for the "HotKeySet" function but

this assigns a hotkey to a function within a given script. I want the hotkey to run

the entire script. Any ideas??

Mark

Share this post


Link to post
Share on other sites



Sure, use this to start your script. It will basically wait for the keypress, and then start the function Main().

HotKeySet("!a", "Main") ;wait for ALT-a keystroke, then go to Main()
While 1 ;loop forever to wait for the keypress
  Sleep(100) ;no need to kill the CPU
WEnd

Func Main()
  HotKeySet("!a") ;remove the hotkey so we don't jump around once we have started
 ;you start your script here
EndFunc

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

well, I'd prefer not to have a script running continuously in the background. Also, I would like the hotkey to be available at all times from anywhere within the operating system....

picky bastard aren't I......

Share this post


Link to post
Share on other sites

well, I'd prefer not to have a script running continuously in the background.

If the script stops, any hotkeys assigned from within that script will no longer work. You need the script to be active if you want to use the hotkey. Having it running isn't hard on the CPU at all because it's waiting 100 ms before it loops. You can increase this number to be even eaisier on the CPU if you'd like.

Also, I would like the hotkey to be available at all times from anywhere within the operating system

That's the way a hotkey works :D

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

Create a shortcut to the script, right click the shortcut, have a look at the properties. I'm sure you can see the pertinent option from there.

Share this post


Link to post
Share on other sites

thanks. that's what I was hoping was possible.

Share this post


Link to post
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
Sign in to follow this  
Followers 0