| View previous topic :: View next topic |
| Author |
Message |
4birds
Joined: 06 Mar 2008 Posts: 167
|
Posted: Thu Nov 05, 2009 12:19 am Post subject: Need help w/ hotkey to execute an onclick button on webpage. |
|
|
Hey guys, I'd like to execute an onclick button on a website without using MouseClick to send it to the x,y coordinates.
The website I need it on is an internal work site so I can't give the address. I'd like to create a script such that when a hotkey is pressed it executes an onclick button on the webpage.
Using tank's iWebBrowser2 Learner, I got the button's info.ID=save, onclick=process(event) and I'm not sure if this is relevant but the EleIndex is 591.
I know I need more. Can you point me in the right direction
I tried looking on the forum for an answer to this but haven't found it.
Thanks for your help. |
|
| Back to top |
|
 |
Ace Coder
Joined: 26 Oct 2009 Posts: 361
|
Posted: Thu Nov 05, 2009 12:28 am Post subject: |
|
|
| I havent had the need to do browser automation nor do I know how to really but... Com is all I can suggest. Sean was on earlier maybe he will post and help afterall he made the com library. |
|
| Back to top |
|
 |
Leef_me
Joined: 08 Apr 2009 Posts: 5336 Location: San Diego, California
|
Posted: Thu Nov 05, 2009 1:22 am Post subject: |
|
|
I don't know what an "onclick button" is.
| Quote: | | without using MouseClick |
Why can't you use MouseClick command ?
All three of these routines below ,use the mouse to do the clicking.
| Code: | #Persistent
CoordMode, ToolTip, screen ; without these commands, x & y are realative to window
CoordMode, Mouse, screen
CoordMode, Pixel, screen
x=-425
y=225
return
F1::
mousegetpos, xp, yp
mousemove,x,y, 50
mouseclick, left
mousemove,xp,yp, 50
return
f2::
Click, left %X%, %Y%
RETURN
f3::
Send {Click %X%, %Y%, left}
return |
|
|
| Back to top |
|
 |
4birds
Joined: 06 Mar 2008 Posts: 167
|
Posted: Thu Nov 05, 2009 1:40 am Post subject: |
|
|
sorry, the onclick command is a function within a webpage.
so, if you were to click the button on a webpage with your mouse it would trigger whatever that button was programmed to do.
One of my problems is that the button will change x,y coordinates every so often and of course is different on each computer that I own. |
|
| Back to top |
|
 |
MasterFocus
Joined: 08 Apr 2009 Posts: 3035 Location: Rio de Janeiro - RJ - Brasil
|
Posted: Thu Nov 05, 2009 1:47 am Post subject: |
|
|
I suggest COM or maybe ImageSearch. _________________ "Read the manual. Read it again. Search the forum.
Try something before asking. Show what you've tried."
Antonio França
My stuff: Google Profile |
|
| Back to top |
|
 |
4birds
Joined: 06 Mar 2008 Posts: 167
|
Posted: Thu Nov 05, 2009 2:13 am Post subject: |
|
|
| To be honest I know COM. can you give a brief example of a COM script that utilizes a hotkey? |
|
| Back to top |
|
 |
Leef_me
Joined: 08 Apr 2009 Posts: 5336 Location: San Diego, California
|
Posted: Thu Nov 05, 2009 2:20 am Post subject: |
|
|
| Flight4birds wrote: | | sorry, the onclick command is a function within a webpage. | Thanks. I seem to have come across that term when I did a "view ->source" on a webpage. I didn't remember until you jogged my memory.
FYI, I know imagesearch pretty well, if COM doesn't work for you. |
|
| Back to top |
|
 |
4birds
Joined: 06 Mar 2008 Posts: 167
|
Posted: Thu Nov 05, 2009 2:27 am Post subject: |
|
|
| Leef_Me, you said you know imagesearch, but can you make a script that will mouseclick the coordinates of an image, even if the image shows up on different places from time to time? |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2462
|
Posted: Thu Nov 05, 2009 2:41 am Post subject: |
|
|
Does the element index 591 remain constant? Then, you may try
| Code: | | COM_Invoke(pwb, "document.all[591].click") ; with AHK and COM | or | Code: | | pwb.document.all(591).click() ; with AHK_L and COM_L |
|
|
| Back to top |
|
 |
Leef_me
Joined: 08 Apr 2009 Posts: 5336 Location: San Diego, California
|
Posted: Thu Nov 05, 2009 2:49 am Post subject: |
|
|
Does the vertical scrollbar on the side of the browser count ? Check out the two scripts in my post.
http://www.autohotkey.com/forum/viewtopic.php?p=290383#290383
Just to get a running start, I suggest trying out the first script in that post.
Please be forwarned, it does a UrlDownloadToFile if it doesn't find the needed gif in the same directory as your script.
btw, for images I want to detect that aren;t read-made gifs, I use printscreen and paint and save as 24 bit BMP.
edit: you'll need to add a mouseclick statement or change the mousemove statement.
edit2: of course, the image will have to be visible to be found by imagesearch |
|
| Back to top |
|
 |
4birds
Joined: 06 Mar 2008 Posts: 167
|
Posted: Thu Nov 05, 2009 3:14 am Post subject: |
|
|
Sean, thanks for your response.
Now while I'm not necessarily new to AHK, I'm not a good programmer and have not used COM yet.
I do have it in my AHK folder, but never really understood what exactly it was for.
Anyways, element index 591 does remain constant.
So let's say I only want to click that element index only at certain times, can I use a hotkey to trigger it?
I mean would something like this work?
| Code: |
^a::
COM_Invoke(pwb, "document.all[591].click")
|
or do COM scripts not work like this?
Where do I need to place the AHK script so it will correct work with COM?
Essential, if I'm uses COM scripts, where do I place them and how do I activate them?
Sean, thanks for your help and patience. |
|
| Back to top |
|
 |
4birds
Joined: 06 Mar 2008 Posts: 167
|
Posted: Thu Nov 05, 2009 3:17 am Post subject: |
|
|
| scratch that, the element does NOT remain constant. Sean ,your thoughts? |
|
| Back to top |
|
 |
Ace Coder
Joined: 26 Oct 2009 Posts: 361
|
Posted: Thu Nov 05, 2009 3:19 am Post subject: |
|
|
| You will need to #include |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2462
|
Posted: Thu Nov 05, 2009 3:33 am Post subject: |
|
|
You can/better use Id, save, if the save Id is unique. You have to first store pwb as a global variable.
| Code: | | ^a::COM_Invoke(pwb, "document.all[save].click") |
|
|
| Back to top |
|
 |
4birds
Joined: 06 Mar 2008 Posts: 167
|
Posted: Thu Nov 05, 2009 4:13 am Post subject: |
|
|
| Sean, it didn't seem to work. the save ID is unique. Is the code you packaged up all ready to go or did I need to add something? |
|
| Back to top |
|
 |
|