0

So I'm using GlobalHotkeys to register my hotkeys. but i want instead of just make a key without being able to change it, so it will be possible to change it from a .txt File. so tried something like that: Code

 using (StreamReader sr = new StreamReader(@"C:\Keys.txt"))
            {
                String line = sr.ReadToEnd();
                ghk = new Hotkeys.GlobalHotkey(Hotkeys.Constants.NOMOD, Keys.Insert, this); }

Now how do i make it read the hotkey that .txt file include ? Need Instead of "Keys.Insert" to be whatever hotkey that inside the text file it's always says: enter image description here

sdhp442
  • 1
  • 2
  • https://stackoverflow.com/questions/12060513/converting-a-string-to-keys-in-c-sharp – Hans Passant Dec 31 '19 at 09:22
  • Tried and it says that: https://puu.sh/EUZ5v/58f4468e52.png – sdhp442 Dec 31 '19 at 09:30
  • It properly recommend TryParse(), not Parse. And you're supposed to put "S" in the text file, not "Keys.S". Do not turn the S key into a hotkey, you break the machine. – Hans Passant Dec 31 '19 at 09:40
  • @HansPassant i figured it out by doing this:https://puu.sh/EUZAS/9a96b0129c.png – sdhp442 Dec 31 '19 at 10:21
  • But now i got this problem: https://puu.sh/EUZCB/45bc1134f1.png with that the program know what key i actually pressed, and i cant put the "key" there – sdhp442 Dec 31 '19 at 10:23

0 Answers0