Sign in to follow this  
Followers 0
taren9k3

Help me with controlclick

17 posts in this topic

When I use ControlClick function I have to use WinActivate command before. So I want to ask you are there anyways to use controlclick or some functions else that do not need to use WinActivate. Thanks

Share this post


Link to post
Share on other sites



You don't need to WinActivate windows before you ControlClick them... That's the nice thing about ControlClick?

Example:

Run ("notepad")
WinWait ("Untitled -")
Run ("control Sysdm.cpl")
WinWait ("System Properties")

MsgBox (0, "", "We're going to activate Notepad and controlclick OK on the System Properties window while it's not active.")
WinActivate ("Untitled - ")
Sleep (2000)
ControlClick ("System Properties", "", "OK")

Share this post


Link to post
Share on other sites

You don't need to WinActivate windows before you ControlClick them... That's the nice thing about ControlClick?

Example:

Run ("notepad")
WinWait ("Untitled -")
Run ("control Sysdm.cpl")
WinWait ("System Properties")

MsgBox (0, "", "We're going to activate Notepad and controlclick OK on the System Properties window while it's not active.")
WinActivate ("Untitled - ")
Sleep (2000)
ControlClick ("System Properties", "", "OK")

I dont understand!! Help me plz.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Controlclick has the ability to click the window even the window is not active. But not all.

from the helpfile:

Remarks

Some controls will resist clicking unless they are the active window. Use the WinActivate() function to force the control's window to the top before using ControlClick().

If the your controlclick clicking on a button, try to use Controlcommand.

ControlCommand("System Properties", "", "CONTROL ID", "Check", "")

Use the AutoIt window info to get the CONTROL ID of the button.

Edited by nfaustin

[font="Palatino Linotype"][size="2"]*** The information contained in this post should be considered and certified WORKS ON MY MACHINE ***[/size][/font][font="Palatino Linotype"][size="2"] [/size][/font]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Control Click is like clicking, but that window doesn't have to be active.

The ControlClick function takes 3 mandatory parameters:

Title of the window

Text

Control ID

What Exodius is doing is:

ControlClick ("System Properties", "", "OK")

He first tells AutoIT to click on the window with the title "System Properties". For text he makes the parameter null. He finishes by telling AutoIT to click the button that is labeled "OK". This means that even though Notepad is active, it selects the System Properties window and hits the OK button.

-Pandemic

Edited by Pandemic

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

He first tells AutoIT to click on the window with the title "System Properties". For text he makes the parameter null. He finishes by telling AutoIT to click the button that is labeled "OK". This means that even though Notepad is active, it selects the System Properties window and hits the OK button.

Quoted for truth, basically I'm opening two windows (that anyone running Windows XP at least) should be able to open by default, activating one and then showing that you can ControlClick on the other window (the System Properties window) which is inactive.

So if it's not working for you taren9k3, then you may have some fundamental issues on your machine. :)

Edited by exodius

Share this post


Link to post
Share on other sites

A related question, what's the easiest way to send a left mouse click to the close 'x' on a window frame? The WinInfo gadget doesn't give any control IDs for window frame controls.

Share this post


Link to post
Share on other sites

Do you need to actually click on the x? As in WinClose won't work?

Share this post


Link to post
Share on other sites

When I use ControlClick function I have to use WinActivate command before. So I want to ask you are there anyways to use controlclick or some functions else that do not need to use WinActivate. Thanks

Try to call ControlFocus() just before ControlClick().

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Do you need to actually click on the x? As in WinClose won't work?

Yes. The application is a download manager. afaik there's no option to have it start to tray. I'm launching with an app that launches the browser with it, and kills the download manager when the browser closes. If you click the 'x' it minimizes to tray. But I see no way to do it. A sendmessage to the system menu may work if I can dig out how to do it again. But it would be nice if I could just mouse click the 'x' since some apps do owner draw in the frame and sysmenu close may not work with those.

edit: if I send it a 'close' it will shut down instead of hide to tray. If I send it a 'min' then it will show the task bar button. So click on 'x' would be best if it were possible.

Edited by MilesAhead

Share this post


Link to post
Share on other sites

Hmmmmmm, thought a NirCmd sending the window a 'hide' would work. It minimizes to tray, but then the icon menu open won't work. It just shows the button in the taskbar without opening the window.

You'd think this would be easy. :)

Share this post


Link to post
Share on other sites

_WinAPI_SetWindowPlacement may do what you need but you will have to know what command to put in the WINDOWPLACEMENT Structure ($tagWINDOWPLACEMENT).

Get a handle to window, press the X button then call _WinAPI_GetWindowPlacement to find out what the tagWINDOWPLACEMENT->showCmd is.


Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


Link to post
Share on other sites

_WinAPI_SetWindowPlacement may do what you need ...

Thanks for the reply. Turns out in this case the target program also handles Alt-F4 as minimize to tray. I just wrote a few lines of script to make the window active, then send Alt-F4. Seems to do the job well enough for this purpose. :)

Share this post


Link to post
Share on other sites

Someone can make the program that can login to Yahoo without activate Yahoo messenger window.

Share this post


Link to post
Share on other sites

Someone can make the program that can login to Yahoo without activate Yahoo messenger window.

eh?

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

I think he need rentacoder

Edited by nfaustin

[font="Palatino Linotype"][size="2"]*** The information contained in this post should be considered and certified WORKS ON MY MACHINE ***[/size][/font][font="Palatino Linotype"][size="2"] [/size][/font]

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

I think he need rentacoder

Heh. Or he can try http://www.DonationCoder.com in the "Coding Snacks" forum. That's how I ended up doing this one. The minimize to tray thing I'm just doing for myself. Since I wrote the program to launch browser with download manager I figured I might as well use it myself. :)

Edited by MilesAhead

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  
Followers 0