markyrocks Posted January 8, 2020 Share Posted January 8, 2020 (edited) Moderator note: Please read the post BELOW this first - it will save you a lot of time and possibly tears. ########################################################################## For whatever reason I've been on a coding kick lately. I'm not exactly sure what got this all started at this point. I was playing around with dllstructs and I'm working on a way (halfassed) of using dot notation and methods with dllstructs. So on the way I came to a point where i was getting pointers and couldn't figure out what exactly to do from there. I have since figured that out but it brought me to the ptr() function in the help file. At first i wasn't quite sure what that was even for but i've since figured that out as well duh.,,,, but anyways on this journey of pointers memory addresses and dereferencing. I was actually considering making my own dll to solve some of these issues i was having. I still might to that one day. Long story short i realized pointers weren't really a thing in autoit. Dereferencing pointers is almost unheard of. Google searches show very few results and I figured it was kinda an unexplored area that i was actually interested in so I wrote this script. I've been working on it for 2 or 3 days, so please don't laugh me outa here. I realize in autoit the variable itself is the pointer and that using pointers is supposed to be faster lol but this script has alot of overhead. Its not too bad i think each function only has one loop looking through an array that is the tracker of everything that happens. Something that is currently not a feature is if you bring a pointer from somewhere else (good luck finding one lol) you can't just punch it into a function and have it spit out a result. So in other words you can only use pointers created by the script to read and write data with. another thing that i couldn't figure out a way around (Maybe one of you can) is that if a pointer is created then the variable is dereferenced and if that same variable is given another value, then the pointer is basically lost. You could get it back by giving the original variable the original value, or even any other variable the same value and get it back. $a="monkey" $a=_GetPtr($a) $a=_defeference($a) $a=76 $a=_GetExistingPointer($a) <------This will fail $b="monkey" $b=_GetExistingPointer($b) <----------------this would bring back the pointer that was originally created by $a an unfortunate downside to the way this is set up if you have multiple variables with the same values that you get pointers for and you dereference them and try to get the pointers back the only one that would come back would be the first one in the list. I guess i could always add in something that could keep track of pointers that were actually assigned to variables.... ya i could probably put something like that in pretty easily. After all this what the heck right. So anyways check it out. Tell me what you think. Obviously if a knowledgeable person wanted to use some pointers for specific purposes they could definitely write a script to accomplish that with less overhead but this is for someone with limited experience or knowledge and just wants to use pointers for whatever reason and doesn't want to reinvent the wheel every time they write a new script. Thanks for taking a look Pointers.au3 Edited January 8, 2020 by Melba23 Added rider Spoiler "I Believe array math to be potentially fatal, I may be dying from array math poisoning" Link to comment Share on other sites More sharing options...
LarsJ Posted January 8, 2020 Share Posted January 8, 2020 To make this perfectly clear: The post above is completely rubbish, completely useless and totally wrong. It's simply misinformation. Data in AutoIt variables is internally stored in variants. Data in AutoIt arrays is internally stored in safearrays of variants. Autoit variables are references to these variants and safearrays, but they are not pointers to data. It makes no sense to consider an AutoIt variable as a pointer and try to extract data using that pointer. The Ptr() function is a simple data type conversion function that can convert e.g. a string to pointer. In the same way that Int() can convert a string to an integer. Pointers in AutoIt are primarily used as parameters in functions in external DLLs e.g. all the functions in the Microsoft DLLs. Musashi, Earthshine and argumentum 3 Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 8, 2020 Moderators Share Posted January 8, 2020 LarsJ, Thank you for that burst of clarity. I have added a rider to the OP and I am locking the thread. 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...
Developers Jos Posted January 8, 2020 Developers Share Posted January 8, 2020 (edited) FYI: The OP pmed me with this stuff and I advised to open a discussion here to get input on the proposal made as I have no time at this moment to dive into the details of it.... guess the input was pretty clear. Jos Edited January 8, 2020 by Jos 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. Link to comment Share on other sites More sharing options...
Developers Jos Posted January 8, 2020 Developers Share Posted January 8, 2020 (edited) Ok... I have opened this thread again so it can be discussed here as I don't want more PM's on this topic. So please discuss this in a clear manner so everybody can learn from it! When I get any notice of wrong doings this thread will be closed permanently! Jos Edited January 8, 2020 by Jos 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. Link to comment Share on other sites More sharing options...
markyrocks Posted January 8, 2020 Author Share Posted January 8, 2020 (edited) 7 hours ago, LarsJ said: To make this perfectly clear: The post above is completely rubbish, completely useless and totally wrong. It's simply misinformation. Data in AutoIt variables is internally stored in variants. Data in AutoIt arrays is internally stored in safearrays of variants. Autoit variables are references to these variants and safearrays, but they are not pointers to data. It makes no sense to consider an AutoIt variable as a pointer and try to extract data using that pointer. The Ptr() function is a simple data type conversion function that can convert e.g. a string to pointer. In the same way that Int() can convert a string to an integer. Pointers in AutoIt are primarily used as parameters in functions in external DLLs e.g. all the functions in the Microsoft The data is stored in memory after all regardless of the name you call it. Variables in c++ are basically both a pointer and a reference. I'd assume they're the same in autoit but we just dont have access to the pointer. I.e. int a=1 Int* b=&a I was kinda tired when I wrote the original post so maybe it was a distinction that I didn't make but its basically splitting hairs. This is not meant to be educational to the reader. This is a request for thoughts and opinions on my script not my description of the the script. In my mind I don't make the distinction between pointers and references bc its basically the same thing. It can be either or in c++. Autoit is written in c++ underneath the autoit layer those variables do indeed have pointers associated with them. This guy basically backs up my point in like the first minute. Hes great btw. Highly recommend watching his series on c++ Edited January 8, 2020 by markyrocks Spoiler "I Believe array math to be potentially fatal, I may be dying from array math poisoning" Link to comment Share on other sites More sharing options...
markyrocks Posted January 10, 2020 Author Share Posted January 10, 2020 (edited) Ok so I know you guys hate me or whatever, that's fine just makes me want to write more inspired code. I've been thinking about the usefulness of this script that I wrote here for a few days. Which for one it could let c++ to autoit converts code closer to what they're used to if they so chose to. Obviously this is a little different than that bc it still isn't truly the pointer to the actual variable. It produces a fake pointer to the information but it can be used similarly to the real thing provided the user exclusively used these functions to store and retrieve data saved in the associated variables. The second biggest useful thing that could come from using this is the ability to have implicit connection between two variables or even more if necessary. In other words a REFERENCE omg . Anyways so check out the following $a=392 ;if we go $a=$b $b would only be equal to the value of $a if $a changes then $b just stays the same. Obviously we have byref but that trick only works in functions. If you wanted $b to change if $a changed that's not possible with the above. Its possible with the below code $a=1976 $b="a" $b=eval($b) That is fine but it requires the user to pass the name of the variable that you're attempting to reference. That's obviously not that big of a deal but what if the user doesn't want that variable to be a string they just want it to be some other value. I guess they could just make a new variable as the string name of the first and pass it. That's fine but also extra steps. Or they could just write the string in there but that's no fun this is about variables. Also extra parameters in functions if you need both the name of $a as a string and a different value to be associated with $a. Now check this out. $a="whatever I want" $a=_GetPointer($a) $b=$a Now at this point if the _WriteToPointer() function is used to exclusively used to change the value of $a, _Dereference($b) will always be equal to the value of _Dereference($a) no matter where else in the script the value changes. This can be useful if you have an array keeping track of the data of a variety of different variables it would save you the extra lines of code to keep resaving the value of something. Instead they could both be the same pointer and when the value is needed simply call _Dereference($array[$element]) This is all kinda a pain I will admit and it is probably easier to just force the user to pass the variable name as a string. But there can also be errors with that, typos misspelling ect. Then the expected value is always null and it might take a hr just to find one typo bc you're looking at 300 lines of code trying to figure out why it's not working. It was kinda funny I was scratching my head bc I was getting an error, I had a variable named $StringSplit and after hours of staring at my computer I get the infamous variable possibly used b4 declaration error and I'm like wth I declared and gave it a value.... then after a few changes for no reason that I had typed $Stringplit..... eye strain is a real thing. So anyways. Autoit error checker let's you know if a variable is misspelled if a string into a parameter of a function is misspelled you're on your own. The script this post is about must not be complete trash bc undoubtedly I'm sure I would have heard about it by now. I realize it's not perfect but I'm glad I wrote it bc It actually lead me to the idea I have now for actually finding the real pointer to these variables. It is a fantastic concept and if everything goes according to plan I should hopefully have an update to this that might just return the real pointer and it would make some of the nonsense I described above obsolete and lead to real references and aliases ect and hopefully better performance of scripts in the future. Its probably much faster to read and write directly to memory than sending the variable through the interpreter and however many functions that the source code of autoit uses to categorize and store the variables and then back. Edited January 10, 2020 by markyrocks Spoiler "I Believe array math to be potentially fatal, I may be dying from array math poisoning" Link to comment Share on other sites More sharing options...
markyrocks Posted January 10, 2020 Author Share Posted January 10, 2020 On 1/8/2020 at 10:49 AM, Melba23 said: LarsJ, Thank you for that burst of clarity. I have added a rider to the OP and I am locking the thread. M23 Do you mind removing your "rider" bc I clearly proved my point. The rider is the definition of fake news. Thanks Earthshine 1 Spoiler "I Believe array math to be potentially fatal, I may be dying from array math poisoning" Link to comment Share on other sites More sharing options...
LarsJ Posted January 11, 2020 Share Posted January 11, 2020 To make this perfectly clear: The post above is completely rubbish, completely useless and totally wrong. It's simply misinformation. It is fake news. The most significant mistake made is that the OP believes that because the internal AutoIt code is C++ code, AutoIt variables are also C++ variables. But that is not the case. AutoIt variables are not C++ variables. They are AutoIt variables. And you can't talk about dereferencing AutoIt variables. The closest approach to direct access to AutoIt variables and arrays is demonstrated in Accessing AutoIt Variables. Earthshine and Musashi 2 Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
Developers Jos Posted January 11, 2020 Developers Share Posted January 11, 2020 (edited) 10 hours ago, markyrocks said: Do you mind removing your "rider" bc I clearly proved my point. The rider is the definition of fake news. Thanks My guess is it would have been better to stay on-topic instead of posting this.... but that could be just the "dude" you PMed. in other words: When you really badly want to be taken serious, it would help when you actually start behaving like an adult. ... oh, for what it is worth: You haven't proved much yet that prove the other statements made as invalid. Jos Edited January 11, 2020 by Jos Earthshine 1 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. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 11, 2020 Moderators Share Posted January 11, 2020 markyrocks, From the eloquent rebuttals posted above by LarsJ it seems to me that the consensus view is that your ramblings are the "fake news" - not my rider - and so it stays. And as Jos has already mentioned, such OT matters are best dealt with via PM rather then in open forum. 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...
markyrocks Posted January 13, 2020 Author Share Posted January 13, 2020 (edited) On 1/11/2020 at 1:38 AM, LarsJ said: To make this perfectly clear: The post above is completely rubbish, completely useless and totally wrong. It's simply misinformation. It is fake news. The most significant mistake made is that the OP believes that because the internal AutoIt code is C++ code, AutoIt variables are also C++ variables. But that is not the case. AutoIt variables are not C++ variables. They are AutoIt variables. And you can't talk about dereferencing AutoIt variables. The closest approach to direct access to AutoIt variables and arrays is demonstrated in Accessing AutoIt Variables. If you would have taken 10 seconds and explained that autoit has an intentional memory obscuring security feature this would have all gone alot smoother. I did not realize this when I wrote the above and I could understand how that would irritate people bc thats obviously counter to that feature. I understand why it exists. I personally think it should be optional but it is what it is. I totally understand what you mean by a variant. But regardless I'm still happy about the above code. I understand how the above code could be a security risk. That's really all you had to say. Geez. @Jos the variables in autoit are indeed written to memory. To pretend like they just exist in thin air is ridiculous. I don't want to get to in depth bc obviously I'm not telling of you anything new. @Melba23 Someone saying my comment is trash is not very elegant. I'd also like to add that theres some serious flaws in some of the _winapi functions. Might want to have someone take a look at them Edited January 13, 2020 by markyrocks Spoiler "I Believe array math to be potentially fatal, I may be dying from array math poisoning" Link to comment Share on other sites More sharing options...
Developers Jos Posted January 13, 2020 Developers Share Posted January 13, 2020 (edited) 59 minutes ago, markyrocks said: the variables in autoit are indeed written to memory. To pretend like they just exist in thin air is ridiculous. I don't want to get to in depth bc obviously I'm not telling of you anything new. Not sure why I am addressed here. I am NOT one that worked on the AutoIt3 source, other than an odd minor fix, and mainly focussed on development and delivery of SciTE4AutoIt3, its tools and installer, so always refrain from making comments on the internals of AutoIt3. Jos Edited January 13, 2020 by Jos 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. Link to comment Share on other sites More sharing options...
markyrocks Posted January 13, 2020 Author Share Posted January 13, 2020 11 minutes ago, Jos said: Not sure why I am addressed here. I am NOT one that worked on the AutoIt3 source, other than an odd minor fix, and mainly focussed on development and delivery of SciTE4AutoIt3, its tools and installer, so always refrain from making comments on the internals of AutoIt3. Jos I can definitely understand why noone wants to talk about the internal workings and that's fine but someone could have pmed me about where I was headed with all this instead of trying to make me look like a clown in the open forum. I feel like I've been pretty cordial and I definitely haven't received the same in kind. Spoiler "I Believe array math to be potentially fatal, I may be dying from array math poisoning" Link to comment Share on other sites More sharing options...
Earthshine Posted January 13, 2020 Share Posted January 13, 2020 (edited) Larsj's first response post should have been sufficient in my opinion. from there, instead of argument, you could have simply asked for some explanations and done some research. Edited January 13, 2020 by Earthshine Musashi 1 My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
markyrocks Posted January 13, 2020 Author Share Posted January 13, 2020 (edited) 7 minutes ago, Earthshine said: Larsj's first response post should have been sufficient in my opinion. from there, instead of argument, you could have simply asked for some explanations and done some research. Ya research something noone wants to talk about. Good thinking. I definitely should have done that. Edited January 13, 2020 by markyrocks Spoiler "I Believe array math to be potentially fatal, I may be dying from array math poisoning" Link to comment Share on other sites More sharing options...
Developers Jos Posted January 13, 2020 Developers Share Posted January 13, 2020 (edited) 2 hours ago, markyrocks said: I can definitely understand why noone wants to talk about the internal workings and that's fine but someone could have pmed me about where I was headed with all this instead of trying to make me look like a clown in the open forum. I feel like I've been pretty cordial and I definitely haven't received the same in kind. This somehow feels like it is directed to me. I thought I have been very clear with you ...right? I do not have the time at this moment to dive into the details of all the stuff you are rambling about and stated as such to you in PM with the suggestion to post it here. That you get these "calling this bullshit" responses is not something I planned for, but having said that it has been you that started with stating everything as facts instead of taking the smart approach and leaving room for people to correct you on your ideas. This was the last I say about this topic as I didn't want to get involved here anyways.... so never PM me again please! Jos *click* as this will only further deteriorate in a pissing contest. Edited January 13, 2020 by Jos JLogan3o13 1 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. Link to comment Share on other sites More sharing options...
Recommended Posts