Text-editing Script Not Working in Microsoft Word Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Alexander2
Posts: 348
Joined: 27 Apr 2019, 17:38

Text-editing Script Not Working in Microsoft Word

Post by Alexander2 » 23 Sep 2022, 03:56

I use the following script for uppercasing selected text. The script works in any text-editing program or text field. But it does not work in an open text document in Microsoft Word (although it works in other fields in Microsoft Word—for example, in the search field which is brought up by pressing Ctrl + F). Does anyone know why the script works everywhere except an open Microsoft Word document?

Code: Select all

#If GetKeyState("LShift", "P")
NumpadIns:: ; LShift + Numpad0.
Clipboard =
Send ^c
ClipWait, 0
SendInput % Format("{Text}{:U}", Clipboard)
return
#If

Rohwedder
Posts: 7558
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Text-editing Script Not Working in Microsoft Word  Topic is solved

Post by Rohwedder » 23 Sep 2022, 05:05

Hallo,
try:

Code: Select all

#If GetKeyState("LShift", "P")
NumpadIns:: ; LShift + Numpad0
Clipboard =
Send, {LShift Up}^c
ClipWait, 0
SendInput % Format("{Text}{:U}", Clipboard)
return
#If

Alexander2
Posts: 348
Joined: 27 Apr 2019, 17:38

Re: Text-editing Script Not Working in Microsoft Word

Post by Alexander2 » 24 Sep 2022, 02:53

Rohwedder wrote:
23 Sep 2022, 05:05
Hallo,
try:

Code: Select all

#If GetKeyState("LShift", "P")
NumpadIns:: ; LShift + Numpad0
Clipboard =
Send, {LShift Up}^c
ClipWait, 0
SendInput % Format("{Text}{:U}", Clipboard)
return
#If
Thank you. Apparently while the Shift key is held in Microsoft Word, some actions cannot be executed.

Rohwedder
Posts: 7558
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Text-editing Script Not Working in Microsoft Word

Post by Rohwedder » 24 Sep 2022, 03:16

I don't think Microsoft Word is to blame but Microsoft Windows!
When the key combination LShift + Numpad0 is pressed, Autohotkey sees only the event NumpadIns was pressed and does not mask LShift. Try:

Code: Select all

#If GetKeyState("LShift", "P")
NumpadIns:: ; LShift + Numpad0
KeyHistory

Alexander2
Posts: 348
Joined: 27 Apr 2019, 17:38

Re: Text-editing Script Not Working in Microsoft Word

Post by Alexander2 » 24 Sep 2022, 12:05

Rohwedder wrote:
24 Sep 2022, 03:16
I don't think Microsoft Word is to blame but Microsoft Windows!
When the key combination LShift + Numpad0 is pressed, Autohotkey sees only the event NumpadIns was pressed and does not mask LShift. Try:

Code: Select all

#If GetKeyState("LShift", "P")
NumpadIns:: ; LShift + Numpad0
KeyHistory
When I used my original script (without the {LShift Up} command) in the system’s Notepad, the selected text was uppercased. But when I used the same script in Microsoft Word, the selected text was not uppercased. So I thought that Microsoft Word prevented the uppercasing of the text. I still do not understand why the original script works in Notepad but not in Microsoft Word.

Rohwedder
Posts: 7558
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Text-editing Script Not Working in Microsoft Word

Post by Rohwedder » 24 Sep 2022, 12:39

On second thought, neither do I.

User avatar
flyingDman
Posts: 2791
Joined: 29 Sep 2013, 19:01

Re: Text-editing Script Not Working in Microsoft Word

Post by flyingDman » 24 Sep 2022, 14:36

Why not:

Code: Select all

<+NumpadIns:: 				; LShift + Numpad0.
Clipboard := ""
Send ^c
ClipWait, 0
SendInput % Format("{Text}{:U}", Clipboard)
return
or am I off course?
14.3 & 1.3.7

Rohwedder
Posts: 7558
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Text-editing Script Not Working in Microsoft Word

Post by Rohwedder » 25 Sep 2022, 00:30

It applied, without explicitly mentioning it, the premise Numlock is on.
Then, at least here, <+NumpadIns:: does not trigger.

With Numlock off the comment should be:

Code: Select all

<+NumpadIns:: ; LShift + NumpadIns.

Alexander2
Posts: 348
Joined: 27 Apr 2019, 17:38

Re: Text-editing Script Not Working in Microsoft Word

Post by Alexander2 » 25 Sep 2022, 03:28

Thank you for the explanations. When Numlock is off, the original script works both in Notepad and Microsoft Word when the <+NumpadIns:: hotkey is used.

Post Reply

Return to “Ask for Help (v1)”