Mat Posted January 14, 2010 Share Posted January 14, 2010 Why does AutoIt have all the internal controls as Id's? All I'm wondering is what benefit this has, as surely you'll then need to convert it into a handle in order to use any of the win api functions on it. And also there could be problems with duplicates as I've read somewhere that Control Id's and guaranteed to be unique. Mat AutoIt Project Listing Link to comment Share on other sites More sharing options...
Aurel Posted January 14, 2010 Share Posted January 14, 2010 Why does AutoIt have all the internal controls as Id's? All I'm wondering is what benefit this has, as surely you'll then need to convert it into a handle in order to use any of the win api functions on it. And also there could be problems with duplicates as I've read somewhere that Control Id's and guaranteed to be unique.MatEvery windows controls in almost all programming languages have ID-s.Windows recive messages based on specific ID and dispatch them to the system.You can have constant or variable type( INTEGER ) based ID but still must value inother words must have numeric ID. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 14, 2010 Moderators Share Posted January 14, 2010 Mat,I can imagine that when Jon first wrote AutoIt he found it more convenient to use an internal array to keep track of created controls - hence the 65532 limit on controls per script. The existence of the built_in GUICtrlGetHandle command lends credence to that idea. And using such an array allows controls to be deleted and recreated without too much playing about with lists of handles - have you noticed that a new control takes the first available ControlID and not the next highest? Altering an already indexed array element is much faster then searching for a given handle in a list and then deleting it (which is what I imagine is the difference between the operation at present and what it would be if Windows handles were used).As for duplicates - the use of the array prevents that.Finally, if you create your controls in immediate succession you can use the ControlIDs in a loop to set their styles, fonts, etc. That is something I would be very loath to give up as several of my scripts have used this to good effect.No doubt Jon will be along in a minute to shoot all this out of the water... 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...
monoceres Posted January 14, 2010 Share Posted January 14, 2010 First off, what value a handle/id takes is irrelevant for you as a scripter. The reason? Probably because it's safer to return an int to you so it cannot be fiddled with. Keeping the integrity of ones handles are important, what would happen if autoit returned the HANDLE of a newly opened file and you closed the file manually with _WinAPI_CloseHandle? It would be catastrophic if any windows function would crash on invalid handle since autoit it now working on a invalid handle. Plus the internal reference count (autoit's) for the handle would mess up so it would mean autoit would try to clear already cleared handles. Another thing is that it would remove any type safety from the language, you could just use any handle as anything, for example trying to read a HWND as a file. Keeping them as arbitrary numbers protects you and autoit and it's very fast since array (or operation that works like array lookup) is very fast. The alternative would be to give you the real handle and make a key/value pair in a hash table, but even that would only overcome half of the problems above. Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
Mat Posted January 14, 2010 Author Share Posted January 14, 2010 Thanks for replies all! Thats explained it a lot better. AutoIt Project Listing Link to comment Share on other sites More sharing options...
Administrators Jon Posted January 14, 2010 Administrators Share Posted January 14, 2010 It's worth noting as well that the autoit IDs also correspond to the general windows IDs that you see if you hover over the controls in Au3Info (or any other screen reader) - the actual handle changes each run. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ 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