Hi!
I'm playing with the API of Windows, but I haven't found much
information about that (almost all is for VB -.- )
So I'd like to know where can I search for it.
Im trying to get de windows where the user is working, i have:
a = Win32API.new('user32', 'GetForegroundWindow', [], 'P')
a.Call()
But it doesnt work... The GetForegroundWindow function doesnt need
params and it returns a handle of the windows, so i think it should
run...
Thanks.
P.S.: Sorry, English is not my first language
···
--
Posted via http://www.ruby-forum.com/ .
Diego Guti wrote:
Hi!
I'm playing with the API of Windows, but I haven't found much
information about that (almost all is for VB -.- )
So I'd like to know where can I search for it.
Im trying to get de windows where the user is working, i have:
a = Win32API.new('user32', 'GetForegroundWindow', , 'P')
a.Call()
But it doesnt work... The GetForegroundWindow function doesnt need
params and it returns a handle of the windows, so i think it should
run...
Thanks.
P.S.: Sorry, English is not my first language
Try changing your last parameter from 'P' to 'N':
a = Win32API.new('user32', 'GetForegroundWindow', , 'N')
window = a.Call()
David
···
--
Posted via http://www.ruby-forum.com/\ .
recommend ffi, too, for windows api stuff:
ffi - Ruby FFI
win32api scares me.
···
--
Posted via http://www.ruby-forum.com/ .
Try changing your last parameter from 'P' to 'N':
a = Win32API.new('user32', 'GetForegroundWindow', , 'N')
window = a.Call()
David
Thanks, now it's running :).
Just one more question. Now i got the handle of the window, any chance
to get the name of the window??
···
--
Posted via http://www.ruby-forum.com/\ .
Yeah, well, FFI scares me. It's a PITA declaring structs, and it won't
build with MSVC++.
Dan
···
On Mar 23, 8:32 am, Roger Pack <rogerpack2...@gmail.com> wrote:
recommend ffi, too, for windows api stuff:
Windows Examples · ffi/ffi Wiki · GitHub
win32api scares me.
Diego Guti wrote:
Try changing your last parameter from 'P' to 'N':
a = Win32API.new('user32', 'GetForegroundWindow', , 'N')
window = a.Call()
David
Thanks, now it's running :).
Just one more question. Now i got the handle of the window, any chance
to get the name of the window??
You can use the GetWindowText API call. Pass it (1) your window handle,
(2) a string buffer into which the text is to be copied, and (3) the
maximum number of characters to copy to the buffer:
require 'Win32API'
getForegroundWindow = Win32API.new('user32', 'GetForegroundWindow', ,
'L')
getWindowText = Win32API.new('user32', 'GetWindowText', ['L', 'P', 'I'],
'I')
window_handle = getForegroundWindow.Call()
title_buffer = ' ' * 256
getWindowText.Call(window_handle, title_buffer, 256)
puts(title_buffer)
David
···
--
Posted via http://www.ruby-forum.com/\ .
You can use the GetWindowText API call. Pass it (1) your window handle,
(2) a string buffer into which the text is to be copied, and (3) the
maximum number of characters to copy to the buffer:
require 'Win32API'
getForegroundWindow = Win32API.new('user32', 'GetForegroundWindow', ,
'L')
getWindowText = Win32API.new('user32', 'GetWindowText', ['L', 'P', 'I'],
'I')
window_handle = getForegroundWindow.Call()
title_buffer = ' ' * 256
getWindowText.Call(window_handle, title_buffer, 256)
puts(title_buffer)
David
Ok. Thank you very much !! Now It's perfect.
Regards
···
--
Posted via http://www.ruby-forum.com/\ .
Thanks a lot for the code
do you how is possible to get the text content of the browser when
displaying a flash app?
David Mullet wrote in post #763686:
···
Diego Guti wrote:
Try changing your last parameter from 'P' to 'N':
--
Posted via http://www.ruby-forum.com/\ .