globalmousekeyhook
globalmousekeyhook copied to clipboard
InvalidCastExpression Using Example Creating Dictionary<Sequence,Action>
Following the example I'm creating a Dictionary<Sequence,Action> like this:
ShowMainWindowSequence = Sequence.FromString("Control+Shift+D"); HideMainWindowSequence = Sequence.FromString("Escape"); var assignment = new Dictionary<Sequence, Action>{ {ShowMainWindowSequence, ()=>Console.WriteLine("No!")}, {HideMainWindowSequence, ()=>Console.WriteLine("rename2")} };
Then receive the following error during runtime:
System.InvalidCastException: 'Unable to cast object of type 'Gma.System.MouseKeyHook.Sequence' to type 'Gma.System.MouseKeyHook.Combination'.'
Those variables are definitely Sequences and not Combinations so I'm pretty stumped at what the issue is, any idea? A new bug possibly?
I think I figured out the issue its because it uses single combinations but the example says that's ok so maybe that's a bug? Great library though, its a huge help
I am getting the same error. When the loop goes to 2
var sequences = new Dictionary<Sequence, Action>(); for (int i = 1; i <= 1; i++) { for (int j = 0; j <= 9; j++) { int bufferIndex = (i * 10) + j; sequences.Add(Sequence.FromString($"Control + D{i}, D{j}"), () => ActionSelectBuffer(bufferIndex.ToString())); } }