Sign in to follow this  
Followers 0
Sajesh

Click link in a GUI

12 posts in this topic

Hi,

I am a beginner in Auto IT.

I need to click a link in GUI window.

Can anyone guide me with the functions needed to click a link in GUI.

Thanks!

Share this post


Link to post
Share on other sites



Welcome!

Example:

#include <GuiConstants.au3>

Global $Flag = 1

$hGui = GUICreate(":-)", 240, 120)

$URL_Label = GUICtrlCreateLabel("Welcome to AutoIT forum", 60, 40, 130, 16)
GUICtrlSetCursor(-1, 0)
;GUICtrlSetBkColor(-1, 0xFF0000)

GUISetState()

While 1
    $msg = GUIGetMsg()
    
    Switch $msg
    Case $GUI_EVENT_CLOSE
        ExitLoop
    Case $GUI_EVENT_MOUSEMOVE
        $aCurPos = GUIGetCursorInfo()
        
        If $aCurPos[4] = $URL_Label And $Flag = 1 Then
            GUICtrlSetColor($URL_Label, 0xFF0000)
            GUICtrlSetFont($URL_Label, Default, Default, 2)
            $Flag = 0
        ElseIf $aCurPos[4] <> $URL_Label And $Flag = 0 Then
            GUICtrlSetColor($URL_Label, 0x000000)
            GUICtrlSetFont($URL_Label, Default)
            $Flag = 1
        EndIf
    Case $URL_Label
        ShellExecute("http://www.autoitscript.com/forum")
    EndSwitch
WEnd
:)

Share this post


Link to post
Share on other sites

I need to click a link in GUI window.

Not really sure but I think he wanted to know how to click on a link, not create a GUI with a link.

@Sajesh...is it a IE window that has the link?...If so look in the helpfile for IE functions.

Share this post


Link to post
Share on other sites

Not really sure but I think he wanted to know how to click on a link, not create a GUI with a link.

@Sajesh...is it a IE window that has the link?...If so look in the helpfile for IE functions.

Sorry for not explaining my question well.

Actually I am testing a window that has a link.

My objective is to click that link in the GUI window without using mouse and I dont have the URL of that link.

How can I recognize that link in the window and click it with the keyboard.

Please explain.

Share this post


Link to post
Share on other sites

@Sajesh..You can try getting the control name of the link by using the Autoit Window Spy ("C:\Program Files\AutoIt3\Au3Info.exe").

Share this post


Link to post
Share on other sites

@Sajesh..You can try getting the control name of the link by using the Autoit Window Spy ("C:\Program Files\AutoIt3\Au3Info.exe").

But spy is not recognizing the link. Is there any other way?

Share this post


Link to post
Share on other sites

Welcome!

Example:

#include <GuiConstants.au3>

Global $Flag = 1

$hGui = GUICreate(":-)", 240, 120)

$URL_Label = GUICtrlCreateLabel("Welcome to AutoIT forum", 60, 40, 130, 16)
GUICtrlSetCursor(-1, 0)
;GUICtrlSetBkColor(-1, 0xFF0000)

GUISetState()

While 1
    $msg = GUIGetMsg()
    
    Switch $msg
    Case $GUI_EVENT_CLOSE
        ExitLoop
    Case $GUI_EVENT_MOUSEMOVE
        $aCurPos = GUIGetCursorInfo()
        
        If $aCurPos[4] = $URL_Label And $Flag = 1 Then
            GUICtrlSetColor($URL_Label, 0xFF0000)
            GUICtrlSetFont($URL_Label, Default, Default, 2)
            $Flag = 0
        ElseIf $aCurPos[4] <> $URL_Label And $Flag = 0 Then
            GUICtrlSetColor($URL_Label, 0x000000)
            GUICtrlSetFont($URL_Label, Default)
            $Flag = 1
        EndIf
    Case $URL_Label
        ShellExecute("http://www.autoitscript.com/forum")
    EndSwitch
WEnd
:)
Thanks Rasim! I gained a lot of knowledge from ur code.

Share this post


Link to post
Share on other sites

But spy is not recognizing the link. Is there any other way?

Can we have the app name... maybe someone can show you easily rather than guessing what it would be.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Can we have the app name... maybe someone can show you easily rather than guessing what it would be.

It is an XML based application.

Share this post


Link to post
Share on other sites

Can we have the app name... maybe someone can show you easily rather than guessing what it would be.

It is an XML based application.

Share this post


Link to post
Share on other sites

It is an XML based application.

Please consider this example:

Open IE 7

Click Help--> About.

In the about window there is a link '2006 Microsoft Corporation'.

Auto IT spy is not recognizing this link.

Share this post


Link to post
Share on other sites

Is the link in a dedicated position? Maybe you can just click it using coordinates?

Opt("MouseCoordMode", 2)    ;2 = relative coords to the client area of the active window
WinActivate("About Internet Explorer")
MouseClick("primary", 148, 288)

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