Define hotkeys via script possible?

Is there currently a way to define Hotkeys in a script? I'd like to click a button in a script dialog by pressing something like ctrl+a. I found the SetQualifiers method but this doesn't seem to work in this context.

Try putting & before the letter in the button's label.

For example, if the button label is something like Add or Cat, change it to &Add or C&at, and ctrl+a will usually then activate it.

That's what I did but it's not enough. Sorry, I gave a bad example. What I really want to do (for abr :slight_smile: ) is press a hotkey to execute Show VIEWERCMD zoom,reset and toggle the focus to the viewer (my other request), press another hotkey and toggle the focus back to the dialog.

Do you mean it doesn't work, or you want something slightly different like a hotkey without a (visible) button?

You could probably position the button so it's outside of the visible window, although it would be a little odd as you could still tab to it, but not see it or know when it was active.

What I want is a hotkey without a button. The &Add thing works.

We'll add this in the next update.

That's great! Thank you.

Thanks for implementing this.
How is the syntax to test if a specific Hotkey named "apply" was pressed?

Your message loop will get a "hotkey" event and the Msg.control property will equal "apply".

Got it. Thanks for the quick reply.

...but how do I click a button via hotkey? I couldn't find anything working for button controls.

Assuming you have something that runs one of your functions when the button is clicked, you run the same function when the hotkey is pushed.

Got it working after re-arranging parts of my script, thanks.
There's one issue: I applied a hotkey to change the value of a combobox which works so far but the message loop doesn't notice the selchange event which makes the hotkey useless. I tried with setting the focus to the control but it didn't work.

Sometimes controls only fire change events for changes made by the user. (This is often a good thing as it stops your code getting into an endless feedback loop by triggering changes which trigger events which trigger more changes.)

Unfortunately, Windows isn't entirely consistent about this, so some controls/changes do trigger events and others don't.

Where they don't, but you need them to, you would normally call your own function after making the change if you need to process it the same as if the user made the change.

[quote]Where they don't, but you need them to, you would normally call your own function after making the change if you need to process it the same as if the user made the change.[/quote]I'm afraid that's beyond my scripting skills. With my current functions I couldn't find a good solution but it's not really essential. The buttons and a checkbox are working fine with a hotkey.

I'm sure it's not :slight_smile:

Thank you for the compliment but at the moment I'm clueless. Please give me a hint (verbose if possible). :slight_smile:

If you have something like (psuedo-code):

<message loop> get message if message = "event" then do stuff do stuff do stuff end if <end message loop>

You would re-factor it like:

<message loop> get message if message = "event" then call function to do stuff end if <end message loop>

And then have a separate function which implements the "do stuff" code. This lets you call that "do stuff" function from other parts of your script - e.g. when the hotkey is pressed.

In terms of VBScript, you can define functions like this:

Function MyFunction(parameter, parameter, parameter) ' do stuff MyFunction = True ' return value End Function

And then you could call result = MyFunction(1, 2, 3) (obviously passing it whatever arguments you actually need).

Ok, so far that's not new for me. My question is what to do to wake up that sleeping control. I tried several things but the only thing that worked was select next item/select previous item which naturally causes an ugly flickering. I don't want to use AutoHotkey to "process it the same as if the user made the change".

I don't understand your question sorry.