[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

AutoIt: HWnd function of AutoIt giving method missing error

Anukul Singhal

7/12/2008 10:26:00 AM

Hi,

I am using AutoIt in my ruby code to automate a client
application.Although most of the AutoIt methods are working fine, I am
not able to use the HWnd function of AutoIt, getting a method missing
error. Would like to know if there is anything wrong in the code below:

require 'win32ole'

autoIt = WIN32OLE.new("AutoItX3.Control")
bb = IO.popen("C:/Windows/Notepad.exe")
sleep 3.0
appID = autoIt.WinGetHandle("Untitled -Notepad")
sAppID = appID.to_s
appHandle = autoIt.HWnd(sAppID)
puts appHandle

The above piece of code gives me this error:

1) Error:
test_client_actions_click_positive(Client_unit_test):
WIN32OLERuntimeError: unknown property or method `HWnd'
HRESULT error code:0x80020006
Unknown name.

Although HWnd is a supported method for AutoIt, I am getting this error.

I know I can use the title arg for performing my actions, but my
requirement is to get the WindowHandle and use it to perform actions
like ControlSetText and ControlClick, etc.

Can anyone tell what is wrong in the above code snippet? Or am I missing
something to make it work.

Thanks,
Anukul
--
Posted via http://www.ruby-....

9 Answers

Siep Korteling

7/12/2008 11:37:00 AM

0

Anukul Singhal wrote:
> Hi,
>
> I am using AutoIt in my ruby code to automate a client
> application.Although most of the AutoIt methods are working fine, I am
> not able to use the HWnd function of AutoIt, getting a method missing
> error. Would like to know if there is anything wrong in the code below:
>
> require 'win32ole'
>
> autoIt = WIN32OLE.new("AutoItX3.Control")
> bb = IO.popen("C:/Windows/Notepad.exe")
> sleep 3.0
> appID = autoIt.WinGetHandle("Untitled -Notepad")
> sAppID = appID.to_s
> appHandle = autoIt.HWnd(sAppID)
> puts appHandle

When this line is inserted:

puts autoIt.ole_methods

it shows there is no method Hwnd.

AFAIK WinGetHandle is already giving you what you want. If you need the
handle from a control (f.i. a button or label) , use ControlGetHandle.

hth,

Siep
--
Posted via http://www.ruby-....

Anukul Singhal

7/12/2008 11:48:00 AM

0

Hi Siep,

Thanks a lot for the reply. You are right that WinGetHandle or
ControlGetHandle should do the trick for me. But my requirement is to
use one of these handles to set text or do the click operation. What I
want to do is this:

appID = autoIt.WinGetHandle("Untitled -Notepad")
autoIt.ControlSetText(appID,"","Edit1","This is a text")

I want to use title argument only once to fetch the window handle and
then subsequently use the window handle to perform other actions of
setting text or click. Is it possible to avoid 'title' argument and use
a Window Handle instead?
My concern is that if there are more than 1 instance of say "Notepad",
the title of all the instances of notepad would be the same but the
Window Handle would be unique for each instance, and hence would be a
good option to use for performing actions.

Is there any way out to do the above step and avoid "title" as the first
argument?

Thanks,
Anukul

Siep Korteling wrote:
> Anukul Singhal wrote:
>> Hi,
>>
>> I am using AutoIt in my ruby code to automate a client
>> application.Although most of the AutoIt methods are working fine, I am
>> not able to use the HWnd function of AutoIt, getting a method missing
>> error. Would like to know if there is anything wrong in the code below:
>>
>> require 'win32ole'
>>
>> autoIt = WIN32OLE.new("AutoItX3.Control")
>> bb = IO.popen("C:/Windows/Notepad.exe")
>> sleep 3.0
>> appID = autoIt.WinGetHandle("Untitled -Notepad")
>> sAppID = appID.to_s
>> appHandle = autoIt.HWnd(sAppID)
>> puts appHandle
>
> When this line is inserted:
>
> puts autoIt.ole_methods
>
> it shows there is no method Hwnd.
>
> AFAIK WinGetHandle is already giving you what you want. If you need the
> handle from a control (f.i. a button or label) , use ControlGetHandle.
>
> hth,
>
> Siep

--
Posted via http://www.ruby-....

Masaki Suketa

7/12/2008 12:02:00 PM

0

Hello,

Anukul Singhal wrote:
> autoIt = WIN32OLE.new("AutoItX3.Control")
> bb = IO.popen("C:/Windows/Notepad.exe")
> sleep 3.0
> appID = autoIt.WinGetHandle("Untitled -Notepad")
> sAppID = appID.to_s
> appHandle = autoIt.HWnd(sAppID)
> puts appHandle
>
> The above piece of code gives me this error:
>
> 1) Error:
> test_client_actions_click_positive(Client_unit_test):
> WIN32OLERuntimeError: unknown property or method `HWnd'
> HRESULT error code:0x80020006
> Unknown name.
>
> Although HWnd is a supported method for AutoIt, I am getting this error.

I think HWnd is a function for AutoIt script, but HWnd is not
included in AutoItX3.Control.
HWnd is not included the ole_methods list.

autoIt = WIN32OLE.new("AutoItX3.Control")
p autoIt.ole_methods

How about asking AutoIt Team whether HWnd is included in
AutoItX3.Control or not?
Or Asking AutoIt Team how to call HWnd from VBScript.
If you can call HWnd from VBScript, you could call HWnd from Win32OLE.

Regards,
Masaki Suketa


Siep Korteling

7/12/2008 8:20:00 PM

0

Anukul Singhal wrote:
> Hi Siep,
>
> Thanks a lot for the reply. You are right that WinGetHandle or
> ControlGetHandle should do the trick for me. But my requirement is to
> use one of these handles to set text or do the click operation. What I
> want to do is this:
>
> appID = autoIt.WinGetHandle("Untitled -Notepad")
> autoIt.ControlSetText(appID,"","Edit1","This is a text")
>
> I want to use title argument only once to fetch the window handle and
> then subsequently use the window handle to perform other actions of
> setting text or click. Is it possible to avoid 'title' argument and use
> a Window Handle instead?
> My concern is that if there are more than 1 instance of say "Notepad",
> the title of all the instances of notepad would be the same but the
> Window Handle would be unique for each instance, and hence would be a
> good option to use for performing actions.
>
> Is there any way out to do the above step and avoid "title" as the first
> argument?
>

Found an undocumented feature. This is a way to use the handle:

res=autoIt.ControlSend("[HANDLE:#{appID}]","","Edit1","some text")
sleep 2
autoIt.Winclose("[HANDLE:#{appID}]")

hth,

Siep


--
Posted via http://www.ruby-....

Anukul Singhal

7/13/2008 5:48:00 AM

0

Hi,

Thanks so much. It worked great! Just want to know if you have the url
or any reference where you got these undocumented features from?

Thanks,
Anukul

Siep Korteling wrote:
> Anukul Singhal wrote:
>> Hi Siep,
>>
>> Thanks a lot for the reply. You are right that WinGetHandle or
>> ControlGetHandle should do the trick for me. But my requirement is to
>> use one of these handles to set text or do the click operation. What I
>> want to do is this:
>>
>> appID = autoIt.WinGetHandle("Untitled -Notepad")
>> autoIt.ControlSetText(appID,"","Edit1","This is a text")
>>
>> I want to use title argument only once to fetch the window handle and
>> then subsequently use the window handle to perform other actions of
>> setting text or click. Is it possible to avoid 'title' argument and use
>> a Window Handle instead?
>> My concern is that if there are more than 1 instance of say "Notepad",
>> the title of all the instances of notepad would be the same but the
>> Window Handle would be unique for each instance, and hence would be a
>> good option to use for performing actions.
>>
>> Is there any way out to do the above step and avoid "title" as the first
>> argument?
>>
>
> Found an undocumented feature. This is a way to use the handle:
>
> res=autoIt.ControlSend("[HANDLE:#{appID}]","","Edit1","some text")
> sleep 2
> autoIt.Winclose("[HANDLE:#{appID}]")
>
> hth,
>
> Siep

--
Posted via http://www.ruby-....

Siep Korteling

7/13/2008 2:55:00 PM

0

Anukul Singhal wrote:
> Hi,
>
> Thanks so much. It worked great! Just want to know if you have the url
> or any reference where you got these undocumented features from?
>
> Thanks,
> Anukul

http://www.autoitscript.com/forum/index.php?showtopic=57887&view=findpost&am...

(you was close!)

Regards,

Siep

--
Posted via http://www.ruby-....

Yoorghis

7/11/2012 2:48:00 AM

0

On Tue, 10 Jul 2012 13:31:26 -0700, MattB
<trdell1234NOMORESPAM@gmail.com> wrote:

>On Tue, 10 Jul 2012 14:14:47 -0600, Yoorghis@Jurgis.net wrote:
>
>>On Tue, 10 Jul 2012 11:25:15 -0700, MattB
>><trdell1234NOMORESPAM@gmail.com> wrote:
>>
>>>Romney Courts Black Vote, an Obama Strength in ?08
>>
>>BWHAHAHAHAHA
>>
>>Your pathetic idiot MIGHT get 5% of the black vote
>
>
>5% I am going for 14% or so.
>

Well, then you're admitting that white citizens voting for that dumb
asshole are 80% or so more stupid than blacks

MattB

7/11/2012 3:35:00 AM

0

On Tue, 10 Jul 2012 20:47:47 -0600, Yoorghis@Jurgis.net wrote:

>On Tue, 10 Jul 2012 13:31:26 -0700, MattB
><trdell1234NOMORESPAM@gmail.com> wrote:
>
>>On Tue, 10 Jul 2012 14:14:47 -0600, Yoorghis@Jurgis.net wrote:
>>
>>>On Tue, 10 Jul 2012 11:25:15 -0700, MattB
>>><trdell1234NOMORESPAM@gmail.com> wrote:
>>>
>>>>Romney Courts Black Vote, an Obama Strength in ?08
>>>
>>>BWHAHAHAHAHA
>>>
>>>Your pathetic idiot MIGHT get 5% of the black vote
>>
>>
>>5% I am going for 14% or so.
>>
>
>Well, then you're admitting that white citizens voting for that dumb
>asshole are 80% or so more stupid than blacks


That's your opinion and that is fine. Honestly neither is a good
candidate.

Yoorghis

7/11/2012 2:54:00 PM

0

On Tue, 10 Jul 2012 20:34:52 -0700, MattB
<trdell1234NOMORESPAM@gmail.com> wrote:

>On Tue, 10 Jul 2012 20:47:47 -0600, Yoorghis@Jurgis.net wrote:
>
>>On Tue, 10 Jul 2012 13:31:26 -0700, MattB
>><trdell1234NOMORESPAM@gmail.com> wrote:
>>
>>>On Tue, 10 Jul 2012 14:14:47 -0600, Yoorghis@Jurgis.net wrote:
>>>
>>>>On Tue, 10 Jul 2012 11:25:15 -0700, MattB
>>>><trdell1234NOMORESPAM@gmail.com> wrote:
>>>>
>>>>>Romney Courts Black Vote, an Obama Strength in ?08
>>>>
>>>>BWHAHAHAHAHA
>>>>
>>>>Your pathetic idiot MIGHT get 5% of the black vote
>>>
>>>
>>>5% I am going for 14% or so.
>>>
>>
>>Well, then you're admitting that white citizens voting for that dumb
>>asshole are 80% or so more stupid than blacks
>
>
>That's your opinion and that is fine. Honestly neither is a good
>candidate.

That's your (silly) "opinion" and it's why I can make you look totally
screwed up.

Obama's contribution to saving this nation for SURE disaster (because
it was happening)---won't be appreciated until Rumny RETURNS to what
got us there in the first place

Republicans, (rumny having little power) will GO BACK to Deregulation,
tax cuts, program removal and America WILL suffer.