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 

MouseClickGetPos? Lol

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



Joined: 14 Oct 2007
Posts: 44

PostPosted: Thu Dec 13, 2007 2:09 am    Post subject: MouseClickGetPos? Lol Reply with quote

Yeah, I was wondering if there is an actual way for me to detect a mouseclick.

I can somewhat emulate this by using MouseGetPos, but it isn't that effective.

Code:

CoordMode,Mouse,Screen


^g::
MsgBox You will have 3 seconds to move to desired spot.
Sleep 3000
MouseGetPos, ObjectOnScreenX, ObjectOnScreenY
MsgBox You selected %ObjectOnScreenX% , %ObjectOnScreenY%
return

Back to top
View user's profile Send private message AIM Address
Erittaf



Joined: 02 Nov 2007
Posts: 182

PostPosted: Thu Dec 13, 2007 2:11 am    Post subject: Reply with quote

try
Code:
~Lbutton::

the ~ will allow the click to have it's normal effect and then your hotkey can trigger a MouseGetPos or whatever else.
Back to top
View user's profile Send private message Send e-mail
leggah



Joined: 14 Oct 2007
Posts: 44

PostPosted: Thu Dec 13, 2007 2:17 am    Post subject: Reply with quote

huh?

Lol
Back to top
View user's profile Send private message AIM Address
Erittaf



Joined: 02 Nov 2007
Posts: 182

PostPosted: Thu Dec 13, 2007 2:21 am    Post subject: Reply with quote

you are trying to detect when a user clicks the mouse, correct? If so then use this.

Code:
~Lbutton::
...
put whatever AHK code you want to happen every time the left mouse button is clicked here
...


If not, please clarify
Back to top
View user's profile Send private message Send e-mail
leggah



Joined: 14 Oct 2007
Posts: 44

PostPosted: Thu Dec 13, 2007 4:37 am    Post subject: Reply with quote

oh oh!

I see.

Just read the docs

Thanks dude
Back to top
View user's profile Send private message AIM Address
leggah



Joined: 14 Oct 2007
Posts: 44

PostPosted: Thu Dec 13, 2007 3:14 pm    Post subject: Reply with quote

The problem with using ~LButton is that the script after that executes EVERY time the user mouse clicks. How do i set it so that it only does the stuff after

~Lbutton::

once?

-leg
Back to top
View user's profile Send private message AIM Address
Dra_Gon



Joined: 25 May 2007
Posts: 316

PostPosted: Thu Dec 13, 2007 3:47 pm    Post subject: Reply with quote

Well... You could do something like this:

Code:
~Lbutton::
{
myClick += 1
if (myclick = 1)
{
 <<whatever you want it to do that first time goes here>>
}
}


or, simply:
Code:
~Lbutton::
 <<whatever you want it to do that one time goes here>>
exitapp

That way, regardless of how many times you do it after that first click, the code will just ignore them.
There are a bunch of little tricks you can do, depending on what behavior you want. A lot of what I know is just what I've seen in other people's scripts and I modify them here and there to experiment.
Good luck!

Dra'Gon
_________________

For a good laugh {hopefully} >> megamatts.50megs.com

My WritersCafe profile>>
http://www.writerscafe.org/writers/BlueDragonFire/
Back to top
View user's profile Send private message Send e-mail
leggah



Joined: 14 Oct 2007
Posts: 44

PostPosted: Sun Dec 16, 2007 1:06 am    Post subject: Reply with quote

Thanks for that Dra_gon

I thought it would work with my object with a few modifications
But it seems like its not working

I understand that myClick+ increments it by one every time the left button is clicked, but I want to do something else at some other time.

I tried this but it was a complete failure. LOL

Code:


~LButton::

if clicks:=1
{
   MsgBox Blah
   clicks=clicks+clicks+1
}
else
   MsgBox Whoa
return



^q::
MsgBox click is now equal to 1

clicks:=1
return


edit: basically, if I dont press crtl+q, there will be no prompt, it will not "do" anything
Back to top
View user's profile Send private message AIM Address
haichen



Joined: 05 Feb 2007
Posts: 140
Location: Osnabrück, Germany

PostPosted: Sun Dec 16, 2007 12:57 pm    Post subject: Reply with quote

Try this:
Code:
clicks:=1
~LButton::
if (clicks =1)
{
   MsgBox Blah
   clicks=0
}
else
   MsgBox Whoa
return

^q::
MsgBox click is now reset to 1. Dont click on me. Take the Enter button.
clicks:=1
return


Have a look at your IF statement: No :=. Thats an assignment.

Quote:
clicks=clicks+clicks+1

clicks = 0 --> 1
clicks = 1 --> 3
clicks = 3 --> 7
...

if you want to add 1 everytime you could do this:
Code:
clicks := clicks + 1

or shorter
Code:
clicks += 1
Back to top
View user's profile Send private message
leggah



Joined: 14 Oct 2007
Posts: 44

PostPosted: Sun Dec 16, 2007 6:30 pm    Post subject: Reply with quote

Thank you. That works smoothly.

I thought := was used for integers and = was for strings. my bad
Back to top
View user's profile Send private message AIM Address
Lexikos



Joined: 17 Oct 2006
Posts: 2739
Location: Australia, Qld

PostPosted: Mon Dec 17, 2007 12:19 am    Post subject: Reply with quote

Standalone, := is used for evaluating an expression and assigning the result, while = is used for assigning text (with simple text substitutions.)
In an If or expression, := is used for assignment, while = is used for comparison. I think == (equal to / "equal two") is clearer for that, but in AutoHotkey == is case-sensitive.

If I'm reading your example correctly, KeyWait may be more appropriate than a hotkey:
Code:
CoordMode,Mouse,Screen

^g::
    KeyWait, LButton, D ; wait for LButton down
    KeyWait, LButton    ; wait for LButton up (optional)
    MouseGetPos, ObjectOnScreenX, ObjectOnScreenY
    MsgBox You selected %ObjectOnScreenX% , %ObjectOnScreenY%
return

If you want to block the click, you can use the Hotkey command:
Code:
CoordMode,Mouse,Screen

^g::
    Hotkey, LButton, Clicked, On
return
Clicked:
    Hotkey, LButton, Clicked, Off
    MouseGetPos, ObjectOnScreenX, ObjectOnScreenY
    MsgBox You selected %ObjectOnScreenX% , %ObjectOnScreenY%
return
Back to top
View user's profile Send private message
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