Mouse cannot select text with pyautogui #20773

Open
opened 2026-01-31 07:23:37 +00:00 by claunia · 5 comments
Owner

Originally created by @ebundy on GitHub (Nov 6, 2023).

Windows Terminal version

1.17.11461.0

Windows build number

10.0.19045.3570

Other Software

python 3.10, pyautogui 0.9.5 (The exact versions doesn't matter actually)

Steps to reproduce

Install the pyautogui library (The version doesn't matter).
Execute the following code and you have 3 seconds to switch to the terminal and position the cursor on any text.

from time import sleep

import pyautogui
from pyautogui import Point

sleep(3)
pyautogui.click()
pyautogui.mouseDown(button='left')
for i in range(50):
    position: Point = pyautogui.position()
    pyautogui.moveTo(position.x + 4, position.y)
pyautogui.mouseUp(button='left')

Expected Behavior

The text where the cursor is positioned starts to be selected towards the right.
FYI : I tested that code on other terminals like classic windows terminal, Git Bash and WSL2 and the problem doesn't occur.

Actual Behavior

The cursor is positioned at the right place and progress to the right as expected but no selection happens.
ezgif-1-639c7a0728

Originally created by @ebundy on GitHub (Nov 6, 2023). ### Windows Terminal version 1.17.11461.0 ### Windows build number 10.0.19045.3570 ### Other Software python 3.10, pyautogui 0.9.5 (The exact versions doesn't matter actually) ### Steps to reproduce Install the pyautogui library (The version doesn't matter). Execute the following code and you have 3 seconds to switch to the terminal and position the cursor on any text. ``` from time import sleep import pyautogui from pyautogui import Point sleep(3) pyautogui.click() pyautogui.mouseDown(button='left') for i in range(50): position: Point = pyautogui.position() pyautogui.moveTo(position.x + 4, position.y) pyautogui.mouseUp(button='left') ``` ### Expected Behavior The text where the cursor is positioned starts to be selected towards the right. FYI : I tested that code on other terminals like classic windows terminal, Git Bash and WSL2 and the problem doesn't occur. ### Actual Behavior The cursor is positioned at the right place and progress to the right as expected but no selection happens. ![ezgif-1-639c7a0728](https://github.com/microsoft/terminal/assets/15986712/8cc1a893-dc52-46b8-86eb-6526e8cd7435)
claunia added the Issue-BugPriority-3Product-TerminalArea-UserInterface labels 2026-01-31 07:23:38 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Nov 6, 2023):

Here's possibly a dumb question - does it work if the Terminal isn't running as admin1 /? There's typically quite a few protections in place (by Windows itself) that prevent unelevated apps from sending input to elevated ones


  1. Or, the inverse: is pycharm (or whatever's running your pyautogui script) running as admin? ↩︎

@zadjii-msft commented on GitHub (Nov 6, 2023): Here's possibly a dumb question - does it work if the Terminal isn't running as admin[^1]/? There's typically quite a few protections in place (by Windows itself) that prevent unelevated apps from sending input to elevated ones [^1]: Or, the inverse: is pycharm (or whatever's running your `pyautogui` script) running as admin?
Author
Owner

@ebundy commented on GitHub (Nov 6, 2023):

I checked and none of the two applications (Terminal and Pycharm) are running in admin.
I tried to run in admin both and the behavior is the same.
As stated previously, I notice the expected behavior with the classic Windows terminal, Git Bash terminal and WSL2 terminal and that is true in the exact same execution context (no admin running), so I assume that the problem is specific to the (modern) Microsoft Terminal implementation.
If some additional information could be helpful, please tell me what, I would like my best to provide it.
Note : I also tried with the most recent preview build (Microsoft.WindowsTerminalPreview_1.19.2831) but unfortunately the issue persists.

@ebundy commented on GitHub (Nov 6, 2023): I checked and none of the two applications (Terminal and Pycharm) are running in admin. I tried to run in admin both and the behavior is the same. As stated previously, I notice the expected behavior with the classic Windows terminal, Git Bash terminal and WSL2 terminal and that is true in the exact same execution context (no admin running), so I assume that the problem is specific to the (modern) Microsoft Terminal implementation. If some additional information could be helpful, please tell me what, I would like my best to provide it. Note : I also tried with the most recent preview build (Microsoft.WindowsTerminalPreview_1.19.2831) but unfortunately the issue persists.
Author
Owner

@zadjii-msft commented on GitHub (Nov 6, 2023):

image
That little shield icon means either:

  • the Terminal thinks you're running it as admin
  • You have UAC disabled entirely
@zadjii-msft commented on GitHub (Nov 6, 2023): ![image](https://github.com/microsoft/terminal/assets/18356694/c3898dd7-8c8e-4321-a2aa-3a06fa4a5421) That little shield icon means either: * the Terminal thinks you're running it as admin * You have UAC disabled entirely
Author
Owner

@ebundy commented on GitHub (Nov 7, 2023):

EDIT :
I managed to run the two applications in non-administrator and the problem persists.
ezgif-2-e8f99b381c

ORIGINAL:
Good point.
I checked the state of the process and it turns out that the process is running as administrator (elevated column in process explorer). Wichis surprising because I didn't execute it as an administrator.
I also checked my UAC, indeed they were disabled entirely. I re-enabled them (intermediary level) and I restarted my computer.
Now Windows Terminal asks me a permission because "the application can do some modification on my computer." If I validate the opening, the problem remains. The application is still executed as an administrator. If I don't the application is not opened.
I tried the hints provided by users in this issue (https://github.com/microsoft/terminal/issues/13197) but it seems to be not working in my case like for some others.
I also tried to run the program as a regular user with this syntax but it seems to be not acceptable for the terminal :
wt.exe /runas. I have a Windows error saying that /runas is a not valid argument for wt.exe.

Did you have other ideas on how I may fix it?

@ebundy commented on GitHub (Nov 7, 2023): EDIT : I managed to run the two applications in non-administrator and the problem persists. ![ezgif-2-e8f99b381c](https://github.com/microsoft/terminal/assets/15986712/0d4bf4aa-c5c7-425d-a8a2-97760e687367) ORIGINAL: Good point. I checked the state of the process and it turns out that the process is running as administrator (elevated column in process explorer). Wichis surprising because I didn't execute it as an administrator. I also checked my UAC, indeed they were disabled entirely. I re-enabled them (intermediary level) and I restarted my computer. Now Windows Terminal asks me a permission because "the application can do some modification on my computer." If I validate the opening, the problem remains. The application is still executed as an administrator. If I don't the application is not opened. I tried the hints provided by users in this issue (https://github.com/microsoft/terminal/issues/13197) but it seems to be not working in my case like for some others. I also tried to run the program as a regular user with this syntax but it seems to be not acceptable for the terminal : `wt.exe /runas`. I have a Windows error saying that /runas is a not valid argument for wt.exe. Did you have other ideas on how I may fix it?
Author
Owner

@yg-i commented on GitHub (Jun 5, 2024):

I maybe experiencing the same issue as @ebundy

@ebundy:

  • when you hover your mouse over the '+' (new tab) and 'x' (close tab) buttons in the tab bar at the top (not: the close/maximize/minimize buttons in the top right corner), do those buttons change color?
  • When you click them, do tabs get closed/opened?
  • When you right click in the blank areas of the tab, does a context menu show up?

For me the answer is 'no' to all the above.

@yg-i commented on GitHub (Jun 5, 2024): I maybe experiencing the same issue as @ebundy @ebundy: - when you hover your mouse over the '+' (new tab) and 'x' (close tab) buttons in the tab bar at the top (not: the close/maximize/minimize buttons in the top right corner), do those buttons change color? - When you click them, do tabs get closed/opened? - When you right click in the blank areas of the tab, does a context menu show up? For me the answer is 'no' to all the above.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#20773