Jump to content
Sign in to follow this  
commonjunks

Why different syntax for ControlClick while using in c# and au3

Recommended Posts

commonjunks

Hi,

I am trying to click Save button once IE popup window to download a file

Here following code working flawless when using in au3 file

WinWaitActive("File Download")

ControlClick("File Download", "", "&Save")

But when i use same code in c#, it is not working as it suppose to

AutoItX3Class AUI = new AutoItX3Class();

AUI.WinWaitActive("File Download", "", 0);

AUI.ControlClick("File Download", "", "&Save", "left", 1, 0, 0)

Any help?

Posted Image

Share this post


Link to post
Share on other sites
Richard Robertson

I assume the x,y of 0,0 is the problem. On Windows XP, you notice that the buttons have rounded corners. Maybe if you move your click in a bit so it actually touches the button, it might work.

Share this post


Link to post
Share on other sites
zfisherdrums

Hello 'commonjunks';

Try this:

AUI.ControlClick("File Download", "", "&Save", "left", 1, -1, -1)

Zach...

Edit: What Mr. Robertson said! :P

Edited by zfisherdrums

Share this post


Link to post
Share on other sites
commonjunks

@zfisherdrums, your trick did work ;).

@Richard Robertson Thank you.

Did i mention, I LOVE YOU GUYS :P (Not a girly love, but other love).

Is there any documentation i refer if i get similar situation?

Share this post


Link to post
Share on other sites
Richard Robertson

Pretty much the AutoIt help files. Also, my comment about the rounded corners was a purely visual aspect.

Share this post


Link to post
Share on other sites
zfisherdrums

Well, there is the AutoItX Help File and the MSDN documentation, although I'm not sure where I read that the use of '-1' implies default parameters. Outside of that, you have us here in the forum. Good luck with whatever you're working on!

Zach...

Share this post


Link to post
Share on other sites
commonjunks

Ok, it works once and when today i test it again it get fail :P.

I have no idea why

AutoItX3Class AUI = new AutoItX3Class();

following code is working when Save As screen appear

AUI.WinWaitActive("Save As", "",0);

AUI.ControlClick("Save As", "", "&Save", "left", 1, 0, 0);

but none of the following work for File Download screen

AUI.WinWaitActive("File Download", "",0);

AUI.ControlClick("File Download", "", "&Save", "left", 1, 0, 0);

or

AUI.WinWaitActive("File Download", "",0);

AUI.ControlClick("File Download", "", "&Save", "left", 1, -1, -1);

as you can see both button seems same

Posted Image

Posted Image

for your information when either line execute AUI.ControlClick("File Download", "", "&Save", "left", 1, -1, -1) or AUI.ControlClick("File Download", "", "&Save", "left", 1, 0, 0) focus go to save button but it don't click it.

At end i make some thing which is working but not very clean

AUI.WinActivate("File Download", "");

AUI.WinMove("File Download", "", 0, 0, 404, 273);

AUI.MouseMove(257, 158, 1);

AUI.MouseDown("left");

AUI.Sleep(250);

AUI.MouseUp("left");

AUI.Sleep(250);

AUI.WinActivate("Save As", "");

AUI.ControlClick("Save As", "", "&Save", "left", 1, 0, 0);

Hope someone can help

Share this post


Link to post
Share on other sites
Richard Robertson

You used 0, 0 again for your control click. Use -1, -1.

Share this post


Link to post
Share on other sites
commonjunks

You used 0, 0 again for your control click. Use -1, -1.

Hi Richard,

Thanks for reply, i tried both

1-

AUI.ControlClick("File Download", "", "&Save", "left", 1, -1, -1)

2-

AUI.ControlClick("File Download", "", "&Save", "left", 1, 0, 0)

None of these two work.

Share this post


Link to post
Share on other sites
Richard Robertson

Try 5, 5 then. That should hit the button.

Edited by Richard Robertson

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×