| View previous topic :: View next topic |
| Author |
Message |
Guest
|
Posted: Wed Oct 27, 2004 2:29 am Post subject: click something from browser without specifying x, y, value |
|
|
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
|
Posted: Wed Oct 27, 2004 3:25 am Post subject: |
|
|
You can try "PixelSearch".If there are other web page element with same colors you can try PixelSearch
combined with "StatusBarGetText" |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Wed Oct 27, 2004 11:29 am Post subject: |
|
|
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.
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
| 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.
 |
|
| Back to top |
|
 |
ILL.1
Joined: 29 Sep 2004 Posts: 84
|
Posted: Wed Oct 27, 2004 11:40 am Post subject: |
|
|
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 |
|
 |
dijiyd
Joined: 31 Mar 2004 Posts: 90 Location: Philippines
|
Posted: Wed Oct 27, 2004 11:41 am Post subject: |
|
|
| This icon, does it submit a form? (Though this method need that you know some html and a little javascript) |
|
| Back to top |
|
 |
Guest
|
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10474
|
Posted: Wed Oct 27, 2004 12:14 pm Post subject: |
|
|
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 |
|
 |
Guest
|
Posted: Wed Oct 27, 2004 12:18 pm Post subject: |
|
|
| 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
|
Posted: Wed Oct 27, 2004 12:48 pm Post subject: |
|
|
In MSIE, it would be something like this:
Send, ^f
WinWaitActive, Find
Send, Main Entry{enter}
Sleep, 200
Send {tab}{Enter} |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Wed Oct 27, 2004 1:55 pm Post subject: |
|
|
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  |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10474
|
Posted: Wed Oct 27, 2004 2:58 pm Post subject: |
|
|
| 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 |
|
 |
tpatel5
Joined: 27 Oct 2004 Posts: 65 Location: GA
|
Posted: Wed Oct 27, 2004 3:03 pm Post subject: |
|
|
NO Bobo is right it was me (tpatel5)!!!! but forgot to login  |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10474
|
Posted: Wed Oct 27, 2004 3:04 pm Post subject: |
|
|
Thanks for admitting your guilt  |
|
| Back to top |
|
 |
cstone
Joined: 16 Apr 2005 Posts: 28
|
Posted: Tue Apr 26, 2005 12:52 am Post subject: |
|
|
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 |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10474
|
Posted: Tue Apr 26, 2005 1:55 am Post subject: |
|
|
| Thanks for sharing another cool javascript technique. |
|
| Back to top |
|
 |
|