checco096 Posted November 22, 2014 Share Posted November 22, 2014 Hi all I am working on a program with pixels and I have to select a portion of the screen to work ... to prevent the user to search the coordinates of each corner of the rectangle on which to work the program I thought maybe you could make sure to select that part of the screen by dragging the mouse and enclose it in a variable ... The problem is ... how do ... I looked everywhere, I have read the entire manual (by pressing F1) of autoit and I have really no idea ... Help me please !! Link to comment Share on other sites More sharing options...
computergroove Posted November 22, 2014 Share Posted November 22, 2014 (edited) Try pixelsearch -> https://www.autoitscript.com/autoit3/docs/functions/PixelSearch.htm If youre asking how do you determine how to get the pixel coordinates then you can use this: (see next post) Edited November 22, 2014 by computergroove Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
computergroove Posted November 22, 2014 Share Posted November 22, 2014 (edited) Just fixed a couple of things in the script to work better with the offset. Use this one instead. It's better. expandcollapse popup#include <GuiConstants.au3> #include <ControlGetHandleByPos.au3> Opt("GUIOnEventMode", 1) Opt("WinTitleMatchMode", 4) Global $xoffset = 10;X axis distance from mouse pointer to blue label Global $yoffset = 23;Y axis distance from mouse pointer to blue label Global $wposx, $wposy, $dt, $cwin, $xcalcl, $xcalcr, $ycalc, $cpos, $pos, $tpos, $hexv, $pcolor Global $title = "Your Title Here" HotKeySet("{ESC}", "Terminate") $pgui = GUICreate($title, 250, 13, -1, -1, $ws_popup);Rear place holder for back of the blue label box (Title, Length of the blue lable box, Height of the blue label box,,) $startlab = GUICtrlCreateLabel(" X: 0000, Y: 0000", 0, 0, 250, 13) GUICtrlSetBkColor($startlab, 13434879);blue label box color WinSetOnTop($pgui, "", 1) GUISetState(@SW_SHOW) While 1 _nmgp() WEnd Func _nmgp() Local $_cpos = MouseGetPos();get current position of the mouse on desktop Sleep(10) $pcolor = PixelGetColor($_cpos[0], $_cpos[1]);help $pos = MouseGetPos() GUICtrlSetData($startlab, " X: " & $pos[0] & ", Y: " & $pos[1] & " HEX: " & Hex($pcolor, 6) & " DEC: " & $pcolor) ;************************************ Moves the blue label with the mouse ***************************** If $dt = 1 Then $xcalcr = 0.95 * @DesktopWidth $xcalcl = 0.05 * @DesktopWidth $ycalc = 0.9 * @DesktopHeight If $pos[1] > $ycalc Then $wposy = $pos[1] - $yoffset * 2 Else $wposy = $pos[1] + $yoffset EndIf If $pos[0] > $xcalcr Then $wposx = $pos[0] - $xoffset * 3 ElseIf $pos[0] < $xcalcl Then $wposx = $pos[0] + 10 Else $wposx = $pos[0] - $xoffset EndIf Else _clientmouse() EndIf WinMove($title, "", $wposx, $wposy) ;************************************ End Moves the blue label with the mouse *************************** EndFunc Func _clientmouse() Opt("MouseCoordMode", 1) $tpos = MouseGetPos() $cpos = WinGetPos($cwin) $xcalcr = 0.95 * $cpos[2] $xcalcl = 0.95 * $cpos[2] $ycalc = 5.0 * $cpos[3];Y axis for offsetting the text box when you reach the top of the screen (so you can stil see the coordinates) If $tpos[1] > $ycalc Then $wposy = $tpos[1] - $yoffset * 2; Y Axis to determine the distance from the mouse pointer and the blue text box Else $wposy = $tpos[1] + $yoffset EndIf If $tpos[0] > $xcalcr Then $wposx = $tpos[0] - $xoffset - $xcalcr ; X Axis to determine the distance from the mouse pointer and the blue text box ElseIf $tpos[0] < $xcalcl Then $wposx = $tpos[0] + 10 Else $wposx = $tpos[0] - $xoffset EndIf EndFunc Func terminate() Exit 0 EndFunc Edited November 22, 2014 by computergroove Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
TheSaint Posted November 23, 2014 Share Posted November 23, 2014 You could also look at MouseCoordMode in the Help file. BlockInput may also be of use to you, but you really need to be careful using that command. Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
checco096 Posted November 23, 2014 Author Share Posted November 23, 2014 (edited) I now how i can take the position of the coursor but i would like to do for example this: in witch when i click select region i can select a part of window (green part) and when i leave the mouse the program save this coordinates in a variable.. But how can i do it?? I have to put this coordinates in pixelsearch function.. Edited November 23, 2014 by checco096 Link to comment Share on other sites More sharing options...
junkew Posted November 23, 2014 Share Posted November 23, 2014 source for tools like this will help you '?do=embed' frameborder='0' data-embedContent>> FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
checco096 Posted November 23, 2014 Author Share Posted November 23, 2014 (edited) Thanks i've fixed! Edited November 23, 2014 by checco096 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