SendMessage Win32API function

On Win 2K: ruby 1.6.8 (2002-12-24) [i586-mswin32]

Open a Notepad window BEFORE running this script

require “Win32API”

Now find the window handle of this session

findWindow = Win32API.new(“user32”,
“FindWindow”,
[‘P’,‘P’], ‘L’)
hWnd = findWindow.call(0,“Untitled - Notepad”)
puts hWnd if $DEBUG
raise ‘open a “Notepad” window and then try again’ if
(hWnd <= 0)

And change the title

WM_SETTEXT=0xC
sendMessage = Win32API.new(“user32”, “SendMessage”,
[‘L’,‘L’,‘L’,‘P’], ‘L’)
b = sendMessage.call(hWnd, WM_SETTEXT,-1,“Hello
There”)
puts b if $DEBUG

···

Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com