Moderators SmOke_N Posted July 15, 2006 Moderators Share Posted July 15, 2006 1. I'm no expert, I just listen and apply what I learn from them. 2. I would imagine those functions would work using the ControlHandles of the ControlID/ClassNameNN... I don't know why a control would have hidden text though. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
1905russell Posted July 17, 2006 Share Posted July 17, 2006 1. I'm no expert, I just listen and apply what I learn from them.2. I would imagine those functions would work using the ControlHandles of the ControlID/ClassNameNN... I don't know why a control would have hidden text though.1. Hey I'm only a one X and youve got 9 (probably much more but truncated) to me you're a mega expert.How many Xs does one need to be an expert?2. Those functions work well. The hidden control text seem to indicate controls used with the more advanced versions of the application software.I looked at your function and the key there is DLLCall to windows. This is a problem for me because I just want to easily Macro but unfortunately before I do I have to learn all this "hardware related" stuff which I expected to be in place already.My next challenge it seems also has a DLLCall and belongs to another forum and I see you were the last one there - so see you there. I hope that many find this forum helpful as it has been for me. Thanks. Link to comment Share on other sites More sharing options...
1905russell Posted July 19, 2006 Share Posted July 19, 2006 (edited) 1. Hey I'm only a one X and you’ve got 9 (probably much more but truncated) to me you're a mega expert.How many Xs does one need to be an expert?2. Those functions work well. The hidden control text seem to indicate controls used with the more advanced versions of the application software.I looked at your function and the key there is DLLCall to windows. This is a problem for me because I just want to easily Macro but unfortunately before I do I have to learn all this "hardware related" stuff which I expected to be in place already.My next challenge it seems also has a DLLCall and belongs to another forum and I see you were the last one there - so see you there. I hope that many find this forum helpful as it has been for me. Thanks.I solved the other issue so I'm back here. I have a problem understanding coordinates.Why would I get the following results using Opt('MouseCoordMode', 2) and ControlGetPos() which is the same results as shown on the Autoit Window Info.Title: WhateverClass: WhateverFrameSize: X: 0 Y: 0 W: 1243 H: 833>>>>>>>>>>> Mouse Details <<<<<<<<<<<Window: X: 997 Y: 580 ;(CLICKED AT BOTTOM RIGHT CORNER OF CONTROL)>>>>>>>>>>> Control Under Mouse <<<<<<<<<<<Size: X: 3 Y: 2 W: 994 H: 530This to me would indicate the x,y coordinates of the control arex = (997 - 994) = 3 (correct as above)but y = (580-530) = 50 (wrong above shows 2)y = 50 is the correct actual visible coordinate.This difference seems more or less constant, no matter where parent or control is situated.(with this particular application - have not checked others)What does this mean (other than I need to adjust by 50 every time)?If I change to Opt('MouseCoordMode', 1) I then get Size: X: 59 Y: 0 W: 1175 H: 799Please interpret this for me.Edit 1 - I tested other applications and y is always out by a constant amount (not always 50 - eg. Outlook is always 30). Why? Edited July 19, 2006 by 1905russell Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 19, 2006 Moderators Share Posted July 19, 2006 If you look up MouseCoordMode in the help file, it will explain what 0,1,2 does. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
1905russell Posted July 19, 2006 Share Posted July 19, 2006 (edited) If you look up MouseCoordMode in the help file, it will explain what 0,1,2 does.I don't think you understood my question. Obviously I looked it up. Okay so I've looked it up again, now will you please explain. You tell me how you would calculate the origin x,y of a control on the screen? Do you know how I have to do it? Let's say it's an Outlook control. By trial and error the constant out is 30. Check it out and you will see. MouseCoordMode 2 $OriginX = $aCPos[0] $OriginY = $aCPos[1] + 30 Alternatively $BottomRightX = $aCPos[2] + $aCPos[0] $BottomRightY = $aCPos[3] + $aCPos[1] + 30 So tell me how you do would do it? Edited July 19, 2006 by 1905russell Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 20, 2006 Moderators Share Posted July 20, 2006 (edited) When comparing Control positions they return Client coords by default. So if your using MouseGetPos(), you will use Opt('MouseCoordMode', 2) instead of 1 or 0. Is that what your asking? Or do you want the entire area of the control? If that's the case it would be something like:expandcollapse popup;_ControlGetRectPos() ; Returns an array ;$Array[0] = X top left of control ;$Array[1] = Y top left of control ;$Array[2] = X bottom right of control ;$Array[3] = Y bottom right of control ;(like a square or rectangle) Opt('MouseCoordMode', 2); Remember that Control positions are returned as Client Coords HotKeySet('{Esc}', '_ExitNow') If Not ProcessExists('Calc.exe') Then Run('Calc.exe') ProcessWait('Calc.exe') EndIf While 1 $aCPos2Click = _ControlGetRectPos('Calculator', '1', 'Button7') If IsArray($aCPos2Click) Then If Not WinActive('Caculator') Then WinActivate('Calculator') MouseClick('Primary', Random($aCPos2Click[0], $aCPos2Click[2]), Random($aCPos2Click[1], $aCPos2Click[3])) EndIf Sleep(10) WEnd Func _ControlGetRectPos($hWnd, $sTextCID, $hWndCID) $OptWTMM = Opt('WinTitleMatchMode', 2) $OptWSC = Opt('WinSearchChildren', 1) If IsString($hWnd) Then WinGetHandle($hWnd) If IsString($hWndCID) Then $hWndCID = ControlGetHandle($hWnd, $sTextCID, $hWndCID) Local $aCpos = ControlGetPos($hWnd, $sTextCID, $hWndCID) Opt('WinTitleMatchMode', $OptWTMM) Opt('WinSearchChildren', $OptWSC) If IsArray($aCpos) Then Local $iXStartPos = $aCpos[0], $iYStartPos = $aCpos[1] Local $iXEndPos = ($aCpos[0] + $aCpos[2]), $iYEndPos = ($aCpos[1] + $aCpos[3]) Local $aReturnPos[4] = [$iXStartPos, $iYStartPos, $iXEndPos, $iYEndPos] Return $aReturnPos EndIf Return 0 EndFunc Edit: Changed the name of the function. Edited July 20, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
1905russell Posted July 20, 2006 Share Posted July 20, 2006 I ran your code but it just hits 1111111 all around this control. I'll look at code tomorrow. I need to ControlGetPos() or something and then display - control under mouse - the control location origin x,y, h, w - I hope your 11111 code will facilitate this? Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 20, 2006 Moderators Share Posted July 20, 2006 (edited) I ran your code but it just hits 1111111 all around this control. I'll look at code tomorrow.I need to ControlGetPos() or something and then display - control under mouse - the control location origin x,y, h, w - I hope your 11111 code will facilitate this?It's an example of what is returned only. And what can be done with it. But if you just want x,y,w,h then ControlGetPos() will do that with client coords returned, mine actually gives you the Min area and Maximum area of where the button is located... so lets say you have Control that is client coord x top right 0 / client coord y top right 0 / width of control is 30 and height is 20 as an example, this would be easy to say the area of this control is x = 0y = 0w = 30h = 20 ... so don't click outside top left 0 and bottom right 30 or top left 0 and bottom right 20... but what if the control is at 10 top left x and 9 top left y ... then you need to add 10 to width and 9 to height so you would have:x = 10y = 9w = 40 (equals bottom right X)h = 29 (equals bottom right Y)(If you can imagine a rectangle)My function just does the math for you is all... Where ControlGetPos returns top left x and y / width and height... mine returns top left x and y with the x and y already added to the width and height respectively, both are returning client coords. Edited July 20, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
WTS Posted July 20, 2006 Share Posted July 20, 2006 hey nice one smoken. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 20, 2006 Moderators Share Posted July 20, 2006 hey nice one smoken.Thanks, changed the name of the function. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
1905russell Posted July 20, 2006 Share Posted July 20, 2006 (edited) w = 40 (equals bottom right X) h = 29 (equals bottom right Y) (If you can imagine a rectangle) Edited July 21, 2006 by 1905russell Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 20, 2006 Moderators Share Posted July 20, 2006 (edited) w = 40 (equals bottom right X) h = 29 (equals bottom right Y) (If you can imagine a rectangle) w is never 40 brx is. h is never 29 bry is. I have solved the problem and now know how to determine the exact origin x,y of a control. You can use ControlGetPos cords with one adjustment in the calculation: Func _MouseWCOutAdjustment() $OptMCM = Opt('MouseCoordMode', 1) $aMWpos = MouseGetPos() Opt('MouseCoordMode', 2) $aMCpos = MouseGetPos() Opt('MouseCoordMode', $OptMCM) Local $iOutAdjstX = $aMWpos[0]- $aMCpos[0], $iOutAdjstY = $aMWpos[1]- $aMCpos[1] MsgBox(0, "MousePos Wx,Wy Cx,Cy Ox,Oy ", $aMWpos[0] & " " & $aMWpos[1] & " " & $aMCpos[0] & " " & $aMCpos[1] & " " & $iOutAdjstX & " " & $iOutAdjstY) EndFunc Now everything is perfect. This adjustment can be understood as follows; Open Notepad and make a screen W:508 H:554 so that Client area is W:500 H:500 according to Info. You will notice whatever mode you use the control under mouse dimensions always remain the same. The difference above is Wx=8 and Hx =54 and they represent the right scroll bar and the header. Info highlights the scroll bar but it is not included in the client area width height calculation If you put the mouse top left at X:8 Y:54 (Screen Mode)you should have the below included >>>>>>>>>>>> Window Details <<<<<<<<<<<<< Title: Untitled - Notepad Class: Notepad Size: X: 0 Y: 0 W: 508 H: 554 >>>>>>>>>>> Mouse Details <<<<<<<<<<< Screen: X: 8 Y: 54 >>>>>>>>>>> Control Under Mouse <<<<<<<<<<< Size: X: 0 Y: 0 W: 500 H: 500 If you want to locate the exact position of the control you need to make the above adjustment for this constant. I told you there was a constant and that some applications were different. Thats because the headers were bigger. Now everything makes sense. Thank you.I'm confused on 1 why you need this, and 2 why not just use Client Coords for everything (All the Mouse and Pixel functions can be used in Client Mode is why it's confusing)? Are you only trying to get the Mouse Position relative to window position, or are you trying to get client position relative to window position. Sorry, but I'm still not following on why you would do anything in Screen or Window Mode, if Client Mode is an option. Edit: I guess I'm biased in the aspect, I use Client Coords for everything, my AutoInfo Tool is set to Client Coords always. Edited July 20, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
1905russell Posted July 20, 2006 Share Posted July 20, 2006 (edited) I'm confused on 1 why you need this, and 2 why not just use Client Coords for everything (All the Mouse and Pixel functions can be used in Client Mode is why it's confusing)? Are you only trying to get the Mouse Position relative to window position, or are you trying to get client position relative to window position. Sorry, but I'm still not following on why you would do anything in Screen or Window Mode, if Client Mode is an option.Edit:I guess I'm biased in the aspect, I use Client Coords for everything, my AutoInfo Tool is set to Client Coords always.1 If I know the exact location of a control on screen then I know the coordinates of other controls on screen and client locations. 2 I now can determine exact origin xy location of control on screen. Without telling me, show me how you would calculate on that notepad example that the actual origin x,y is 0,0 on the screen. Write me the function so I can see what you mean. How do you get your code formatted in a separated box on the forum? Edited July 20, 2006 by 1905russell Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 20, 2006 Moderators Share Posted July 20, 2006 (edited) 1 If I know the exact location of a control on screen then I know the coordinates of other controls on screen and client locations. 2 I now can determine exact origin xy location of control on screen. Without telling me, show me how you would calculate on that notepad example that the actual origin x,y is 0,0 on the screen. Write me the function so I can see what you mean. How do you get your code formatted in a separated box on the forum?I'm not saying anything about "Screen Coords", I'm saying if your using controls, then you don't need them, just do EVERYTHING in Client Coords. What does it matter where it is on Screen Coords when your interacting with a Windows Controls anyway. ControlGetPos() is all you need... just use Opt('PixelCoordMode', 2) and Opt('MouseCoordMode', 2) for everything (Place them 1 time at the top of your script). It just seems that your making it entirely to difficult.Now to answer your question, I would use WinGetPos()/WinGetClientSize()/ControlGetPos() to return the Screen Coords If I really felt it necessary.Edit:Added itteration to Modes. Edited July 20, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
1905russell Posted July 20, 2006 Share Posted July 20, 2006 I'm not saying anything about "Screen Coords", I'm saying if your using controls, then you don't need them, just do EVERYTHING in Client Coords. What does it matter where it is on Screen Coords when your interacting with a Windows Controls anyway. ControlGetPos() is all you need... just use Opt('PixelCoordMode', 2) and Opt('MouseCoordMode', 2) for everything (Place them 1 time at the top of your script). It just seems that your making it entirely to difficult.Now to answer your question, I would use WinGetPos()/WinGetClientSize()/ControlGetPos() to return the Screen Coords If I really felt it necessary.Edit:Added itteration to Modes.Lets say you found it necessary (and I have a case where it is definitely necessary and I will advise you in a day or two with exact details when I tackle it again). So lets say you felt it necessary, using WinGetPos()/WinGetClientSize()/ControlGetPos() please write me the function to run on the Notepad example and return 0,0 as the origin in a MsgBox.How do you display the code like that on the forum please? Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 20, 2006 Moderators Share Posted July 20, 2006 Lets say you found it necessary (and I have a case where it is definitely necessary and I will advise you in a day or two with exact details when I tackle it again). So lets say you felt it necessary, using WinGetPos()/WinGetClientSize()/ControlGetPos() please write me the function to run on the Notepad example and return 0,0 as the origin in a MsgBox.How do you display the code like that on the forum please?Right, would you like a Big Mac with that order too? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
1905russell Posted July 20, 2006 Share Posted July 20, 2006 Right, would you like a Big Mac with that order too?You mean you can't do it? Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 21, 2006 Moderators Share Posted July 21, 2006 You mean you can't do it?There's a far cry from "can't" and "won't". I think I've demonstrated that there's not much I'm not willing to try. And sarcastic remarks like that will leave hoping that somone else answers the cry for help. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
1905russell Posted July 21, 2006 Share Posted July 21, 2006 There's a far cry from "can't" and "won't". I think I've demonstrated that there's not much I'm not willing to try. And sarcastic remarks like that will leave hoping that somone else answers the cry for help.I really don't know what you mean? I don't need a funtion - I have one. I do it my way - it works. You said you could do it using WinGetPos()/WinGetClientSize()/ControlGetPos() and I said show me because to I don't believe you can. There is no sarcasm and none was intended but if you are looking for an excuse to get out of it that's okay. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 21, 2006 Moderators Share Posted July 21, 2006 (edited) I really don't know what you mean? I don't need a funtion - I have one. I do it my way - it works. You said you could do it using WinGetPos()/WinGetClientSize()/ControlGetPos() and I said show me because to I don't believe you can. There is no sarcasm and none was intended but if you are looking for an excuse to get out of it that's okay.My apologies then, I didn't realize you had "exactly" what you needed. But, I don't need an exscuse to get out of anything, I'm married with kids, that's exscuse enough for anything. Edit: Here... Proof of concept, just because I don't want anyone to think it can't be done:Local $Window = 'Untitled - Notepad' If Not WinExists($Window) Then Run('Notepad.exe') WinWaitActive($Window) ElseIf WinExists($Window) And Not WinActive($Window) Then WinActivate($Window) EndIf Local $aArrayControlScreenPos = _ControlGetScreenPos($Window, '', '', 'Edit1') MsgBox(64, 'Info', 'X - Screen Start = ' & $aArrayControlScreenPos[1] & @CR & _ 'Y - Screen Start = ' & $aArrayControlScreenPos[2] & @CR & _ 'X Bottom Right Ending = ' & $aArrayControlScreenPos[3] & @CR & _ 'Y Bottom Right Ending = ' & $aArrayControlScreenPos[4]) Func _ControlGetScreenPos($hWnd, $shWndText, $sCIDText, $hWndCID) If IsString($hWnd) Then $hWnd = WinGetHandle($hWnd, $shWndText) If Not IsHWnd($hWndCID) Then $hWndCID = ControlGetHandle($hWnd, $sCIDText, $hWndCID) If Not WinActive($hWnd) Then Return SetError(1, 0, 0) Local $aWinPos = WinGetPos($hWnd), $aWinCSize = WinGetClientSize($hWnd) Local $aCtrlPos = ControlGetPos($hWnd, $sCIDText, $hWndCID) If Not IsArray($aWinPos) Or Not IsArray($aWinCSize) Or Not IsArray($aCtrlPos) Then Return SetError(2, 0, 0) Return StringSplit(($aWinPos[0] + (($aWinPos[2] - $aWinCSize[0]) + $aCtrlPos[0])) & ',' & _ ($aWinPos[1] + (($aWinPos[3] - $aWinCSize[1]) + $aCtrlPos[1])) & ',' & _ ($aWinPos[0] + (($aWinPos[2] - $aWinCSize[0]) + $aCtrlPos[2])) & ',' & _ ($aWinPos[1] + (($aWinPos[3] - $aWinCSize[1]) + $aCtrlPos[3])), ',') EndFunc Edit2: Typo... Don't think Notepad.exe is spelled Notepade.exe Edited July 21, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. 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