delaghetto Posted September 13, 2008 Share Posted September 13, 2008 this is a little hard to explain ok so i am making a gui for a script i have written and what i have is X and Y input boxes for points on the users screen. what i need is a way for the user to click on the screen and it automatically inputs these numbers or possibly add in the cursor position from the autoit info program and the user can manually enter in the numbers. Link to comment Share on other sites More sharing options...
dworld Posted September 13, 2008 Share Posted September 13, 2008 this is a little hard to explainok so i am making a gui for a script i have written and what i have is X and Y input boxes for points on the users screen. what i need is a way for the user to click on the screen and it automatically inputs these numbers or possibly add in the cursor position from the autoit info program and the user can manually enter in the numbers.Hi delaghetto,sorry but i didn't understand the last part of your sentence:"(...)or possibly add in the cursor position from the autoit info program and the user can manually enter in the numbers."what is your main goal with the gui? just get back the X and Y coordinates?could you explain more detailed? dworldI'm new in autoit, but I like it. My mind is open to the new things. Link to comment Share on other sites More sharing options...
delaghetto Posted September 13, 2008 Author Share Posted September 13, 2008 i am making a bot that will click 6 different spots on the users screen. the program has X and Y coordinate input boxes to specify the location on the screen for the mouseclick. basically what i need is the dumbest way to make it easy for the user to get these coordinates. autoit comes with a handy little tool called AutoIt Window Info which will tell you the X and Y coordinates of your mouse. i need to implement this into my program some how. i want to make this easy for the users out there that know nothing of this. Link to comment Share on other sites More sharing options...
dworld Posted September 13, 2008 Share Posted September 13, 2008 (edited) Well if you check in the help AutoIt->Function Reference->Gui parameters->GUIGetCursorInfo or search for "mouse get pos" you will get an example script. And if you modify only one line, it'll show the X, Y coordinates on the fly. here is the modified EXAMPLE script: #include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Global $x, $y Example() Func Example() Local $msg GUICreate("Press Esc to Get Pos", 400, 400) $x = GUICtrlCreateLabel("0", 10, 10, 50) $y = GUICtrlCreateLabel("0", 10, 30, 50) GUISetState() ; Run the GUI until the dialog is closed Do $msg = GUIGetMsg() GetPos() ; MODIFIED LINE Until $msg = $GUI_EVENT_CLOSE EndFunc ;==>Example Func GetPos() Local $a $a = GUIGetCursorInfo() GUICtrlSetData($x, $a[0]) GUICtrlSetData($y, $a[1]) EndFunc ;==>GetPos [Edit] It will show you the mouse cursor position relative to GUI window. Edited September 13, 2008 by dworld dworldI'm new in autoit, but I like it. My mind is open to the new things. Link to comment Share on other sites More sharing options...
delaghetto Posted September 13, 2008 Author Share Posted September 13, 2008 ahhhh i guess i wasnt thinking lol thank you very much for you help Link to comment Share on other sites More sharing options...
delaghetto Posted September 13, 2008 Author Share Posted September 13, 2008 ok well how do i make relative to the entire screen? Link to comment Share on other sites More sharing options...
dworld Posted September 13, 2008 Share Posted September 13, 2008 well add one extra include: #include <WinAPI.au3>oÝ÷ Ø Ý{axg>©àzÚºÚ"µÍIÌÍØHHÕÚ[TWÑÙ]ÝÛÜ[Ê BQÕRPÝÙ]]J ÌÍÞ ÌÍØVÌ×JBQÕRPÝÙ]]J ÌÍÞK ÌÍØVÍJ It was working for me. dworldI'm new in autoit, but I like it. My mind is open to the new things. Link to comment Share on other sites More sharing options...
delaghetto Posted September 13, 2008 Author Share Posted September 13, 2008 well add one extra include: #include <WinAPI.au3>oÝ÷ Ø Ý{axg>©àzÚºÚ"µÍIÌÍØHHÕÚ[TWÑÙ]ÝÛÜ[Ê BQÕRPÝÙ]]J ÌÍÞ ÌÍØVÌ×JBQÕRPÝÙ]]J ÌÍÞK ÌÍØVÍJ It was working for me. Perfect it works for me also. now ill hafta figure out how to implement it into my code. thanks for your help Link to comment Share on other sites More sharing options...
dworld Posted September 13, 2008 Share Posted September 13, 2008 Perfect it works for me also. now ill hafta figure out how to implement it into my code. thanks for your help you're welcome I'm happy that I could help dworldI'm new in autoit, but I like it. My mind is open to the new things. Link to comment Share on other sites More sharing options...
delaghetto Posted September 13, 2008 Author Share Posted September 13, 2008 oh i am going to need help for the rest of my script so if anyone is kind hearted and would like to help on the completion of my program. i use msn messenger and i can broadcast my desktop via webcam through msn so you can see exactly what i am doing. just message me on msn: hawkforce1@hotmail.com i am a quick and easy person to work with and i have good logic so i can figure most of this stuff out myself but sometimes i will need a quick reference Link to comment Share on other sites More sharing options...
rasim Posted September 14, 2008 Share Posted September 14, 2008 dworldGood example, but need little modifyexpandcollapse popup#include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Global $hGUI, $x, $y Example() Func Example() Local $msg $hGUI = GUICreate("Press Esc to Get Pos", 400, 400) $x = GUICtrlCreateLabel("X - 0", 10, 10, 50, 16) GUICtrlSetColor(-1, 0x0000FF) $y = GUICtrlCreateLabel("Y - 0", 10, 30, 50, 16) GUICtrlSetColor(-1, 0x228B22) GUISetState() GetPos() ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_MOUSEMOVE ;We need to call GetPos() func only when mouse moved to avoid control flickering and reduce CPU usage GetPos() EndSwitch WEnd EndFunc ;==>Example Func GetPos() Local $a = GUIGetCursorInfo() ControlSetText($hGUI, "", $x, "X - " & $a[0]) ControlSetText($hGUI, "", $y, "Y - " & $a[1]) EndFunc ;==>GetPos Link to comment Share on other sites More sharing options...
dworld Posted September 16, 2008 Share Posted September 16, 2008 hello rasimthank you very much for the correctionI'm just new at AutoIt and not using too events, which is not good, so I'll change this:)I like your code, and I know that the matter is that "We need to call GetPos() func only when mouse moved to avoid control flickering and reduce CPU usage", but just to make perfect the solution we should change few things:#include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Global $hGUI, $x, $yoÝ÷ ÚÚºÚ"µÍÚ[ÛYH ÑÕRPÛÛÝ[Ñ^]LÉÝÂÚ[ÛYH ÕÚ[TK]LÉÝÂÜ ÌÎNÓ]ÝXÛUÉÌÎNËJBÛØ[ ÌÍÚÕRK ÌÍÞ ÌÍÞK ÌÍØoÝ÷ Ù©Ýjëh×6Func GetPos() Local $a = GUIGetCursorInfo() ControlSetText($hGUI, "", $x, "X - " & $a[0]) ControlSetText($hGUI, "", $y, "Y - " & $a[1]) EndFunc ;==>GetPosoÝ÷ ÚÚºÚ"µÍ[ÈÙ]ÜÊ BIÌÍØHHÕÚ[TWÑÙ]ÝÛÜ[Ê BÛÛÛÙ]^ ÌÍÚÕRK ][ÝÉ][ÝË ÌÍÞ ][ÝÖH ][ÝÈ [È ÌÍØVÌ×JBÛÛÛÙ]^ ÌÍÚÕRK ][ÝÉ][ÝË ÌÍÞK ][ÝÖHH ][ÝÈ [È ÌÍØVÍJB[[ÈÏOIÝÑÙ]Üin order to be not relative to GUI window. dworldI'm new in autoit, but I like it. My mind is open to the new things. Link to comment Share on other sites More sharing options...
rasim Posted September 17, 2008 Share Posted September 17, 2008 dworldWithout API:expandcollapse popup#include <GuiConstantsEx.au3> Opt('MustDeclareVars', 1) Global $hGUI, $x, $y Example() Func Example() Local $msg $hGUI = GUICreate("Press Esc to Get Pos", 400, 400) $x = GUICtrlCreateLabel("X - 0", 10, 10, 50, 16) GUICtrlSetColor(-1, 0x0000FF) $y = GUICtrlCreateLabel("Y - 0", 10, 30, 50, 16) GUICtrlSetColor(-1, 0x228B22) GUISetState() GetPos() ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_MOUSEMOVE ;We need to call GetPos() func only when mouse moved to avoid control flickering and reduce CPU usage GetPos() EndSwitch WEnd EndFunc ;==>Example Func GetPos() ControlSetText($hGUI, "", $x, "X - " & MouseGetPos(0)) ControlSetText($hGUI, "", $y, "Y - " & MouseGetPos(1)) EndFunc ;==>GetPos Link to comment Share on other sites More sharing options...
dworld Posted September 17, 2008 Share Posted September 17, 2008 you won, respect dworldI'm new in autoit, but I like it. My mind is open to the new things. 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