Sign in to follow this  
Followers 0
orange

Koda Code Cleaner

6 posts in this topic

I just wrote this up a moment ago, and thought that I would share, since I find it particularly useful.

When designing a GUI for a program, Koda's output code is not all that useful, since it does not include functions, or a complete Switch within the main While loop.

My really simple code translates button and menu item declarations into temporary functions, and cases for the switch.

My code turns this:

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("AForm1", 228, 167, 193, 115)
$Button1 = GUICtrlCreateButton("AButton1", 16, 72, 201, 73, 0)
$Label1 = GUICtrlCreateLabel("ALabel1", 24, 40, 43, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
 $nMsg = GUIGetMsg()
 Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
 EndSwitch
WendoÝ÷ Øí¡8b±«­¢+Ø¥¹±Õ±ÐíU%
½¹ÍѹÑ̹ÔÌÐì((I¥½¸MQIP-½U$ÍÑ¥½¸½É´ô(ÀÌØí½É´ÄôU%
ÉÑ ÅÕ½Ðí½É´ÄÅÕ½Ðì°ÈÈà°ÄØÜ°ÄäÌ°ÄÄÔ¤(ÀÌØí    ÕÑѽ¸ÄôU%
Ñɱ
ÉÑ    ÕÑѽ¸ ÅÕ½Ðí   ÕÑѽ¸ÄÅÕ½Ðì°ÄØ°ÜÈ°ÈÀÄ°ÜÌ°À¤(ÀÌØí1°ÄôU%
Ñɱ
ÉÑ1° ÅÕ½Ðí1°ÄÅÕ½Ðì°ÈаÐÀ°ÐÌ°Äܤ)U%MÑMÑÑ¡M]}M!=¤(¹I¥½¸9-½U$ÍÑ¥½¸()]¡¥±Ä(ÀÌØí¹5ÍôU%Ñ5Í ¤(MÝ¥Ñ ÀÌØí¹5Í(
ÍÀÌØíU%}Y9Q}
1=M(á¥Ð(
ÍÀÌØí  ÕÑѽ¸Ä(   ÕÑѽ¸Åչѥ½¸ ¤(¹MÝ¥Ñ )]¹()Õ¹    ÕÑѽ¸Åչѥ½¸ ¤(µÍ½à À°À°ÌäíQ¡Õ¹Ñ¥½¸  ÕÑѽ¸Åչѥ½¸ ¤¥Ìݽɭ¥¹ÁɽÁɱä¸Ìäì¤)¹Õ¹oÝ÷ ØÚ-­æ¥&¥ØZµ©Î)ànëpéò¢ç^²('zÊ^r&¥)Z®P0Øm¢{(}»­¶ìjwfz{¢µé¬©"îËb¢{¢·r·n+h}ªZr,¥ç"~'¦i×­+¢¹Z®Pjh(x-¢ë¶¬jZ-²!¢¬¢g¨ç¥±çø§u«¬yú+Ûh¡«­¢+Ø¥¹±Õ±ÐíU%
½¹ÍѹÑ̹ÔÌÐì((ÀÌØí½É´ÄôU%
ÉÑ ÅÕ½Ðí-½
±¹ÈÅÕ½Ðì°ÈàÈ°ÐÐÜ°ÄäÌ°ÄÄÔ¤(ÀÌØí
±¹¥Ñ    ½àôU%
Ñɱ
ÉѥРÅÕ½ÐìÅÕ½Ðì°à°à°ÈØÔ°ÌÜÜ° ¥Ñ=H ÀÌØíM}UQ=YM
I=10°ÀÌØíM}UQ=!M
I=10°ÀÌØíM}]9QIQUI8°ÀÌØí]M}YM
I=10¤¤)U%
ÑɱMÑÑ ´Ä°±¥ÁÐ ¤¤(ÀÌØí
±¹
½  ÕÑѽ¸ôU%
Ñɱ
ÉÑ    ÕÑѽ¸ ÅÕ½Ðí
±¹
½  ÕÑѽ¸ÅÕ½Ðì°ÌÈ°ÐÀÀ°ÈÈÔ°ÌÌ°À¤)U%MÑMÑÑ¡M]}Í¡½Ü¤()]¡¥±Ä(ÀÌØí¹5ÍôU%Ñ5Í ¤(MÝ¥Ñ ÀÌØí¹5Í(
ÍÀÌØíU%}Y9Q}
1=M(á¥Ð(ÍÀÌØí
±¹
½  ÕÑѽ¸(
±¹
½ ¤(¹MÝ¥Ñ )]¹(()Õ¹
±¹
½ ¤(ÀÌØí]¡¥±1½½ÀôÅÕ½Ðí]¡¥±ÄÅÕ½ÐìµÀì
ɱ|(µÀìѵÀìÅÕ½ÐìÀÌØí¹5ÍôU%Ñ5Í ¤ÅÕ½ÐìµÀì
ɱ|(µÀìѵÀìÅÕ½ÐíMÝ¥Ñ ÀÌØí¹5ÍÅÕ½ÐìµÀì
ɱ|(µÀìѵÀìѵÀìÅÕ½Ðí
ÍÀÌØíU%}Y9Q}
1=MÅÕ½ÐìµÀì
ɱ|(µÀìѵÀìѵÀìѵÀìÅÕ½Ðíá¥ÐÅÕ½ÐìµÀì
ɱ(ÀÌØíչѥ½¹1¥ÍÐôÅÕ½ÐìÅÕ½Ðì((ÀÌØíÕ±±
½ôÕ¥ÑÉ±É ÀÌØí
±¹¥Ñ    ½à¤(ÀÌØí5¹ÔôÅÕ½ÐíU%
Ñɱ
ÉÑ5¹Õ%Ñ´ÅÕ½Ðì(ÀÌØí   ÕÑѽ¸ôÅÕ½ÐíU%
Ñɱ
ÉÑ    ÕÑѽ¸ÅÕ½Ðì(ÀÌØíÕµÁÉÉäôMÑÉ¥¹MÁ±¥Ð ÀÌØíÕ±±
½±É±°Ä¤(½ÈÀÌØí1¥¹ôÀѼսչ ÀÌØíÕµÁÉÉ䤴Ä(%MÑÉ¥¹¥¹ÍÑÈ ÀÌØíÕµÁÉÉålÀÌØí±¥¹t°ÀÌØí5¹Ô¤±ÐìÐìÀ½ÈMÑÉ¥¹¥¹ÍÑÈ ÀÌØíÕµÁÉÉålÀÌØí±¥¹t°ÀÌØí    ÕÑѽ¸¤±ÐìÐìÀÑ¡¸(ÀÌØíQµÁYÉ¥±ôMÑÉ¥¹1Ð ÀÌØíÕµÁÉÉålÀÌØí±¥¹t°MÑÉ¥¹¥¹ÍÑÈ ÀÌØíÕµÁÉÉålÀÌØí±¥¹t°ÅÕ½ÐìÅÕ½Ð줤(ÀÌØí]¡¥±1½½ÀôÀÌØí]¡¥±1½½ÀµÀìѵÀìѵÀìÅÕ½Ðí
ÍÅÕ½ÐìµÀìÀÌØíQµÁYÉ¥±µÀì
ɱ|(µÀìѵÀìѵÀìѵÀìÍÑÉ¥¹ÍÑÉ¥ÁÝÌ¡MÑÉ¥¹QÉ¥µ±Ð ÀÌØíQµÁYÉ¥±°Ä¤µÀìÅÕ½Ðíչѥ½¸ ¤ÅÕ½Ðì°à¤µÀì
ɱ(ÀÌØíչѥ½¹1¥ÍÐôÀÌØíչѥ½¹1¥ÍеÀìÅÕ½ÐíÕ¹ÅÕ½ÐìµÀìÍÑÉ¥¹ÍÑÉ¥ÁÝÌ¡MÑÉ¥¹QÉ¥µ±Ð ÀÌØíQµÁYÉ¥±°Ä¤µÀìÅÕ½Ðíչѥ½¸ ¤ÅÕ½Ðì°à¤µÀìɱµÀìQ|(µÀìÅÕ½ÐíµÍ½à À°À°ÌäíQ¡Õ¹Ñ¥½¸ÅÕ½ÐìµÀìÍÑÉ¥¹ÍÑÉ¥ÁÝÌ¡MÑÉ¥¹QÉ¥µ±Ð ÀÌØíQµÁYÉ¥±°Ä¤µÀìÅÕ½Ðíչѥ½¸ ¤ÅÕ½Ðì°à¤|(µÀìÅÕ½Ðì¥Ìݽɭ¥¹ÁɽÁɱä¸Ìäì¤ÅÕ½ÐìµÀìɱµÀìÅÕ½Ðí¹Õ¹ÅÕ½ÐìµÀìɱµÀìɱµÀìɱ(¹%(9áÐ(ÀÌØí]¡¥±1½½ÀôÀÌØí]¡¥±1½½ÀµÀìѵÀìÅÕ½Ðí¹MÝ¥Ñ ÅÕ½ÐìµÀìɱµÀìÅÕ½Ðí]¹ÅÕ½ÐìµÀìɱµÀìɱµÀìɱ(ÀÌØíÕ±±
½ôMÑÉ¥¹±Ð ÀÌØíÕ±±
½°ÍÑÉ¥¹¥¹ÍÑÈ ÀÌØíÕ±±
½°ÅÕ½Ðí]¡¥±ÄÅÕ½Ð줴Ĥ((ÀÌØíÕ±±MÉ¥ÁÐôÀÌØíÕ±±
½µÀìɱµÀìɱµÀìɱµÀìÀÌØí]¡¥±1½½ÀµÀìÀÌØíչѥ½¹1¥ÍÐ(Õ¥ÑɱÍÑÑ ÀÌØí
±¹¥Ñ    ½à°ÀÌØíÕ±±MÉ¥ÁФ(
±¥ÁÁÕÐ ÀÌØíÕ±±MÉ¥ÁФ)¹Õ¹

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I am going to use this alot, so I hope someone else can find a use for it too.

Sure can!

Thanks for sharing.

Edit:

I think I'll work at making this just test any GUI code not only Koda.

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Thank you for sharing, but I don't know if you're aware using Koda press Tools, Advanced Generate.... and adding a check mark to Generate OnEvent code and Generate events for all controls will do the same thing.


AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Nope - I didn't see that. Thanks! Esentially exactly what my little code does.

I usually don't make GUIs; most of my programs are command line based.

Another useless program! Woohoo!

Good thing the program only took 10 minutes to write! :)

EDIT:

Koda does not add events for Menu Items - Mine does. Perhaps not totally useless after all.

(Someone tell me that Koda does this, I haven't had my foot in my mouth for nearly 30 minutes)

Edited by orange

Share this post


Link to post
Share on other sites

Another useless program! Woohoo!

No. Like I said I'll make some use of it. Not everyone uses Koda you know. :)

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Oh, this is going to come in handy :P Thanks!!

I like birds but I don't like things that go "gui gui gui" in the night.

Just another bad joke :)


I am endeavoring, ma'am, to construct a mnemonic circuit using stone knives and bearskins.SpockMy UDFs:Deleted - they were old and I'm lazy ... :)My utilities:Comment stripperPolicy lister 1.07AutoIT Speed Tester (new!)

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0