Sign in to follow this  
Followers 0
leuce

Perform action after mouseclick

14 posts in this topic

G'day everyone

Well I know this is simple but I just spent 10 frustrating minutes with the helpfile, to no avail. How do I get AutoIt to do something when the user clicks with his mouse?

Thanks

Samuel

Share this post


Link to post
Share on other sites



you must create a gui, before anything can happen. See helpfile:

AutoIT -> GUI Reference -> GUI Concepts.

also check some sample code like the example for GUICtrlCreateMenu(). You create a GUI and then you process the window messages via GUIGetMsg().

Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

#include <Misc.au3>

$dll = DllOpen("user32.dll")

While 1
    Sleep ( 250 )
    If _IsPressed("01", $dll) Then
        MsgBox(0,"_IsPressed", "Mouse was clicked")
        ExitLoop
    EndIf
WEnd
DllClose($dll)

straight from help file (_IsPressed)

Share this post


Link to post
Share on other sites

How do I get AutoIt to do something when the user clicks with his mouse?

Hmm, I see beta has an "IsPressed" function...

Sameul

Share this post


Link to post
Share on other sites

Hmm, I see beta has an "IsPressed" function...

Sameul

maybe you should tell us more detailed what you intend to do...

Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

you must create a gui, before anything can happen.

Thanks, but I was under the impression that such functions will then only be applicable to the created GUI. What I want is to let the script perform a function when the user clicks an existing non-AutoIt window.

I'll tell you what I'm trying to do... my browser, Opera, doesn't have the most extensive History function and I'd like a script which keeps a detailed history of all pages I have visited. To do this, the script should save the text of the statusbar whenever a user clicks while Opera is the active window.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

look at _ispressed in the beta help file!!!!!111!!1!!!

eidt: didn't read whole post

Edited by codemyster

Share this post


Link to post
Share on other sites

I'll tell you what I'm trying to do... my browser, Opera, doesn't have the most extensive History function and I'd like a script which keeps a detailed history of all pages I have visited. To do this, the script should save the text of the statusbar whenever a user clicks while Opera is the active window.

Hmm, rats. I had thought that the status bar in Opera was called OperaWindowClass1, but it isn't. I'm gonna have to figure out another way to capture the URL of the link under the mouse. This outputs blanks:

#include <Misc.au3>
$dll = DllOpen("user32.dll")

While 1
Sleep ( 250 )
If _IsPressed("01", $dll) Then
$var = ControlGetText("Opera", "", "OperaWindowClass1")
$foo = FileOpen("bla.txt", 1)
FileWrite ($foo, "<a href=""" & $var & """>" & $var & "</a><br>" & @CRLF)
FileClose ($foo)
EndIf
WEnd

DllClose($dll)

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

I'll tell you what I'm trying to do... my browser, Opera, doesn't have the most extensive History function and I'd like a script which keeps a detailed history of all pages I have visited. To do this, the script should save the text of the statusbar whenever a user clicks while Opera is the active window.

Ah, O.K. Then you could do this:

  • Detect if the mouse was clicked AND any Opera windows was active via _IsPressed() and WinActive() (see also WinTitleMatchMode (Option) ).
  • Check if the mouse was clicked within the Opera Window: WinGetPos and MouseGetPos.
  • Try to read the text from the Opera URL bar. See tool: AutoIT Window Info and ControlGetText().
EDIT: See also these links: http://www.autoitscript.com/forum/index.ph...p;hl=opera++url http://www.autoitscript.com/forum/index.ph...p;hl=opera++url

Cheers

Kurt

Edited by /dev/null

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

Try to read the text from the Opera URL bar.

Unfortunately, as a security feature in Opera, the new URL isn't displayed in the URL bar (I assume you mean the address field) until after the server responds. This means that the current page's URL remains in the URL bar for a few seconds until the new page starts loading.

Fortunately, the link under the mouse cursor is displayed in Opera's status bar... (unless some fancy Javascript on the page hides it, but that rarely happens in the web sites I generally visit) but now I have to figure out what that status bar's control is named.

Thanks for your help.

Samuel

Share this post


Link to post
Share on other sites

on the page hides it, but that rarely happens in the web sites I generally visit) but now I have to figure out what that status bar's control is named.

I did a quick check. The control in Opera 9 is called OperaWindowClass3 HOWEVER the shown text is not the URL, so you cannot read the url with ControlGetText.

I also did check the history function of Opera. It looks good to me, so what exactly are you missing? Maybe there are other tools to enhance that functionality....

Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

I also did check the history function of Opera. It looks good to me, so what exactly are you missing? Maybe there are other tools to enhance that functionality...

If you play around with the history a little more, you'll discover that certain types of URLs are simply not added to the History (I can't figure out which, right now, but I have on many occasions visited the History in the hope to find the URL of a page I visited a few minutes before, only to find that it has not been added to the History).

Also, if you revisit a page during the same day, Opera moves the history item up to the top, thereby destroying the chronological path of your surfing expedition. If, for example, I can remember that I had visited X shortly after I had visited Y, then Opera's history will only be of any help if I can tell for certain that I hadn't visited X or Y in the mean time for a second time. In fact, if I go to the history and click a link, that link is moved to the top of the history.

In addition, only pages that have been successfully visited, gets added to the history. So say for example I google for something and then I click several links, those links will not be added to the history unless they load successfull (and they'll be added not in the order that I clicked them, but in the order that their servers started responding).

Opera's history entries can't be sorted. For example, if I surf many windows at the same time, the history will be populated with all the pages from each web site all jumbled up, but if I have my own history file, then I can sort by URL so that all pages from one web site are grouped together. I can also search by URL (in Opera, the URL is not displayed in the history... instead, the web site's title is displayed, even if it is "Type your title here" or "Untitled" or simlar). Of course, ideally one would like to capture both URL and web site title, but I'll cross that bridge when I get to it.

In the mean time... it has occured to me that it may be possible to capture the feed that Opera sends to the point of presence and extract the URL from that... if I can get AutoIt to capture that feed. :-)

Share this post


Link to post
Share on other sites

The control in Opera 9 is called OperaWindowClass3...

Sadly, Opera 9 malfunctions on my computer, and I'm forced to use Opera 8 (but Opera 8 is quite functional, so it's no big deal). It if wasn't for the utter lack of userfriendliness in FireFox I would have switched long ago (although I do use FF at the moment for certain stuff, like Gmail).

Samuel

Share this post


Link to post
Share on other sites

In the mean time... it has occured to me that it may be possible to capture the feed that Opera sends to the point of presence and extract the URL from that... if I can get AutoIt to capture that feed. :-)

well, no. You can't capture the IP packets with AutoIT. However, you could install a HTTP proxy software on your computer and change the proxy settings of Opera to point to that proxy. If so configured, the proxy will log every URL for you and you could then parse the logs with AutoIT and do whatever you want with that data.

Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

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