Jump to content


Defining how a script behave within and outside define area


  • Please log in to reply
2 replies to this topic

#1 Guest101

Guest101
  • Guests

Posted 07 June 2012 - 03:36 PM

I ran into a script that traps the mouse within predefined box. I like to take this script and add something more to it. For example,

If the cursor is within the predefine box, it will send abc and if it happens to wonder outside the defined area
it will send xyz.
In other words, it will behave differently depend where the cursor is located. In this case, it's ok to send abc as long as you're within this box but if cursor move out of the box send xyz. Is this something doable in ahk?


Code:
VarSetCapacity(RectangleStructure, 16, 0)

NumPut(200, RectangleStructure, 0) ; X coordinate of the Upper-Left corner on screen.
NumPut(200, RectangleStructure, 4) ; Y Coordinate of the Upper-Left corner on screen.
Numput(400, RectangleStructure, 8) ; X coordinate of the Lower-Right corner on screen.
NumPut(400, RectangleStructure, 12) ; Y Coordinate of the Lower-Right corner on screen.
Return 

F2::
DllCall("ClipCursor", "Uint", &RectangleStructure)
return

F3::
DllCall("ClipCursor", "Uint", "NULL")
return


#2 Guest101

Guest101
  • Guests

Posted 07 June 2012 - 03:37 PM

dont know why there is a smile face there but it's suppose to be a number 8.

#3 engunneer

engunneer
  • Fellows
  • 9162 posts

Posted 07 June 2012 - 03:39 PM

you can use mousegetPos to tell where the mouse is, and then use an if statement to decide which to send.

If I'm not mistaken, the script you posted keeps your mouse in the box always, so it would never send xyz?

As far as the smile, that is 8). I put your code in code tags to fix it.