tonycst Posted December 15, 2016 Share Posted December 15, 2016 Help file says: If a handle is returned, it must be released using _WinAPI_DeleteObject(). and gives example: _ScreenCapture_Capture(@MyDocumentsDir & "\GDIPlus_Image1.jpg") which makes no sense because there is no variable for the function and if you look at the complete example code, there is no _WinAPI_DeleteObject(). either. Does that mean that if no variable is used to call one or another function, there is no need to worry about memory leaks ? (or clutter) Related question: Does memory get cleared of all data once script exists or it need to be cleared ? thank ya Link to comment Share on other sites More sharing options...
BrewManNH Posted December 15, 2016 Share Posted December 15, 2016 Your 1st question doesn't make a lot of sense. If you use _ScreenCapture_Capture with a file name as the first parameter, then you won't get a handle returned, you get True if the image is saved ok. No where does it say if you use a variable that you need to use _WinAPI_DeleteObject. You're asking too broad a question and using a single function as an example for the question to which it doesn't apply to at all. Most of the time when the script closes it clears its data, but not always in some cases, so it's best to clear them yourself prior to exiting. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
mikell Posted December 16, 2016 Share Posted December 16, 2016 11 hours ago, tonycst said: which makes no sense because there is no variable for the function and if you look at the complete example code, there is no _WinAPI_DeleteObject(). either. Using _ScreenCapture_Capture() depending on the first param you get : either a handle (and then you must be release it using _WinAPI_DeleteObject ) or a file (and then the used variables are released internally by the UDF ) Link to comment Share on other sites More sharing options...
tonycst Posted December 17, 2016 Author Share Posted December 17, 2016 Oh ok i get it now. I thought variable before _ScreenCapture_Capture is the handle. I guess variable is a handle storage ? Does that mean i should not use _ScreenCapture_Capture(@DesktopDir & "\Shapshot.jpg") without variable so that i can delete the object once picture is saved, correct ? Thanks Link to comment Share on other sites More sharing options...
spudw2k Posted December 19, 2016 Share Posted December 19, 2016 Per the help file: Return Value Returns a handle to an HBITMAP if $sFileName is empty. If called with $sFileName then the image is saved to the file and nothing is returned. Remarks If a handle is returned, it must be released using _WinAPI_DeleteObject(). So, if you do specify a filename to output the image to, nothing gets returned. If you don't specify a filename, an HBITMAP object handle is returned and therefore should be released when finished with using _WinAPI_DeleteObject If you look at the ScreenCapture.au3 UDF, you'll see at the end of the _ScreenCapture_Capture() function it evaluates if $sFilename = "". If $sFileName = "" Then Return handle else Continue script and provide the bitmap object as a parameter to the _ScreenCapture_SaveImage and set $bFreeBmp paramter to true (which executes _WinAPI_DeleteObject after saving the file). So either way, with cleanup is (should be) done. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
tonycst Posted December 22, 2016 Author Share Posted December 22, 2016 one day ill understand all of what you said. thanks ! Link to comment Share on other sites More sharing options...
spudw2k Posted December 22, 2016 Share Posted December 22, 2016 Let me take a small step back to make sure something fundamental is understood; what is meant by a return? When you execute a function, it typically "returns" something (i.e. value, string, array, etc.). The variable placed in front of a function--i.e. $iMsg = Msgbox(...)--will be assigned what the function returns. Now, after that..does re-reading my post above help explain any better? Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
tonycst Posted December 26, 2016 Author Share Posted December 26, 2016 i got that part yes. 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