How to program keyboard combinations?

How can be this controlled in that simulator? Can HIDmacros be used with this application?
PeteDowson
Posts: 9
Joined: 07 Feb 2011, 18:18

Re: How to program keyboard combinations?

Post by PeteDowson » 10 Feb 2011, 15:33

admin wrote: Try macro on Q with script:

Code: Select all

Dim ctrl
ctrl = HIDMacros.GetKeyState(17) and 128
if (ctrl = 0) then
  ' ctrl not pressed
  HIDMacros.SendKeys "%q" 'send Alt+Q
else
  ' ctrl pressed
  HIDMacros.SendKeys "+q" 'send Ctrl+Shift+Q, Ctrl is already down
end if
I just tested with Pspad editor and seems to send what you need.
I've tried it and it doesn't work. The "%q" works okay, but the "+q" (with control down) sends VK_MENU (scan code 38h) instead of VK_SHIFT. I can see this using Spyxx. Strange, eh? Ctrl+Shift+Q direct to the App works okay, so it isn't the keyboard doing odd things.

Regards
Pete

admin
Site Admin
Posts: 735
Joined: 01 Nov 2010, 13:00
Location: Prague, Czech republic
Contact:

Re: How to program keyboard combinations?

Post by admin » 10 Feb 2011, 22:12

PeteDowson wrote:I wonder why the scripting I added, exactly as per your example, actually stopped HIDmacros doing anything for those keypresses at all, then?
I don't have this experience. I even took your hidmacros.xml, just re-mapped your F1-2 macro to my F1 key and it works as it should - execute Shift+F1 action on F1 press and executes Ctrl+Shift+F1 action on Ctrl+F1 press.

I didn't check with Spyxx as I don't have it installed. My tests are done with software that can assign keyboard shortcuts to some actions.

Did you try if scripts are running at all? Do you receive e.g. some key sent by HIDMacros.SendKeys triggered by some simple macro?
PeteDowson wrote:For instance, although I set a script in the GUI I see no way of NOT selecting one of the non-script options too -- so the XML contained both the key sequence to be sent AND the script itself. Is that right? If not, what is, please? There's no radio button saying "use script", so one of the other options is always selected.
Tab sheet does this selection. Once you have Script tab sheet active, then script is executed when macro is fired. If you have Predefined sheet active with some radio button selected then this option is active.
If you want to investigate xml then check Action tag under Macro.
Petr Medek
LUAmacros author

admin
Site Admin
Posts: 735
Joined: 01 Nov 2010, 13:00
Location: Prague, Czech republic
Contact:

Re: How to program keyboard combinations?

Post by admin » 10 Feb 2011, 22:17

PeteDowson wrote:...but the "+q" (with control down) sends VK_MENU (scan code 38h) instead of VK_SHIFT
What about having simple command HIDMacros.SendKeys "^+q" in macro script?
What about sending ^+q as keyboard sequence directly from macro (Predefined - Send Keyboard Sequence)?
Petr Medek
LUAmacros author

PeteDowson
Posts: 9
Joined: 07 Feb 2011, 18:18

Re: How to program keyboard combinations?

Post by PeteDowson » 10 Feb 2011, 23:07

admin wrote:
PeteDowson wrote:I wonder why the scripting I added, exactly as per your example, actually stopped HIDmacros doing anything for those keypresses at all, then?
I don't have this experience. I even took your hidmacros.xml, just re-mapped your F1-2 macro to my F1 key and it works as it should - execute Shift+F1 action on F1 press and executes Ctrl+Shift+F1 action on Ctrl+F1 press.
Hmm. Very strange then.
Did you try if scripts are running at all? Do you receive e.g. some key sent by HIDMacros.SendKeys triggered by some simple macro?
Aren't these about as simple as you can get? F1 -> Shift+F1, but nothing?
PeteDowson wrote:For instance, although I set a script in the GUI I see no way of NOT selecting one of the non-script options too -- so the XML contained both the key sequence to be sent AND the script itself. Is that right? If not, what is, please? There's no radio button saying "use script", so one of the other options is always selected.
Tab sheet does this selection. Once you have Script tab sheet active, then script is executed when macro is fired. If you have Predefined sheet active with some radio button selected then this option is active.
Sorry, I don't quite understand this. Are you simply saying the radio button selection is ignored if there's any text at all entered into the script tab?
What about having simple command HIDMacros.SendKeys "^+q" in macro script?
What about sending ^+q as keyboard sequence directly from macro (Predefined - Send Keyboard Sequence)?
You mean just to see if they get sent correctly? I'll try that now ...

... those examples work fine.
I've just discovered .. VK_MENU is 'ALT'!!! So % == VK_MENU.

So, now I need to work out why the script with %q in the one case but +q in the case where CTRL is pressed sent ALT q in both cases. It's as if the script wasn't processed, because the %q was the radio-buttoned choice in the predefined tab.

Regards
Pete

admin
Site Admin
Posts: 735
Joined: 01 Nov 2010, 13:00
Location: Prague, Czech republic
Contact:

Re: How to program keyboard combinations?

Post by admin » 11 Feb 2011, 08:41

PeteDowson wrote:Are you simply saying the radio button selection is ignored if there's any text at all entered into the script tab?
No. You have 2 tab sheets in macro definition: Predefined and Scripted. If you switch to Scripted sheet then you choose that script will be executed for this macro. If you switch to Predefined sheet and choose some radio option, then this option is used for macro. You can see this selection is stored when you're clicking on defined macros in left column. Predefined/Scripted sheets are selected for each macro just as you left them. So if you want to have macro with script, you must stay on Scripted tab sheet when you define the macro. Don't switch back to Predefined sheet.

BTW if you're not sure if script is executed, I suggest you put HIDMacros.Debug command into your script. It has one string parametr so you can use something like:

Code: Select all

HIDMacros.Debug "Sending F1"
This will do 2 things:
1) send the string via OutputDebugString API call so it can be seen e.g. in DebugView utility from Sysinternals
2) the string is written into HIDMacros error log so you can see the output in Script tools - Error log tab sheet

Hope it helps with your experiments.
Petr Medek
LUAmacros author

PeteDowson
Posts: 9
Joined: 07 Feb 2011, 18:18

Re: How to program keyboard combinations?

Post by PeteDowson » 11 Feb 2011, 10:31

admin wrote:
PeteDowson wrote:You can see this selection is stored when you're clicking on defined macros in left column. Predefined/Scripted sheets are selected for each macro just as you left them. So if you want to have macro with script, you must stay on Scripted tab sheet when you define the macro. Don't switch back to Predefined sheet.
Oh, right. I see! I'll check this.
BTW if you're not sure if script is executed, I suggest you put HIDMacros.Debug command into your script. It has one string parametr so you can use something like:

Code: Select all

HIDMacros.Debug "Sending F1"
This will do 2 things:
1) send the string via OutputDebugString API call so it can be seen e.g. in DebugView utility from Sysinternals
2) the string is written into HIDMacros error log so you can see the output in Script tools - Error log tab sheet
Thanks! Wil do.

Regards
Pete

angelaametz
Posts: 1
Joined: 19 Jun 2017, 15:04

Re: How to program keyboard combinations?

Post by angelaametz » 19 Jun 2017, 15:17

I spent the whole day doing it. Many thanks to all who took an active part in resolving this issue. I did it to adjust the system for me. Now I installed this player https://yumdownload.com/gom-player. Now I can do a lot of interesting things with the help of hot keys and this software. I advise all lovers to watch movies.

Post Reply