Skip to content

Commit 7a05300

Browse files
committed
fix: make modifierKeys case-insensitive
1 parent 5da452f commit 7a05300

File tree

1 file changed

+27
-24
lines changed

1 file changed

+27
-24
lines changed

lib/commands/extension.ts

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -414,22 +414,23 @@ export async function executeClick(this: NovaWindowsDriver, clickArgs: {
414414
};
415415
const mouseButton: number = clickTypeToButtonMapping[button];
416416

417+
const processesModifierKeys = Array.isArray(modifierKeys) ? modifierKeys : [modifierKeys];
417418
await mouseMoveAbsolute(pos[0], pos[1], 0);
418419
for (let i = 0; i < times; i++) {
419420
if (i !== 0) {
420421
await sleep(interClickDelayMs);
421422
}
422423

423-
if (modifierKeys.includes('ctrl')) {
424+
if (processesModifierKeys.some((key) => key.toLowerCase() === 'ctrl')) {
424425
keyDown(Key.CONTROL);
425426
}
426-
if (modifierKeys.includes('alt')) {
427+
if (processesModifierKeys.some((key) => key.toLowerCase() === 'alt')) {
427428
keyDown(Key.ALT);
428429
}
429-
if (modifierKeys.includes('shift')) {
430+
if (processesModifierKeys.some((key) => key.toLowerCase() === 'shift')) {
430431
keyDown(Key.SHIFT);
431432
}
432-
if (modifierKeys.includes('win')) {
433+
if (processesModifierKeys.some((key) => key.toLowerCase() === 'win')) {
433434
keyDown(Key.META);
434435
}
435436

@@ -439,16 +440,16 @@ export async function executeClick(this: NovaWindowsDriver, clickArgs: {
439440
}
440441
mouseUp(mouseButton);
441442

442-
if (modifierKeys.includes('ctrl')) {
443+
if (processesModifierKeys.some((key) => key.toLowerCase() === 'ctrl')) {
443444
keyUp(Key.CONTROL);
444445
}
445-
if (modifierKeys.includes('alt')) {
446+
if (processesModifierKeys.some((key) => key.toLowerCase() === 'alt')) {
446447
keyUp(Key.ALT);
447448
}
448-
if (modifierKeys.includes('shift')) {
449+
if (processesModifierKeys.some((key) => key.toLowerCase() === 'shift')) {
449450
keyUp(Key.SHIFT);
450451
}
451-
if (modifierKeys.includes('win')) {
452+
if (processesModifierKeys.some((key) => key.toLowerCase() === 'win')) {
452453
keyUp(Key.META);
453454
}
454455
}
@@ -493,6 +494,7 @@ export async function executeHover(this: NovaWindowsDriver, hoverArgs: {
493494
throw new errors.InvalidArgumentError('Both endX and endY must be provided.');
494495
}
495496

497+
const processesModifierKeys = Array.isArray(modifierKeys) ? modifierKeys : [modifierKeys];
496498
let startPos: [number, number];
497499
if (startElementId) {
498500
if (await this.sendPowerShellCommand(/* ps1 */ `$null -eq ${new FoundAutomationElement(startElementId).toString()}`)) {
@@ -534,31 +536,31 @@ export async function executeHover(this: NovaWindowsDriver, hoverArgs: {
534536

535537
await mouseMoveAbsolute(startPos[0], startPos[1], 0);
536538

537-
if (modifierKeys.includes('ctrl')) {
539+
if (processesModifierKeys.some((key) => key.toLowerCase() === 'ctrl')) {
538540
keyDown(Key.CONTROL);
539541
}
540-
if (modifierKeys.includes('alt')) {
542+
if (processesModifierKeys.some((key) => key.toLowerCase() === 'alt')) {
541543
keyDown(Key.ALT);
542544
}
543-
if (modifierKeys.includes('shift')) {
545+
if (processesModifierKeys.some((key) => key.toLowerCase() === 'shift')) {
544546
keyDown(Key.SHIFT);
545547
}
546-
if (modifierKeys.includes('win')) {
548+
if (processesModifierKeys.some((key) => key.toLowerCase() === 'win')) {
547549
keyDown(Key.META);
548550
}
549551

550552
await mouseMoveAbsolute(endPos[0], endPos[1], durationMs, this.caps.smoothPointerMove);
551553

552-
if (modifierKeys.includes('ctrl')) {
554+
if (processesModifierKeys.some((key) => key.toLowerCase() === 'ctrl')) {
553555
keyUp(Key.CONTROL);
554556
}
555-
if (modifierKeys.includes('alt')) {
557+
if (processesModifierKeys.some((key) => key.toLowerCase() === 'alt')) {
556558
keyUp(Key.ALT);
557559
}
558-
if (modifierKeys.includes('shift')) {
560+
if (processesModifierKeys.some((key) => key.toLowerCase() === 'shift')) {
559561
keyUp(Key.SHIFT);
560562
}
561-
if (modifierKeys.includes('win')) {
563+
if (processesModifierKeys.some((key) => key.toLowerCase() === 'win')) {
562564
keyUp(Key.META);
563565
}
564566
}
@@ -586,6 +588,7 @@ export async function executeScroll(this: NovaWindowsDriver, scrollArgs: {
586588
throw new errors.InvalidArgumentError('Both x and y must be provided.');
587589
}
588590

591+
const processesModifierKeys = Array.isArray(modifierKeys) ? modifierKeys : [modifierKeys];
589592
let pos: [number, number];
590593
if (elementId) {
591594
if (await this.sendPowerShellCommand(/* ps1 */ `$null -eq ${new FoundAutomationElement(elementId).toString()}`)) {
@@ -607,31 +610,31 @@ export async function executeScroll(this: NovaWindowsDriver, scrollArgs: {
607610

608611
await mouseMoveAbsolute(pos[0], pos[1], 0);
609612

610-
if (modifierKeys.includes('ctrl')) {
613+
if (processesModifierKeys.some((key) => key.toLowerCase() === 'ctrl')) {
611614
keyDown(Key.CONTROL);
612615
}
613-
if (modifierKeys.includes('alt')) {
616+
if (processesModifierKeys.some((key) => key.toLowerCase() === 'alt')) {
614617
keyDown(Key.ALT);
615618
}
616-
if (modifierKeys.includes('shift')) {
619+
if (processesModifierKeys.some((key) => key.toLowerCase() === 'shift')) {
617620
keyDown(Key.SHIFT);
618621
}
619-
if (modifierKeys.includes('win')) {
622+
if (processesModifierKeys.some((key) => key.toLowerCase() === 'win')) {
620623
keyDown(Key.META);
621624
}
622625

623626
mouseScroll(deltaX ?? 0, deltaY ?? 0);
624627

625-
if (modifierKeys.includes('ctrl')) {
628+
if (processesModifierKeys.some((key) => key.toLowerCase() === 'ctrl')) {
626629
keyUp(Key.CONTROL);
627630
}
628-
if (modifierKeys.includes('alt')) {
631+
if (processesModifierKeys.some((key) => key.toLowerCase() === 'alt')) {
629632
keyUp(Key.ALT);
630633
}
631-
if (modifierKeys.includes('shift')) {
634+
if (processesModifierKeys.some((key) => key.toLowerCase() === 'shift')) {
632635
keyUp(Key.SHIFT);
633636
}
634-
if (modifierKeys.includes('win')) {
637+
if (processesModifierKeys.some((key) => key.toLowerCase() === 'win')) {
635638
keyUp(Key.META);
636639
}
637640
}

0 commit comments

Comments
 (0)