| View previous topic :: View next topic |
| Author |
Message |
leggah
Joined: 14 Oct 2007 Posts: 44
|
Posted: Thu Dec 13, 2007 2:09 am Post subject: MouseClickGetPos? Lol |
|
|
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 |
|
 |
Erittaf
Joined: 02 Nov 2007 Posts: 182
|
Posted: Thu Dec 13, 2007 2:11 am Post subject: |
|
|
try
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 |
|
 |
leggah
Joined: 14 Oct 2007 Posts: 44
|
Posted: Thu Dec 13, 2007 2:17 am Post subject: |
|
|
huh?
Lol |
|
| Back to top |
|
 |
Erittaf
Joined: 02 Nov 2007 Posts: 182
|
Posted: Thu Dec 13, 2007 2:21 am Post subject: |
|
|
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 |
|
 |
leggah
Joined: 14 Oct 2007 Posts: 44
|
Posted: Thu Dec 13, 2007 4:37 am Post subject: |
|
|
oh oh!
I see.
Just read the docs
Thanks dude |
|
| Back to top |
|
 |
leggah
Joined: 14 Oct 2007 Posts: 44
|
Posted: Thu Dec 13, 2007 3:14 pm Post subject: |
|
|
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 |
|
 |
Dra_Gon
Joined: 25 May 2007 Posts: 316
|
Posted: Thu Dec 13, 2007 3:47 pm Post subject: |
|
|
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 |
|
 |
leggah
Joined: 14 Oct 2007 Posts: 44
|
Posted: Sun Dec 16, 2007 1:06 am Post subject: |
|
|
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 |
|
 |
haichen
Joined: 05 Feb 2007 Posts: 140 Location: Osnabrück, Germany
|
Posted: Sun Dec 16, 2007 12:57 pm Post subject: |
|
|
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
|
|
| Back to top |
|
 |
leggah
Joined: 14 Oct 2007 Posts: 44
|
Posted: Sun Dec 16, 2007 6:30 pm Post subject: |
|
|
Thank you. That works smoothly.
I thought := was used for integers and = was for strings. my bad |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2739 Location: Australia, Qld
|
Posted: Mon Dec 17, 2007 12:19 am Post subject: |
|
|
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 |
|
 |
|