AutoHotkey Community

It is currently May 27th, 2012, 11:07 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: February 17th, 2006, 4:53 pm 
Offline

Joined: February 9th, 2006, 10:58 pm
Posts: 19
Can you give me example code that opens Notepad and uses SendMessage or PostMessage to put the string “hello” inside the Untitled Notepad window?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 17th, 2006, 5:12 pm 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
If you really want to do that, Send or ControlSend or ControlSetText or such are probably more appropriate.

If you are just looking for examples, searching the forum with the commands will give you plenty of examples...

PS.: please, avoid sending multiple identical messages.
(Comment by moderator: the duplicate post has been removed. Thanks for understanding.)

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 17th, 2006, 5:39 pm 
Offline

Joined: February 9th, 2006, 10:58 pm
Posts: 19
The problem with using Send or ControlSend is that they do not work while the screen is locked. I found from multiple testing that sending keys will not work on a locked workstation. However, posting windows messages under a locked workstation does work. However, I've only been able to post messages to window titles using the following code:

Run Notepad
WinWait Untitled - Notepad
Sleep, 2000
SendMessage, 0xC, 0, "New Notepad Title" ; 0XC is WM_SETTEXT

How do I post a message inside of the window (in the notepad body) instead of the window title?

Thank you.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 17th, 2006, 6:10 pm 
Offline

Joined: November 8th, 2004, 12:46 am
Posts: 1271
Specify the ClassNN of the control, eg:

Code:
SendMessage, 0xC, 0, "New Notepad Title", Edit1, ahk_class Notepad

_________________
"Anything worth doing is worth doing slowly." - Mae West
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 17th, 2006, 6:25 pm 
Offline

Joined: February 9th, 2006, 10:58 pm
Posts: 19
Thank you so much! That worked great! You're the man!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 17th, 2006, 6:27 pm 
Offline

Joined: November 8th, 2004, 12:46 am
Posts: 1271
arabinow wrote:
You're the man!


Woman. ;)

_________________
"Anything worth doing is worth doing slowly." - Mae West
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 17th, 2006, 6:34 pm 
Offline

Joined: February 9th, 2006, 10:58 pm
Posts: 19
Sorry. You're the woman!!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 17th, 2006, 6:48 pm 
Offline

Joined: February 9th, 2006, 10:58 pm
Posts: 19
Do you know how to use PostMessage or SendMessage to send certain keys like {ENTER}? Example code would be great. I really appreciate it. Thank you.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 17th, 2006, 8:13 pm 
Offline

Joined: November 8th, 2004, 12:46 am
Posts: 1271
You could try using WM_KEYDOWN, although I am unsure what value lParam should be in this case (a 32-bit integer?). Perhaps someone else can post a working example.

Code:
; Enter vk = 0D
WM_KEYDOWN = 0x100

F1::
SendMessage, WM_KEYDOWN, 0D, 0, Edit1, ahk_class Notepad
return

_________________
"Anything worth doing is worth doing slowly." - Mae West
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 18th, 2006, 1:11 pm 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
Always curious of the various uses of AutoHotkey: why do you want to use a graphical application like Notepad on a locked workstation?
Perhaps there is other ways of doing what you do...

If you want to send simple keys like Enter or Tab, you can use the special characters: `n (or perhaps `r`n) and `t.

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 20th, 2006, 12:18 pm 
Offline

Joined: February 9th, 2006, 10:58 pm
Posts: 19
I was using Notepad as a simple test program. I love AutoHotKey but it has problems working while the workstation is under a locked screen. Due to company security policies, I cannot justify having an unlocked workstation. The scripts I created with AutoHotKey will fail under a locked workstation if I try to send keystrokes. Any suggestions?


Report this post
Top
 Profile  
Reply with quote  
PostPosted: February 27th, 2006, 4:29 pm 
Offline

Joined: February 9th, 2006, 10:58 pm
Posts: 19
I was wondering if you can use SendMessage to send a variable. I am using FileRead to read the contents of a text file into a variable. I wanted to use SendMessage to quickly send the string instead of waiting for the meesage to be sent with keystrokes using Send. The following code does not work:

FileRead, OutputVar, C:\test
Run, Notepad
WinWait, Untitled - Notepad
WinActivate, Untitled - Notepad
SendMessage, 0xC, 0, %OutputVar%, Edit1, ahk_Notepad


Any Suggestions on how I can send the contents of my variable inside of the notepad text window. Thank you.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 28th, 2006, 1:38 pm 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
What is ahk_Notepad? 8)

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
PostPosted: December 21st, 2007, 6:47 pm 
hello , it's my first post in this forum
i wanna know how to post this message in VB6
my reason , it's to put a string on edit but i can't , i have some thing wrong in this command line:
postmessage notepad_handle, wm_char,asc("a"),0


Report this post
Top
  
Reply with quote  
 Post subject: use spyxx
PostPosted: December 22nd, 2007, 4:17 pm 
I once had such requirement to simulate keyboard input and also found that SendInput doesn't work when the workstation is locked or a remote desktop connection is disconnected. You will have to use SendMessage/PostMessage along with WM_KEYDOWN/WM_KEYUP messages.

You can try with spyxx (from Visual Studio) and monitor those keyboard messages to learn which parameters you should use.


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, Edd, Exabot [Bot], HotkeyStick and 12 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group