Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
string to keycode (keypress)
Sorry for this really simple question, but I couldn't find it in the help section 'key'
If I put ALT + F8 in a string "AF8" how do I translate it to a hotkey press (which also works in compiled exe).

Function Function12
Copy      Help
str s="AF8" ;; [ALT] + [F8]

key s
key (s)
key (F"{s}")

;; ... ?

The goal is to use it in a dialog where the user can input a key press combination in an inputfield.
AF8, = ALT+F8
QM2 can't do it very easily.
To convert simple strings to virtual-key codes, can be used function QmKeyCodeToVK. Then function SendInput.
Or use C# SendKeys. But its keys syntax is different. Reference.

Function CSharpSendKeys
Copy      Help
function $keys

;Sends keys specified in string.
;Calls .NET function SendKeys.SendWait.
;Syntax reference: <google>C# SendKeys.Send</google>.

;CSharpSendKeys "^a" ;;Ctrl+A

opt noerrorshere 1
CsScript x.AddCode("")
x.Call("Class1.Key" keys)

//C# code
using System;
using System.Windows.Forms;

public class Class1
public static void Key(string keys)
Ok! Thank you!!!

Forum Jump:

Users browsing this thread: 1 Guest(s)