Script pauses when you click in the powershell text window

K

Kris

Suppose you have following code:
for ($i=0 ; $i -lt 10; $i++) { write-host $i ; start-sleep -s 1 }

Now, while the script is running, simply click with the mouse cursor
somewhere in the powershell's text window. The script will pause and
only continues when you press Enter. It turns out that clicking in the
text area actually invokes the text selection action for clipboard copy
operations.

This is all fine, but initially I got reports from people running my
script that my script paused for no reason at all. Eventually, it turned
out that the pause was caused by mouse clicks in the text window (often
caused when they simply wanted to give focus to the partially hidden
powershell window, after which they left and the script remained paused
until they returned hours later only to come to the conclusion that
nothing had happened in the mean time).

This easy copy-text feature is nice, but I was wondering if there is a
way to disable this (script-wise) so that people aren't able anymore to
accidentally pause the script. Being able to disable this feature would
make my my script more fool-proof.

Thanks,

Kris
 

My Computer

B

Bob Landau

Kris

The only method I know of changing this is in the registry

HKCU\Console\QuickEdit 0x1 (on) 0x0 (off)

Most of these settings unfortunately aren't reloaded when changed manually.
The user will need to log off.

The Command Console of course has a "special" relationship with it's
properties and does this on the fly if you change it via the menu.

Perhaps someone else will have better news

bob

"Kris" wrote:

> Suppose you have following code:
> for ($i=0 ; $i -lt 10; $i++) { write-host $i ; start-sleep -s 1 }
>
> Now, while the script is running, simply click with the mouse cursor
> somewhere in the powershell's text window. The script will pause and
> only continues when you press Enter. It turns out that clicking in the
> text area actually invokes the text selection action for clipboard copy
> operations.
>
> This is all fine, but initially I got reports from people running my
> script that my script paused for no reason at all. Eventually, it turned
> out that the pause was caused by mouse clicks in the text window (often
> caused when they simply wanted to give focus to the partially hidden
> powershell window, after which they left and the script remained paused
> until they returned hours later only to come to the conclusion that
> nothing had happened in the mean time).
>
> This easy copy-text feature is nice, but I was wondering if there is a
> way to disable this (script-wise) so that people aren't able anymore to
> accidentally pause the script. Being able to disable this feature would
> make my my script more fool-proof.
>
> Thanks,
>
> Kris
>
 

My Computer

M

Marco Shaw [MVP]


> This easy copy-text feature is nice, but I was wondering if there is a
> way to disable this (script-wise) so that people aren't able anymore to
> accidentally pause the script. Being able to disable this feature would
> make my my script more fool-proof.
From what I can tell so far, running something in the background is not
affected:
http://jtruher.spaces.live.com/blog/cns!7143DA6E51A2628D!130.entry

Marco

--
Microsoft MVP - Windows PowerShell
http://www.microsoft.com/mvp

PowerGadgets MVP
http://www.powergadgets.com/mvp

Blog:
http://marcoshaw.blogspot.com
 

My Computer

O

/\/\o\/\/ [MVP]

This is "Feature" of the console itself, and does also happen when you use
CMD.EXE

Greetings /\/\o\/\/


"Marco Shaw [MVP]" wrote:

>

> > This easy copy-text feature is nice, but I was wondering if there is a
> > way to disable this (script-wise) so that people aren't able anymore to
> > accidentally pause the script. Being able to disable this feature would
> > make my my script more fool-proof.
>
> From what I can tell so far, running something in the background is not
> affected:
> http://jtruher.spaces.live.com/blog/cns!7143DA6E51A2628D!130.entry
>
> Marco
>
> --
> Microsoft MVP - Windows PowerShell
> http://www.microsoft.com/mvp
>
> PowerGadgets MVP
> http://www.powergadgets.com/mvp
>
> Blog:
> http://marcoshaw.blogspot.com
>
 

My Computer

K

Kris

Keith Hill [MVP] wrote:

> Nope. MoW is just stating that CMD.exe has the same problem. Can you
> try to opening the console Window properties and disabling Quick Edit
> and see if that makes the problem go away?
Yes. Turning Quick Edit off makes the problem go away.

Thanks.
 

My Computer

M

Marco Shaw [MVP]

Kris wrote:

> Keith Hill [MVP] wrote:

>> Nope. MoW is just stating that CMD.exe has the same problem. Can you
>> try to opening the console Window properties and disabling Quick Edit
>> and see if that makes the problem go away?
>
> Yes. Turning Quick Edit off makes the problem go away.
>
> Thanks.
>
So at least you can go with what Bob says maybe about the registry edit,
then the *next* time, and forever after, the problem will be gone.

Marco
 

My Computer

K

Kris

Bob Landau wrote:

> HKCU\Console\QuickEdit 0x1 (on) 0x0 (off)
Marco Shaw [MVP] wrote:

> So at least you can go with what Bob says maybe about the registry edit,
> then the *next* time, and forever after, the problem will be gone.
I'm not sure this will work reliably. Currently I have QuickEdit still
enabled in my PowerShell session even though the registry value is set
to 0. Even after log-off or reboot, registry value is zero, but QE is
still enabled.

I've noticed that when I change the window's properties such as the QE
setting, you will be asked if you want to modify the shortcut that
started the session. So, I'm thinking that the registry value is a
global default value, which is easily overruled when the user has
applied the new properties to the shortcut.

Kris
 

My Computer

Top