doriansm
doriansm

Reputation: 245

AutoHotKey ControlSend() Not working with Ctrl functions

I am trying to use ControlSend to simply select all text in a notepad, and copy it. Instead of selecting the text and copying it, it is just typing the litter a and c. I am a total AHK newb so excuse my ignorance here. I want to use ControlSend because I need it to be able to do this in the background. Ultimately this script will be much larger, just trying to get the hang of ControlSend. Help?

#q:: 
ControlSend, Edit1,{Ctrl down}a{Ctrl up}, Untitled
Sleep, 1000
ControlSend, Edit1,{Ctrl down}c{Ctrl up}, Untitled

Upvotes: 0

Views: 1018

Answers (1)

woxxom
woxxom

Reputation: 73616

Use the internal message IDs to execute the commands:

#q::
    sendmessage, WM_COMMAND:=0x111, NOTEPAD_SELECTALL:=25, 0,, ahk_class Notepad
    sendmessage, WM_COMMAND:=0x111, NOTEPAD_COPY:=769, 0,, ahk_class Notepad
    return

To peek the IDs I've used Spy++ (spyxx) x64 on Windows 7 SP1 x64.

Upvotes: 1

Related Questions