View Full Version : [AutoHotKey] Mousemove - Basic math problems..
aasi888
01-31-2012, 04:42 PM
I got an issue with AutoHotkey. I try to broadcast mouseclicks to other windows.
I want to get mouse coords, calculate new Y value and then move mouse to new location. I just got one problem.
The problem is this
yposmove = -70
MouseGetPos, xpos, ypos ;Get mouse position
ypos2 = Add(ypos, yposmove) ;Calculate new Y position
MouseMove, xpos, ypos2, screen ;Move to New position
AutoHotkey understands this ypos2 as string for some reason. So when I run this it moves mouse to MouseMove, xpos, 0, screen
Also tried MouseClick, left, xpos, ypos2, screen but that didnt work either.
Freddie
01-31-2012, 05:56 PM
I got an issue with hotkeynet. I try to broadcast mouseclicks to other windows.The problem is this
yposmove = -70MouseGetPos, xpos, ypos ;Get mouse positionypos2 = Add(ypos, yposmove) ;Calculate new Y position MouseMove, xpos, ypos2, screen ;Move to New positionhotkeynet understands this ypos2 as string for some reason. So when I run this it moves mouse to MouseMove, xpos, 0, screenAlso tried MouseClick, left, xpos, ypos2, screen but that didnt work eitherThat's not a HotkeyNet script. Are you using AutoHotkey?
aasi888
01-31-2012, 06:32 PM
Yeah. My bad. Its autohotkey. I edited the post. But can't edit the title.
luxlunae
01-31-2012, 07:06 PM
Try using %variable% rather than variable. My understanding is that % pulls the value out of the variable.
I'm also amused because I spend half my time on the ahk forums telling people that if they want to box they really should come here, and now that you've come here I'm going to say "if you persist in using AHK rather than a good program (like isboxer), its best to ask those questions on the ahk forum."
Most people here haven't used ahk and its considered pretty obsolete. I use it for a lot of things at work and its a godsend, but for multiboxing the $3 a month I spend on isboxer is well worth it.
Khatovar
01-31-2012, 11:56 PM
Yeah, most people use ISBoxer. I use HotKeyNet and can usually jump in on that, and obviously Freddie is pretty quick on the ball when a HKN question comes up. And then there's Keyclone, which most people here have used at some point even if they don't use it now.
AutoHotkey has maybe a handful of users here, so there's not many people that can offer help with it.
Cptan
02-01-2012, 02:07 AM
If your MouseClick, left, xpos, ypos2, screen didn't work, I would suspect the ypos2 is assigned wrongly in Add function.
I used mouseclick for mouse broadcast to all screen and it works. My code is 'MouseClick, left, tx, RY, 2', and really no diff from yours.
Did u set the CoordMode correctly?
What is the 'screen' variable for? Isn't that the Speed parameter?
aasi888
02-01-2012, 02:14 PM
1. I need to make the program understand the following
calculate: ypos + yposmove and save the value to ypos2. How can I do it?
I need to somehow calculate ypos + yposmove and then store the result as into ypos2.
When I use Msgbox, ypos2:%ypos2% to print the value of ypos2 it turns out like this ypos2:%ypos2%. This means that ypos2 is understood as a string. I need the program to understand ypos2 as value e.g 1023.
Can you copy paste your code, please?
2. I got and easy version of the move to work.
This works: MouseMove, 0,70,, R. (http://www.autohotkey.com/docs/commands/MouseMove.htm)
What is the 'screen' variable for? Isn't that the Speed parameter?
The Screen command: ; Interprets the coordinates below as relative to the screen rather than the active window. You can read about it in CoordMode section. (http://www.autohotkey.com/docs/commands/CoordMode.htm)
I was mixing hotkeynet and autohotkey with each others :D. I was reading the wrong guides from the net. Awesome what lack of sleep does to you! Had a 30 min blackout from my memory in the morning.
Cptan
02-01-2012, 09:56 PM
I need the program to understand ypos2 as valuee.g 1023.
I use ':='. For example
RY := (MY - BigWoWY)/BigWoWH*SmallWoWH + BigWoWH
MouseClick, left, tx, RY, 2
The Screen command: ; Interprets the coordinates below as relative to the screen rather than the active window. You can read about it in CoordMode section. (http://www.autohotkey.com/docs/commands/CoordMode.htm)
When I post you the question on screen variable, I was referring to your codes
MouseMove, xpos, ypos2, screen ;Move to New position
AHK - MouseMove, X, Y [, Speed, R]
e.g. MouseMove, 20, 30, 50, R
Your working code
This works: MouseMove, 0,70,, R. (http://www.autohotkey.com/docs/commands/MouseMove.htm)
A comma is missing in your non-working code?
At any rate, you should be able to solve this problem.
Happy hunting!
aasi888
02-03-2012, 09:35 PM
I guess I got it working somehow now. Perhaps I got some extra spacebars after the lines or something.
Thx for all for help. I'm gonna start working on the mouse system now!
EDIT: I managed to move cursor to the correct location but its very uncertain whether is presses the button or not. Is there a more sure way to broadcast keys?
Cptan
02-06-2012, 02:18 AM
I managed to move cursor to the correct location but its very uncertain whether is presses the button or not.
Double click works very well for me
aasi888
02-09-2012, 03:18 PM
Double click works very well for me
Yep it does. Mayby I was trying to make it too perfect. I was trying to make it click only once. Sometimes the window gets activated from mousemove sometimes and from mouseclick some other times.
vBulletin® v4.2.2, Copyright ©2000-2025, Jelsoft Enterprises Ltd.