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 

Need help w/ hotkey to execute an onclick button on webpage.
Goto page 1, 2, 3, 4, 5, 6  Next
 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
4birds



Joined: 06 Mar 2008
Posts: 167

PostPosted: Thu Nov 05, 2009 12:19 am    Post subject: Need help w/ hotkey to execute an onclick button on webpage. Reply with quote

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
View user's profile Send private message
Ace Coder



Joined: 26 Oct 2009
Posts: 361

PostPosted: Thu Nov 05, 2009 12:28 am    Post subject: Reply with quote

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
View user's profile Send private message
Leef_me



Joined: 08 Apr 2009
Posts: 5336
Location: San Diego, California

PostPosted: Thu Nov 05, 2009 1:22 am    Post subject: Reply with quote

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
View user's profile Send private message
4birds



Joined: 06 Mar 2008
Posts: 167

PostPosted: Thu Nov 05, 2009 1:40 am    Post subject: Reply with quote

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
View user's profile Send private message
MasterFocus



Joined: 08 Apr 2009
Posts: 3035
Location: Rio de Janeiro - RJ - Brasil

PostPosted: Thu Nov 05, 2009 1:47 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
4birds



Joined: 06 Mar 2008
Posts: 167

PostPosted: Thu Nov 05, 2009 2:13 am    Post subject: Reply with quote

To be honest I know COM. can you give a brief example of a COM script that utilizes a hotkey?
Back to top
View user's profile Send private message
Leef_me



Joined: 08 Apr 2009
Posts: 5336
Location: San Diego, California

PostPosted: Thu Nov 05, 2009 2:20 am    Post subject: Reply with quote

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
View user's profile Send private message
4birds



Joined: 06 Mar 2008
Posts: 167

PostPosted: Thu Nov 05, 2009 2:27 am    Post subject: Reply with quote

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
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 2462

PostPosted: Thu Nov 05, 2009 2:41 am    Post subject: Reply with quote

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
View user's profile Send private message
Leef_me



Joined: 08 Apr 2009
Posts: 5336
Location: San Diego, California

PostPosted: Thu Nov 05, 2009 2:49 am    Post subject: Reply with quote

Does the vertical scrollbar on the side of the browser count ? Wink 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: Embarassed 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
View user's profile Send private message
4birds



Joined: 06 Mar 2008
Posts: 167

PostPosted: Thu Nov 05, 2009 3:14 am    Post subject: Reply with quote

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
View user's profile Send private message
4birds



Joined: 06 Mar 2008
Posts: 167

PostPosted: Thu Nov 05, 2009 3:17 am    Post subject: Reply with quote

scratch that, the element does NOT remain constant. Sean ,your thoughts?
Back to top
View user's profile Send private message
Ace Coder



Joined: 26 Oct 2009
Posts: 361

PostPosted: Thu Nov 05, 2009 3:19 am    Post subject: Reply with quote

You will need to #include
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 2462

PostPosted: Thu Nov 05, 2009 3:33 am    Post subject: Reply with quote

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
View user's profile Send private message
4birds



Joined: 06 Mar 2008
Posts: 167

PostPosted: Thu Nov 05, 2009 4:13 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Goto page 1, 2, 3, 4, 5, 6  Next
Page 1 of 6

 
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