Jump to content

How do I click an icon?


Guest Anders
 Share

Recommended Posts

Guest Anders

Hi!

I am new to AutoIt. I am writing a script to customize Windows XP. I just need an answer to two very simple questions: :ph34r:

The first thing I would like to do, is to customize the Control Panel,

So I open it, switch to classic mode and switch to Detailed view mode with the following code:

; /// Open Control Panel

Run("control.exe")

WinWaitActive("Control Panel")

; /// Now that the Control Panel is active switch to Classic View

AutoItSetOption ( "MouseCoordMode", 0 )

MouseClick ( "left" , 50, 175 )

; /// Switch to detailed icon view

ControlSend("Control Panel", "", "DirectUIHWND1", "^D")

Question 1) Well, this work fine, but I guess the way I switch to Classic View is "the amateur way". I guess the best way would be to figure out where in the control panel it says "Switch to Classic View" and then click this text. How do I do this?

Question 2)

Well after I swicthed to Classic View and set the Icons list view to Details (from the menu View > Details) I would like to click some of the icons in the Control Panel. How do I click the "Folder Options" icon and then select the "View" Fan in the upcoming dialog? I know that I could reach this dialog through the menu (Tools > Folder Options), but I would like to do it the "icon way". I know that many of the icons can be reached by running the the cpl (control mouse). But right now I would just like to know how to (double)click the icon. I think that clicking an icon by its coordinates is to risky!

Thanks in advance!

/Anders

Link to comment
Share on other sites

avoid the user interfaces where possible... google search found me this:

starting control panel applets with rundll32

which teaches us that this opens the display control panel:

Rundll32.exe shell32.dll,Control_RunDLL Desk.cpl

in autoit:

run("Rundll32.exe shell32.dll,Control_RunDLL Desk.cpl"

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

Under Windows 98, there is a program called Control.exe that runs the control panel applets.

Run("Control.exe Desk.cpl")

There is a way of specifying which tab to start on, but I forget it right now.

David Nuttall
Nuttall Computer Consulting

An Aquarius born during the Age of Aquarius

AutoIt allows me to re-invent the wheel so much faster.

I'm off to write a wizard, a wonderful wizard of odd...

Link to comment
Share on other sites

Under Windows 98, there is a program called Control.exe that runs the control panel applets.

Run("Control.exe Desk.cpl")

There is a way of specifying which tab to start on, but I forget it right now.

probably the same as what they say in that link I found ,# or something, starting at 0 for first tab...

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

Guest Anders

probably the same as what they say in that link I found ,# or something, starting at 0 for first tab...

Hi again!

First - thanks for all the answers!

As I wrote in my question, I know about running the CPLs like I mentioned in question 2 (control mouse).

But if I would like to click the text "Switch to Classic View"

Posted Image

and then click an icon with the name Folder Options

Posted Image

How do I do that?

Is it not possible?

Or can it only be done by using coordinates?

Thanks again - Anders

Link to comment
Share on other sites

AutoIt can send mouseclicks two ways (someone correct me if I'm wrong)

  • ControlClick ( "title", "text", "classnameNN" [, button] [, clicks]] )

    Sends a click to a specific control, AU3 spy shows "Last Control Under Mouse" if the item you're trying to click isn't a contol, this won't work.

  • MouseClick ( "button" [, x, y [, clicks [, speed ]]] )

    Which clicks by coordinates.

There is no way to tell AutoIt "Click X icon"

As I was saying, the best way to do things is by avoiding mouse coords... I just found that by tabbing twice after the control panel's open then hitting enter, it highlights the desired link. However, if they're already on classic view, it selects the control panel header... procieding from there, hit tab X times to get into the icon list and send "folder options" to select the folder options icon, then hit enter.

However, I'd suggest finding a better way, such as the rundll method for opening control panels, something that doesn't rely on the user not already using the classic view...

oh yeah, and rtfm, look for "click" that will tell you what I've just told you about AutoIt's methods for clicking things.

Edited by emmanuel

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...