Jump to content

Recommended Posts

Posted (edited)

[Sorry I meant "send keystrokes"]

Title is self explaining. I don't understand why this doesn't work:

#include <SendMessage.au3>
#include <WindowsConstants.au3>

Run("notepad.exe")
$hWnd = WinWait("[CLASS:Notepad]", "", 10)
$hControl = ControlGetHandle($hWnd, "", "Edit1")

;This works
ControlSend($hControl, "", "", "hello")
;This doesn't work
_SendMessage($hControl, "hello")

[Just in case. This is a "thought experiment"; don't ask me why I don't use Send(), ControlSend(), etc.]

Edited by oasis375
Posted

_SendMessage doesn't send "strings", it sends "events" to controls
have a look here 

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Posted

Thank you, guys. This is what works:

#include <SendMessage.au3>
#include <WindowsConstants.au3>

Run("notepad.exe")
$hWnd = WinWait("[CLASS:Notepad]", "", 10)
$hControl = ControlGetHandle($hWnd, "", "Edit1")
$text = "this is a line"
$struct_string = DllStructCreate("char[" & StringLen($text) + 1 & "]")
DllStructSetData($struct_string, 1, $text)
_SendMessageA($hControl, $WM_SETTEXT, 0, DllStructGetPtr($struct_string))

 

Posted

how did you go from that trivial mistake in the first post to this fine example posted here so quickly? :o
Good! great progress in so little time...

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...