Moderators Melba23 Posted November 8, 2009 Moderators Posted November 8, 2009 Jos, Did you have to tell everyone! 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
Fubarable Posted November 8, 2009 Posted November 8, 2009 Sure you do... I pay you 5% each month of what I get. And worth EVERY penny! Thanks for the lessons! And great work on this language. When is the OOP version coming out?
Developers Jos Posted November 8, 2009 Developers Posted November 8, 2009 And worth EVERY penny! Euro penny's ? Any ways, last time I checked 5% of nothing comes out as ..... 0 (Cents/Penny's/whatever other currency) 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.
Mat Posted November 8, 2009 Posted November 8, 2009 Mat,To carry on with the advanced tutorial now that we have started - do you use the /SO option with Obfuscator? That strips all the unused constants and functions from any includes and seriously reduces the size of your final exe/au3. Jos has done a wonderful job with it and I find it can save as much as half the size of a script.M23No... I just write that way! I read binary and hex fluently , My method saves more than his, and kind of obfuscates it at the same time (although I have tried un-obfuscating a file before to see just how good it was. I got pretty far, but it was very hard, and took a ridiculous amount of time).I recommend everyone to do something along those lines, as it does make a differenceMat AutoIt Project Listing
JackDinn Posted November 8, 2009 Posted November 8, 2009 well was getting on pretty well , and then a problem http://www.autoitscript.com/forum/index.php?showtopic=105181 Thx all,Jack Dinn. JD's Auto Internet Speed Tester JD's Clip Catch (With Screen Shot Helper) Projects :- AutoIt - My projects My software never has bugs. It just develops random features. :-D
PsaltyDS Posted November 8, 2009 Posted November 8, 2009 (edited) When is the OOP version coming out? If you mean "Object Oriented": Never. Edited November 8, 2009 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
AndrewG Posted November 9, 2009 Author Posted November 9, 2009 AndrewG, I have simplified your code quite a bit and added a fair few comments to explain why. I hope you can follow: expandcollapse popup#include <GUIConstants.au3> Opt("MustDeclareVars", 1) Opt("GUIOnEventMode", 1) Global $frmMain, $g_btnPlay, $g_btnStop, $sMessage, $i_CtrlID = 0 Global $i_isPlay = False ; Makes it easier to toggle between True/False Global $i_Count = 1 $frmMain = GUICreate("Learning Looping", 800, 400, (@DesktopWidth - 800) / 2, (@DesktopHeight - 400) / 2) ; Not needed if only Default ,-1,-1) GUISetOnEvent($GUI_EVENT_CLOSE, "ExitApp") ;Master Play Controls $g_btnPlay = GUICtrlCreateButton("Play", 10, 360, 40, 30) ; Not needed if only Default , -1, -1) GUICtrlSetOnEvent($g_btnPlay, "btnPlay") $g_btnStop = GUICtrlCreateButton("Stop", 50, 360, 40, 30) ; Not needed if only Default , -1, -1) GUICtrlSetOnEvent($g_btnStop, "btnStop") ;Messages GUICtrlCreateGroup("Messages", 450, 180, 220, 140) ; Not needed if only Default , -1, -1) $sMessage = GUICtrlCreateLabel("", 460, 200, 200, 100) ; Not needed if only Default , -1, -1) GUICtrlCreateGroup("", -99, -99, 1, 1);Close group GUISetState(@SW_SHOW) While 1 Playloop() ; See if we need to play WEnd Func ExitApp() Exit EndFunc ;==>ExitApp ;Play Function Func btnPlay() $i_CtrlID = @GUI_CtrlId ; Save the ID of the button as a flag for Playloop() If $i_isPlay = False Then ; == 0 Then == is only for comparing case sensitive strings $i_isPlay = Not $i_isPlay ; Told you it is was easier! GUICtrlSetData($sMessage, $i_isPlay) ;ElseIf $i_isPlay == 1 Then Not needed as $i_IsPlay can only be True/False ; Return Else Return EndIf EndFunc ;==>btnPlay ;Stop Function - see above for explanation of changes Func btnStop() $i_CtrlID = @GUI_CtrlId If $i_isPlay = True Then $i_isPlay = Not $i_isPlay Else Return EndIf EndFunc ;==>btnStop ;Loop function Func PlayLoop() While $i_isPlay = 1 ; Again no need for == ; We only get here is the play button was pressed $i_Count = $i_Count + 1 GUICtrlSetData($sMessage, $i_isPlay & @CRLF & " Looping" & @CRLF & $i_Count) Sleep(500) ; Just so you can see what is going on in the label - my old eyes cannot cope with anything less WEnd ; We can get here if the stop button was pressed or if the ButtonID has been reset to 0 ; So if we do not check we get flickering in the label - try removing the If...Then part and see! If $i_CtrlId = $g_btnStop Then GUICtrlSetData($sMessage, $i_isPlay & @CRLF & "Stopping") ; Reset the buttonID so we do not fire anything when we loop next time $i_CtrlID = 0 EndFunc ;==>PlayLoop Although I can see what you were trying to do, I am a great believer in the KISS* principle and you, in my opinion, were getting a bit over-complicated. Not that you were wrong to try and do it another way - when I code I always think of Kipling: "There are nine and sixty ways of constructing tribal lays, and every single one of them is right!" Please ask if anything is unclear. M23 * Keep It Simple Stupid Melba23, I understand that, and thank you. What I noticed though is the OnEventMode solution uses 100% of my cpu, and the Message-loop mode solution hardly uses any. So then the reason why would be that the in the OnEventMode the PlayLoop function is contantly being called where as in the Message-loop mode after the PlayLoop function has been called the gui is only being polled when the while loop is executing. So the message loop mode seem to be the mode to use in this case. right?
Mat Posted November 9, 2009 Posted November 9, 2009 (edited) What I noticed though is the OnEventMode solution uses 100% of my cpu, and the Message-loop mode solution hardly uses any. So then the reason why would be that the in the OnEventMode the PlayLoop function is contantly being called where as in the Message-loop mode after the PlayLoop function has been called the gui is only being polled when the while loop is executing. So the message loop mode seem to be the mode to use in this case. right? You may be right at it being the write mode to use in this case, but you should not be seeing any CPU usage at all when idle. Sorry Melba but that example definitely has something wrong! Click "play" and it drops to < 2% becouse of the sleep (500), you just need one of those in the normal loop. This would be betterexpandcollapse popup#include <GUIConstants.au3> Opt("MustDeclareVars", 1) Opt("GUIOnEventMode", 1) Global $frmMain, $g_btnPlay, $g_btnStop, $sMessage, $i_CtrlID = 0 Global $i_isPlay = False ; Makes it easier to toggle between True/False Global $i_Count = 1 $frmMain = GUICreate("Learning Looping", 800, 400, (@DesktopWidth - 800) / 2, (@DesktopHeight - 400) / 2) ; Not needed if only Default ,-1,-1) GUISetOnEvent($GUI_EVENT_CLOSE, "ExitApp") ;Master Play Controls $g_btnPlay = GUICtrlCreateButton("Play", 10, 360, 40, 30) ; Not needed if only Default , -1, -1) GUICtrlSetOnEvent($g_btnPlay, "btnPlay") $g_btnStop = GUICtrlCreateButton("Stop", 50, 360, 40, 30) ; Not needed if only Default , -1, -1) GUICtrlSetOnEvent($g_btnStop, "btnStop") ;Messages GUICtrlCreateGroup("Messages", 450, 180, 220, 140) ; Not needed if only Default , -1, -1) $sMessage = GUICtrlCreateLabel("", 460, 200, 200, 100) ; Not needed if only Default , -1, -1) GUICtrlCreateGroup("", -99, -99, 1, 1);Close group GUISetState(@SW_SHOW) While 1 Playloop() ; See if we need to play WEnd Func ExitApp() Exit EndFunc ;==>ExitApp ;Play Function Func btnPlay() $i_CtrlID = @GUI_CtrlId ; Save the ID of the button as a flag for Playloop() If $i_isPlay = False Then ; == 0 Then == is only for comparing case sensitive strings $i_isPlay = Not $i_isPlay ; Told you it is was easier! GUICtrlSetData($sMessage, $i_isPlay) ;ElseIf $i_isPlay == 1 Then Not needed as $i_IsPlay can only be True/False ; Return Else Return EndIf EndFunc ;==>btnPlay ;Stop Function - see above for explanation of changes Func btnStop() $i_CtrlID = @GUI_CtrlId If $i_isPlay = True Then $i_isPlay = Not $i_isPlay Else Return EndIf EndFunc ;==>btnStop ;Loop function Func PlayLoop() While $i_isPlay = 1 ; Again no need for == ; We only get here is the play button was pressed $i_Count = $i_Count + 1 GUICtrlSetData($sMessage, $i_isPlay & @CRLF & " Looping" & @CRLF & $i_Count) Sleep(500) ; Just so you can see what is going on in the label - my old eyes cannot cope with anything less WEnd ; We can get here if the stop button was pressed or if the ButtonID has been reset to 0 ; So if we do not check we get flickering in the label - try removing the If...Then part and see! If $i_CtrlId = $g_btnStop Then GUICtrlSetData($sMessage, $i_isPlay & @CRLF & "Stopping") ; Reset the buttonID so we do not fire anything when we loop next time $i_CtrlID = 0 Sleep (100) ; Sleep Added to save CPU EndFunc ;==>PlayLoop(One line added ) Mat Edited November 9, 2009 by Mat AutoIt Project Listing
Moderators Melba23 Posted November 9, 2009 Moderators Posted November 9, 2009 AndrewG & Mat,Mea culpa, mea culpa, mea maxima culpa! I hate OnEvent mode!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
JackDinn Posted November 9, 2009 Posted November 9, 2009 (edited) I hate OnEvent mode! a man after my own heart And i got called stupid earlier in this thread for expressing that opinion. Edited November 9, 2009 by JackDinn Thx all,Jack Dinn. JD's Auto Internet Speed Tester JD's Clip Catch (With Screen Shot Helper) Projects :- AutoIt - My projects My software never has bugs. It just develops random features. :-D
AdmiralAlkex Posted November 10, 2009 Posted November 10, 2009 a man after my own heart And i got called stupid earlier in this thread for expressing that opinion.Hey I only said your argument was stupid, I didn't mean any offence to you as a person! Now lets all be friends and code some events! .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
JackDinn Posted November 10, 2009 Posted November 10, 2009 (edited) you have my apology's sir ! Yea your right you did not say i was personally stupid , just that my argument was, which i cant even remember what it was right atm, but I'll certainly give way to you on that one. No worries, its all good AutoIt all the way, I will not be a lemming and follow the crowd over the cliff and into the C. Edited November 10, 2009 by JackDinn Thx all,Jack Dinn. JD's Auto Internet Speed Tester JD's Clip Catch (With Screen Shot Helper) Projects :- AutoIt - My projects My software never has bugs. It just develops random features. :-D
JackDinn Posted November 10, 2009 Posted November 10, 2009 (edited) LOL, aye could very well be, i really dont know, however if it is it's like being behind a shield when using AutoIt Edited November 10, 2009 by JackDinn Thx all,Jack Dinn. JD's Auto Internet Speed Tester JD's Clip Catch (With Screen Shot Helper) Projects :- AutoIt - My projects My software never has bugs. It just develops random features. :-D
AndrewG Posted November 10, 2009 Author Posted November 10, 2009 You may be right at it being the write mode to use in this case, but you should not be seeing any CPU usage at all when idle. Sorry Melba but that example definitely has something wrong! Click "play" and it drops to < 2% becouse of the sleep (500), you just need one of those in the normal loop. This would be betterexpandcollapse popup#include <GUIConstants.au3> Opt("MustDeclareVars", 1) Opt("GUIOnEventMode", 1) Global $frmMain, $g_btnPlay, $g_btnStop, $sMessage, $i_CtrlID = 0 Global $i_isPlay = False ; Makes it easier to toggle between True/False Global $i_Count = 1 $frmMain = GUICreate("Learning Looping", 800, 400, (@DesktopWidth - 800) / 2, (@DesktopHeight - 400) / 2) ; Not needed if only Default ,-1,-1) GUISetOnEvent($GUI_EVENT_CLOSE, "ExitApp") ;Master Play Controls $g_btnPlay = GUICtrlCreateButton("Play", 10, 360, 40, 30) ; Not needed if only Default , -1, -1) GUICtrlSetOnEvent($g_btnPlay, "btnPlay") $g_btnStop = GUICtrlCreateButton("Stop", 50, 360, 40, 30) ; Not needed if only Default , -1, -1) GUICtrlSetOnEvent($g_btnStop, "btnStop") ;Messages GUICtrlCreateGroup("Messages", 450, 180, 220, 140) ; Not needed if only Default , -1, -1) $sMessage = GUICtrlCreateLabel("", 460, 200, 200, 100) ; Not needed if only Default , -1, -1) GUICtrlCreateGroup("", -99, -99, 1, 1);Close group GUISetState(@SW_SHOW) While 1 Playloop() ; See if we need to play WEnd Func ExitApp() Exit EndFunc ;==>ExitApp ;Play Function Func btnPlay() $i_CtrlID = @GUI_CtrlId ; Save the ID of the button as a flag for Playloop() If $i_isPlay = False Then ; == 0 Then == is only for comparing case sensitive strings $i_isPlay = Not $i_isPlay ; Told you it is was easier! GUICtrlSetData($sMessage, $i_isPlay) ;ElseIf $i_isPlay == 1 Then Not needed as $i_IsPlay can only be True/False ; Return Else Return EndIf EndFunc ;==>btnPlay ;Stop Function - see above for explanation of changes Func btnStop() $i_CtrlID = @GUI_CtrlId If $i_isPlay = True Then $i_isPlay = Not $i_isPlay Else Return EndIf EndFunc ;==>btnStop ;Loop function Func PlayLoop() While $i_isPlay = 1 ; Again no need for == ; We only get here is the play button was pressed $i_Count = $i_Count + 1 GUICtrlSetData($sMessage, $i_isPlay & @CRLF & " Looping" & @CRLF & $i_Count) Sleep(500) ; Just so you can see what is going on in the label - my old eyes cannot cope with anything less WEnd ; We can get here if the stop button was pressed or if the ButtonID has been reset to 0 ; So if we do not check we get flickering in the label - try removing the If...Then part and see! If $i_CtrlId = $g_btnStop Then GUICtrlSetData($sMessage, $i_isPlay & @CRLF & "Stopping") ; Reset the buttonID so we do not fire anything when we loop next time $i_CtrlID = 0 Sleep (100) ; Sleep Added to save CPU EndFunc ;==>PlayLoop(One line added ) Mat Thanks Mat
AndrewG Posted November 10, 2009 Author Posted November 10, 2009 (edited) Thanks everyone. I learned a lot from this. Edited November 10, 2009 by AndrewG
AdmiralAlkex Posted November 10, 2009 Posted November 10, 2009 Isn't AutoIt built on top of C++?Something like that yes, but what has that to do with anything? Download the source if you're really curious. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
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