zaduma Posted January 15, 2007 Posted January 15, 2007 (edited) here is kinda what my code looks like CODE dim autoit As New AutoItX3Lib.AutoItX3 dim s as string public sub dostuff() s = autoit.ControlGetText("Application", "", ID) msgbox(s) end sub I of course get teh control ID from AutoIt Window Info... The application will work perfectly if I just have opened it, but everytime I open the application there is a new Control ID for the area I want to get text out of. So i was wondering if there is a function like "autoit.GetControlFromPixel(x,y)" and I am blind, or what? P.S. The ClassNameNN changes as well. Thanks in advance Edited January 15, 2007 by zaduma
jvetter713 Posted January 16, 2007 Posted January 16, 2007 If you were to iterate thru all of the controls within the window would you be able to pick the correct control that way? If so then you can get at its id. Otherwise Im not aware of any way to get at a control unless you have its id
sohfeyr Posted January 16, 2007 Posted January 16, 2007 (edited) Without solving your problem for you (tempting as it is...), remember that every control is also a window. Once that is understood, a tremendous chunk of the Win32 API begins to make sense.Here is code in regular AutoIt to get a control from a point:; WindowFromPoint (thanks Larry!) Func WindowFromPoint() Local $point, $cHwnd, $hwnd, $pos, $size Local $dll = dllopen("user32.dll") $point = MouseGetPos() $hwnd = DLLCall($dll, "hwnd", "WindowFromPoint", "int", $point[0], "int", $point[1]) If $hwnd[0] <> 0 Then $pos = WinGetPos($hwnd[0]) If @error Then Return 0 $size = WinGetClientSize($hwnd[0]) If @error Then Return 0 $pos[0] += (($pos[2] - $size[0]) / 2) $pos[1] += (($pos[3] - $size[1]) - (($pos[2] - $size[0]) / 2)) $cHwnd = DLLCall($dll,"hwnd","RealChildWindowFromPoint","hwnd",$hwnd[0], _ "int",$point[0] - $pos[0],"int",$point[1] - $pos[1]) If $cHwnd[0] <> 0 Then $hwnd[0] = $cHwnd[0] EndIf DLLClose($dll) Return $hwnd[0] EndFuncIn AutoItX, the MouseGetPos, WinGetPos, and WinGetClientSize functions are split up into X and Y, but you probably already noticed that. Naturally, you can accept X and Y as parameters instead of using the mouse position. The DLLCall is the tricky part, but it can be replaced with a function made with the DLLImport attribute. PInvoke.net gives the C# signatures (easy enough to translate) for RealChildWindowFromPoint and WindowFromPoint as: [DllImport("user32.dll")] static extern IntPtr RealChildWindowFromPoint(IntPtr hwndParent, POINT ptParentClientCoords); [DllImport("user32.dll")] static extern IntPtr WindowFromPoint(POINT Point);You will also need this (which is already in VB.Net):<System.Runtime.InteropServices.StructLayout(Runtime.InteropServices.LayoutKind.Sequential)> _ Public Structure POINT Public X As Integer Public Y As Integer Public Sub New(ByVal X As Integer, ByVal Y As Integer) Me.X = X Me.Y = Y End Sub End StructureSee MSDN for additional info on those. Suppose that you are uncomfortable with handles for whatever reason, and wanted to get the control ID; you can feed the handle from the above function into this GetDlgCtrlID, and it will give you the exact same thing the AU3InfoTool will.[DllImport("user32.dll")] static extern int GetDlgCtrlID(IntPtr hwndCtl);The rest should be fairly straightforward, and I think the resulting code should work on any 32-bit system after Win95. Good luck! Edited January 16, 2007 by sohfeyr Mine:Time Functions - Manipulate the system clock! | WinControlList (WinGetClassList++) | .Net Setup Wrapper, Detect or install .Net | Writing and using a VB .NET COM object in AutoItNot mine, but highly recommended:AutoItTreeViewExtension plugin | Menu code | Callback helper dll | Auto3Lib - Control the uncontrollable | Creating COM objects in AutoIt | Using .Net framework classes in AutoIt
zaduma Posted January 16, 2007 Author Posted January 16, 2007 (edited) Without solving your problem for you (tempting as it is...), remember that every control is also a window. Once that is understood, a tremendous chunk of the Win32 API begins to make sense.Yeah to bad you didn't help, I wish you would have.I did not come here because I wanted cryptic messages that may hide the actual code needed, I want a line or segment of code to do the function I wanted, If you can not do this then please do not respond as your input is rather uneccesary.I needed VB.net with autoitx, nothing else. Edited January 16, 2007 by zaduma
sohfeyr Posted January 17, 2007 Posted January 17, 2007 @jvetter: You're welcome! Glad to help. @zaduma: You're not. I came inches within solving your programming problem. I gave you sliced bread, meat and cheese, and you complain I didn't give you a sandwich. If you need help with laziness, seek the help of a licensed therapist - or perhaps find someone to do it for you. You have all the grace and problem-solving skills of a cinderblock tumbling down a mountain, and will receive no further assistance, or replies, from me. Mine:Time Functions - Manipulate the system clock! | WinControlList (WinGetClassList++) | .Net Setup Wrapper, Detect or install .Net | Writing and using a VB .NET COM object in AutoItNot mine, but highly recommended:AutoItTreeViewExtension plugin | Menu code | Callback helper dll | Auto3Lib - Control the uncontrollable | Creating COM objects in AutoIt | Using .Net framework classes in AutoIt
Damastah Posted August 15, 2008 Posted August 15, 2008 @zaduma: You're not. I came inches within solving your programming problem. I gave you sliced bread, meat and cheese, and you complain I didn't give you a sandwich. If you need help with laziness, seek the help of a licensed therapist - or perhaps find someone to do it for you. You have all the grace and problem-solving skills of a cinderblock tumbling down a mountain, and will receive no further assistance, or replies, from me.Am I allowed to just post a laugh?
Developers Jos Posted August 15, 2008 Developers Posted August 15, 2008 Am I allowed to just post a laugh? We prefer not when it resurrects a 1.5 year old thread.. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
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