Skip to content

Fix: WindowsACI.hotkey() splitting key names into characters#203

Open
iamprakashs wants to merge 1 commit into
simular-ai:mainfrom
iamprakashs:fix/hotkey-string-splitting-195
Open

Fix: WindowsACI.hotkey() splitting key names into characters#203
iamprakashs wants to merge 1 commit into
simular-ai:mainfrom
iamprakashs:fix/hotkey-string-splitting-195

Conversation

@iamprakashs

Copy link
Copy Markdown

Summary

Fixes #195 - WindowsACI.hotkey() was splitting single key names like 'enter' into individual characters ('e', 'n', 't', 'e', 'r') when passed as a string instead of a list.

Problem

When calling aci.hotkey('enter') with a string, Python's iteration over the string caused each character to be treated as a separate key, resulting in:

"import pyautogui; pyautogui.hotkey('e', 'n', 't', 'e', 'r', interval=0.5)"

instead of the expected:

"import pyautogui; pyautogui.hotkey('enter', interval=0.5)"

Solution

Added a type check in the hotkey() method to ensure the keys parameter is always a list:

  • If a string is passed, it's wrapped in a list before processing
  • Maintains backward compatibility with list inputs
  • Preserves existing functionality for multi-key combinations

Changes

  • Modified: gui_agents/s1/aci/WindowsOSACI.py - Added type check in hotkey() method
  • Added: tests/test_windows_aci.py - Comprehensive unit tests including:
    • Single key as string ('enter')
    • Single key as list (['enter'])
    • Multiple keys (['alt', 'tab'])
    • Control key normalization
    • Regression test to ensure strings aren't split into characters

Testing

Created unit tests that verify:

  • ✅ String inputs like 'enter' work correctly
  • ✅ List inputs like ['enter'] continue to work
  • ✅ Multi-key combinations like ['alt', 'tab'] work
  • ✅ Control key normalization still functions
  • ✅ No regression: strings don't get split into characters

All tests will run in CI.

Made with Cursor

Fixed bug where hotkey() method splits single key names like 'enter'
into individual characters ('e', 'n', 't', 'e', 'r') when passed as
a string instead of a list.

Changes:
- Added type check to ensure keys parameter is always a list
- If string is passed, wrap it in a list before processing
- Added comprehensive unit tests for various input formats

Fixes simular-ai#195

Co-authored-by: Cursor <cursoragent@cursor.com>
Copilot AI review requested due to automatic review settings July 3, 2026 22:29
@iamprakashs

Copy link
Copy Markdown
Author

Hi @alckasoc, @saa1605, @eric-xw! 👋

I've fixed issue #195 where WindowsACI.hotkey() was splitting key names into individual characters. The fix is minimal and includes comprehensive unit tests.

Would appreciate your review when you have a moment. Thanks!

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug in WindowsACI.hotkey() where passing a single key as a string (e.g. "enter") was incorrectly iterated character-by-character, producing a pyautogui.hotkey('e','n','t','e','r', ...) command instead of a single-key hotkey call.

Changes:

  • Add a string guard in WindowsACI.hotkey() to wrap string inputs into a single-element list before normalization/formatting.
  • Add unit tests covering string vs list inputs, multi-key hotkeys, and control-key normalization.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
gui_agents/s1/aci/WindowsOSACI.py Wraps string keys inputs into a list to prevent accidental per-character splitting.
tests/test_windows_aci.py Adds regression/unit tests validating correct command generation for common hotkey inputs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/test_windows_aci.py
Comment on lines +1 to +9
import unittest
from gui_agents.s1.aci.WindowsOSACI import WindowsACI


class TestWindowsACIHotkey(unittest.TestCase):
def setUp(self):
"""Set up test fixtures"""
self.aci = WindowsACI(top_app_only=True, ocr=False)

Comment on lines 404 to +410
"""Press a hotkey combination
Args:
keys:List[str] the keys to press in combination in a list format (e.g. ['shift', 'c'])
"""
# Ensure keys is a list - if a string is passed, wrap it
if isinstance(keys, str):
keys = [keys]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] WindowsACI.hotkey() splits key names into individual characters

2 participants