Fix: WindowsACI.hotkey() splitting key names into characters#203
Open
iamprakashs wants to merge 1 commit into
Open
Fix: WindowsACI.hotkey() splitting key names into characters#203iamprakashs wants to merge 1 commit into
iamprakashs wants to merge 1 commit into
Conversation
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>
Author
There was a problem hiding this comment.
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 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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 thekeysparameter is always a list:Changes
gui_agents/s1/aci/WindowsOSACI.py- Added type check inhotkey()methodtests/test_windows_aci.py- Comprehensive unit tests including:'enter')['enter'])['alt', 'tab'])Testing
Created unit tests that verify:
'enter'work correctly['enter']continue to work['alt', 'tab']workAll tests will run in CI.
Made with Cursor