Timppa Posted October 15, 2015 Posted October 15, 2015 (edited) Hello!I have tried to check if mouse is between certain pixels by this script:Global $MousePosition = MouseGetPos() Global $LocationX1 = 200 Global $LocationX2 = 300 Global $LocationY1 = 150 Global $LocationY2 = 600 Global $CheckX Global $CheckY If $MousePosition[0] = random($LocationX1, $LocationX2) Then ToolTip("Mouse X is at location.") $CheckX = 1 Else ToolTip("Mouse X is not at location.") $CheckX = 0 EndIf If $MousePosition[1] = random($LocationY1, $LocationY2) Then ToolTip("Mouse Y is at location.") $CheckY = 1 Else ToolTip("Mouse Y is not at location.") $CheckY = 0 EndIf If $CheckX == 1 And $CheckY == 1 Then ToolTip("Mouse X&Y is at location") Sleep(3000) Exit EndIfSo it basicly just checks where my mouse is (between certain location), but when I think that using random(x,y) is incorrect.So what I am asking is that is there any command like Between(x,y) because random just randomizes the numbers in it and that's why it won't work. Couldn't find this solution anywhere by google Thanks in advance! EDIT: When I execute this, it always says Mouse X is not at location and same for Y, even if the mouse is at the location. Edited October 15, 2015 by Timppa
water Posted October 15, 2015 Posted October 15, 2015 Both coordinates form a rectangle. I assume that X1/Y1 is the upper left corner and X2/Y2 the lower right corner.So you are looking for something like this:Global $aMousePosition Global $iLocationX1 = 200 Global $iLocationY1 = 150 Global $iLocationX2 = 300 Global $iLocationY2 = 600 While 1 $aMousePosition = MouseGetPos() If $aMousePosition[0] < $iLocationX1 Or $aMousePosition[0] > $iLocationX2 Or $aMousePosition[1] < $iLocationY1 Or $aMousePosition[1] > $iLocationY2 Then ToolTip("Mouse is out of the area. X: " & $aMousePosition[0] & ", Y: " & $aMousePosition[1]) Else ToolTip("Mouse is in the area. X: " & $aMousePosition[0] & ", Y: " & $aMousePosition[1]) EndIf Sleep(50) WEnd Timppa 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
water Posted October 15, 2015 Posted October 15, 2015 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now