AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

click something from browser without specifying x, y, value

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Wed Oct 27, 2004 2:29 am    Post subject: click something from browser without specifying x, y, value Reply with quote

Is there a way to click something from a web browser without specifying the x, y, coordinates. may be, by specifying a word or icon in that window?
Basically, I want to use something in my script that will click on a specific icon in the active window.
Back to top
Gre



Joined: 12 Oct 2004
Posts: 77
Location: São Paulo ,Brazil

PostPosted: Wed Oct 27, 2004 3:25 am    Post subject: Reply with quote

You can try "PixelSearch".If there are other web page element with same colors you can try PixelSearch
combined with "StatusBarGetText"
Back to top
View user's profile Send private message
BoBo
Guest





PostPosted: Wed Oct 27, 2004 11:29 am    Post subject: Reply with quote

I've followed Gre's nice advise - but tweaked it to check for a known link/URL and where its positioned on the screen/webpage.

Exclamation Exclamation To run that script (AHK 1.0.22) you should add a hotkey to break the loop if necessary, as you won't be able to stop it using the mouse Exclamation Exclamation

Code:
SetBatchLines -1
SetTitleMatchMode, 2
WinActivate, AutoHotkey  ; Testing - activate the Autohotkey Forum
Y = 1   

Loop
   {
   X ++
   If X = %A_ScreenWidth% ; if max x coord has been reached
      {
      X = 1 ; restart at X coord
                   Y ++ ; move to next [i]line[/i]
      }
      If Y = %A_ScreenHeight% ; if max y coord has been reached - bye
         ExitApp
   MouseMove,%X%,%Y%, 0 ; moving the mouse
   StatusBarGetText, OutputVar, 1, AutoHotkey ; check the statusbar for the expected link info
   If OutputVar = http://www.autohotkey.com/ ; detected AHK's link/image - click to move to AHK's home
   {
   MouseClick, L,,, 2
   Break
   }


Unfortunately the MouseMove is acting quite slow.

Cool
Back to top
ILL.1



Joined: 29 Sep 2004
Posts: 84

PostPosted: Wed Oct 27, 2004 11:40 am    Post subject: Reply with quote

Run window spy and see if the button you're looking for is shown. Then add that as ahk_CLASS#. Where CLASS is the type of button object and # is the number of that object. Also, you could try PostMessage or SendMessage. Look through the documentation for Winamp. There is a very nice example in there.
_________________
===============
----------ILL.1-----------
===============
Back to top
View user's profile Send private message
dijiyd



Joined: 31 Mar 2004
Posts: 90
Location: Philippines

PostPosted: Wed Oct 27, 2004 11:41 am    Post subject: Reply with quote

This icon, does it submit a form? (Though this method need that you know some html and a little javascript)
Back to top
View user's profile Send private message
Guest






PostPosted: Wed Oct 27, 2004 11:51 am    Post subject: Reply with quote

Here is the link to the website: http://www.webster.com/cgi-bin/dictionary?book=Dictionary&va=absolute

and my icon of interest is the red speaker box for the audio file next to the word absolute ..
Back to top
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10474

PostPosted: Wed Oct 27, 2004 12:14 pm    Post subject: Reply with quote

Another thing I've had success with, at least in MSIE, is to press Ctrl-F to bring up the find window, type the text of a word close to the desired button (the one you want to click). After the find is complete, do "Send {tab}{Enter}" to set focus to the button and press it.

In your example, search for "Main Entry" then do "Send {tab}{Enter}".
Back to top
View user's profile Send private message Send e-mail
Guest






PostPosted: Wed Oct 27, 2004 12:18 pm    Post subject: Reply with quote

thats what i first try to do but i couldn't figure out how to search (or atleast the command for the search)...
Back to top
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10474

PostPosted: Wed Oct 27, 2004 12:48 pm    Post subject: Reply with quote

In MSIE, it would be something like this:

Send, ^f
WinWaitActive, Find
Send, Main Entry{enter}
Sleep, 200
Send {tab}{Enter}
Back to top
View user's profile Send private message Send e-mail
BoBo
Guest





PostPosted: Wed Oct 27, 2004 1:55 pm    Post subject: Reply with quote

Quote:
Here is the link to the website http://www.webster.com/cgi-bin/dictionary?book=Dictionary&va=absolute
Shocked

That link gave me the idea that different people - working on the same issue - in separate threads - in parallel. Check this out: [here]

If that's true - MHO - I'm not amused Confused
Back to top
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10474

PostPosted: Wed Oct 27, 2004 2:58 pm    Post subject: Reply with quote

I think they're different: the other one wanted to move the mouse onto something, this topic is about pressing the button.
Back to top
View user's profile Send private message Send e-mail
tpatel5



Joined: 27 Oct 2004
Posts: 65
Location: GA

PostPosted: Wed Oct 27, 2004 3:03 pm    Post subject: Reply with quote

NO Bobo is right it was me (tpatel5)!!!! but forgot to login Smile
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10474

PostPosted: Wed Oct 27, 2004 3:04 pm    Post subject: Reply with quote

Thanks for admitting your guilt Smile
Back to top
View user's profile Send private message Send e-mail
cstone



Joined: 16 Apr 2005
Posts: 28

PostPosted: Tue Apr 26, 2005 12:52 am    Post subject: Reply with quote

If you make a hot key with this code and run it, it will desplay the form number and element number of all items on the page. look for the button you want and write the first two number down. the first being the from the second the element.

javascript:function ROIoiW(){var i=0,j,A='anonymous',D,E,F=document.forms;while(i<F.length){E=F[i].elements;for(j=0;j<E.length;j++){D=E[j];alert(i+'/'+j+'/'+D.type+'-'+E.name+'-'+D.name+'-'+D.value)}i++}}ROIoiW();void(null)

from there you can use this code to click the button

text = javascript:document.forms[the first number].element[second number].focus()
ControlSetText, Edit1, %test1%, A
ControlFocus, Edit1, A
Send {ENTER};this enter exacutes the javascript
Send {ENTER};this should click the button
_________________
cstone
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10474

PostPosted: Tue Apr 26, 2005 1:55 am    Post subject: Reply with quote

Thanks for sharing another cool javascript technique.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group