Rawox Posted June 28, 2009 Share Posted June 28, 2009 Hey.. I need to know of the cursor is in an apart piece of the screen. For example somewhere between 100 pxl, 100pxl and 200 pxl, 200pxl. A piece of 100 pxls height and 100 pxls width as you can see. Anyone? Rawox Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 28, 2009 Moderators Share Posted June 28, 2009 Rawox,You have the answer in your title - look at MouseGetPos in the Help file. Then use some If or Switch statements.M23P.S. You might like to look at Opt(MouseCoordMode) as well. ;-) Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Rawox Posted June 28, 2009 Author Share Posted June 28, 2009 I already tried these things. Isn't there an option like PixelSearch left left coordinate of rectangle. top top coordinate of rectangle. right right coordinate of rectangle. bottom bottom coordinate of rectangle. If not, can someone please show an example?? Link to comment Share on other sites More sharing options...
somdcomputerguy Posted June 28, 2009 Share Posted June 28, 2009 If not, can someone please show an example??Function MouseGetPos - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
Rawox Posted June 28, 2009 Author Share Posted June 28, 2009 Snowmaker. That doesn't make sense to me! How can I check for the cursor in a given rectangle? I know I can do it with MouseGetPos, why don't you guys just show an example if it isn't that hard? Link to comment Share on other sites More sharing options...
somdcomputerguy Posted June 28, 2009 Share Posted June 28, 2009 Define top/left and bottom/right, or all four corners maybe, use mousegetpos to see if it's 'in there'. That's how I would tackle the situation first. It's maybe the wrong way to do it, but that's where I'd start anyway. Write some code, post it and any problems, I'm sure you'll get some help from others here. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 28, 2009 Moderators Share Posted June 28, 2009 Rawox,I know I can do it with MouseGetPos, why don't you guys just show an example if it isn't that hard?So what have you tried yourself? Just shouting at us will not get your code written for you!M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Rawox Posted June 28, 2009 Author Share Posted June 28, 2009 $WinPos = WinGetPos ( "Smaryl" ) $MousePos = MouseGetPos ( ) $Top = @DesktopHeight/2-35-$height/2 $Left = 0 $Right = $width-5 $Bottom = @DesktopHeight/2-35+$height/2 If $MousePos[0] = $Top And $MousePos[1] = $Left Then EndIf But this just checks 1 pixel, doesn't it? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 28, 2009 Moderators Share Posted June 28, 2009 Rawox,Try thinking logically.You want to know if your cursor is between (100, 100) and (200, 200). What do you think the If or Switch statements might look like? In your code above I see no sign of either 100 or 200 - so how do you expect to find out if your cursor is within those limits?How about trying to code something based on this:; Get mouse position $aM_Pos = MouseGetPos() Switch $aM_Pos[0] ; Is mouse within X coords? Case 100 To 200 Switch $aM_Pos[1] ; Is mouse within Y coords? Case 100 To 200 ; Mouse in the box ; If not Case Else ; Mouse not in the box EndSwitch ; If not Case Else ; Not in the box EndSwitchOver to you. :-)M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Rawox Posted June 28, 2009 Author Share Posted June 28, 2009 Thanks Melba! I tried this, I don't really understand your switch statements but with your help I thought this would work, but why doesn't it? $MousePos = MouseGetPos ( ) For $MousePos[0] = 100 To 200 For $MousePos[1] = 100 To 200 MsgBox ( 0, "lol", "lol" ) Next Next It just always displays the msgbox Link to comment Share on other sites More sharing options...
Thornhunt Posted June 28, 2009 Share Posted June 28, 2009 maybe if mousepos[0] < *** and mousepos[0] > *** and mousepos[1] < *** and mousepos[1] > *** then ... ect ect.. maybee ? have you tried that.. might work Budweiser + room = warm beerwarm beer + fridge = too long!warm beer + CO2 fire extinguisher = Perfect![quote]Protect the easly offended ... BAN EVERYTHING[/quote]^^ hmm works for me :D Link to comment Share on other sites More sharing options...
Yashied Posted June 28, 2009 Share Posted June 28, 2009 maybe if mousepos[0] < *** and mousepos[0] > *** and mousepos[1] < *** and mousepos[1] > *** then ... ect ect.. maybee ? have you tried that.. might work if (mousepos[0] < ***) and (mousepos[0] > ***) and (mousepos[1] < ***) and (mousepos[1] > ***) then My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
Thornhunt Posted June 28, 2009 Share Posted June 28, 2009 if (mousepos[0] < ***) and (mousepos[0] > ***) and (mousepos[1] < ***) and (mousepos[1] > ***) then hhehehe thats what i meant Budweiser + room = warm beerwarm beer + fridge = too long!warm beer + CO2 fire extinguisher = Perfect![quote]Protect the easly offended ... BAN EVERYTHING[/quote]^^ hmm works for me :D Link to comment Share on other sites More sharing options...
Rawox Posted June 29, 2009 Author Share Posted June 29, 2009 Thanks it worked!! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 29, 2009 Moderators Share Posted June 29, 2009 Rawox, I thought this would work, but why doesn't it? $MousePos = MouseGetPos ( ) For $MousePos[0] = 100 To 200 For $MousePos[1] = 100 To 200 MsgBox ( 0, "lol", "lol" ) Next NextYou are joking, of course? For...Next is for counting through a loop:For $i = 1 to 4 ConsoleWrite($i & @CRLF) Next will give you1 2 3 4 So your code above would give you you two loops which would display a total of 10000 MsgBox's....hardly surprising that:It just always displays the msgboxIf you want to become proficient at AutoIt coding, you must try and understand how the simple, often-used functions work. I commented the Switch example above to try and point you in the right direction. Just play with the examples in the Help file until you see how and why they do what they do. I know it is less fun than coding your own stuff, but understanding the basics of the commands you use will increase your ability to code correctly - and reduce the frustration of not understanding why your code does not work as you wish. It would be time well spent, believe me. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
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