Jump to content

Inserting Koda design into a script automatically


martin
 Share

Recommended Posts

I use Koda and I use this program to insert the gui design into my script.

It's very basic and does what I need but it might be of help to someone.

The idea is that in your script where the gui design has to go you simply write an include statement

;start of gui design

#include kodadesignoutput.au3

;end of gui design

The program below makes the include file, or rewrites it, every time you use Tools|Generate code.

When you start the program it asks for the file name for the include which you have to sure is the same as the one in your include statement.

It just saves having to cut and paste every time.

Note added 18th Sept

The Update option in Koda version 1.6.0.1 makes this unnecessary so read no further!

;KODAID

#include 'D:\Program Files\AutoIt3\beta\Include\GUIConstants.au3'

HotKeySet("^!k", "MyExit");CTRL ALT K to end otherwise it will end when Koda Designer ends
;this file is the one created by Kodaid
$file1 = FileOpenDialog('Select include file fo rthe Koda design','\',"Autoitipt file (*.au3)",2)

    WinWaitActive('oda FormDesigner')
while 1
    WinWaitActive('Code',"",3)
    
    if WinActive('Code') Then
        $t = WinGetText ( "Code")
                dothebus()
;must wait untill not active because it still exists when its 'closed'
;maybe just invisible
        WinWaitNotActive('Code')
        
    EndIf
    if not WinExists('oda FormDesigner') then ExitLoop


WEnd


Func dothebus()
    
$ff = FileOpen('tempkodaid.txt',2)
FileWriteLine($ff,'start of copy from Code window')
FileWriteLine($ff,$t)
FileClose($ff)
$fout = Fileopen($file1,2)
$fin = FileOpen('tempkodaid.txt',0)
while 1
    $ll = FileReadLine($fin)
    if @error = -1 Then ExitLoop
    If StringInStr($ll,'### Koda GUI section start ###') Then ExitLoop
    WEnd
while 1
    FileWriteLine($fout,$ll)
    $ll = FileReadLine($fin)
    if @error = -1 Then ExitLoop
    If StringInStr($ll,'### Koda GUI section end   ###') Then
     FileWriteLine($fout,$ll)
     ExitLoop
    EndIf

    WEnd 
FileClose($fin)
FileClose($fout)
            
EndFunc

Func MyExit()
    MsgBox(0x40000,"Stopped Kodaid" ,"Aborted.")
    Exit
EndFunc
Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Have you looked at KodaWrapper?

“Give a man a script; you have helped him for today. Teach a man to script; and you will not have to hear him whine for help.”AutoIt4UE - Custom AutoIt toolbar and wordfile for UltraEdit/UEStudio users.AutoIt Graphical Debugger - A graphical debugger for AutoIt.SimMetrics COM Wrapper - Calculate string similarity.

Link to comment
Share on other sites

Have you looked at KodaWrapper?

Thanks Stumpii, I didn't know about that.

However, I have followed the instructions given by JdeB and run Scite and run Koda, made a design, closed Koda (seems a shame to need to do that) and nothing happens.

The instructions say:-

To get this prototype working for the people using the current SciTE4AutoIt3 install do the following:

- Download attached KodaWrapper.zip and save it in C:\Program Files\AutoIt3\SciTe\FormDesigner.

- UNzip

- Add these lines to SciTEUser.properties:

# 12 FormWrapper for lookfar's Koda FormDesigner

command.12.$(file.patterns.au3)="$(SciteDefaultHome)\Koda\KodaWrapper.exe" "$(FilePath)"

command.save.before.12.$(file.patterns.au3)=1

Is there an error here? It says to unzip Kodawrapper.zip in the FormDesigner folder but the lines to add to the SciteUser.properties refer to "$(SciteDefaultHome)\Koda\KodaWrapper.exe" "$(FilePath)". Anyway I tried putting a copy of KodaWrapper in that directory but still nothing.

Incidentally, do you know how I can get SCite to automatically update files which have been modified by another application after Scite loaded them? It has stopped me making a better version of my own Koda design updater.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Thanks Stumpii, I didn't know about that.

However, I have followed the instructions given by JdeB and run Scite and run Koda, made a design, closed Koda (seems a shame to need to do that) and nothing happens.

The instructions say:-

To get this prototype working for the people using the current SciTE4AutoIt3 install do the following:

- Download attached KodaWrapper.zip and save it in C:\Program Files\AutoIt3\SciTe\FormDesigner.

- UNzip

- Add these lines to SciTEUser.properties:

# 12 FormWrapper for lookfar's Koda FormDesigner

command.12.$(file.patterns.au3)="$(SciteDefaultHome)\Koda\KodaWrapper.exe" "$(FilePath)"

command.save.before.12.$(file.patterns.au3)=1

Is there an error here? It says to unzip Kodawrapper.zip in the FormDesigner folder but the lines to add to the SciteUser.properties refer to "$(SciteDefaultHome)\Koda\KodaWrapper.exe" "$(FilePath)". Anyway I tried putting a copy of KodaWrapper in that directory but still nothing.

Incidentally, do you know how I can get SCite to automatically update files which have been modified by another application after Scite loaded them? It has stopped me making a better version of my own Koda design updater.

I don't use SciTE, so am unable to help in that regard. You may want to request help in the KodaWrapper forum.

“Give a man a script; you have helped him for today. Teach a man to script; and you will not have to hear him whine for help.”AutoIt4UE - Custom AutoIt toolbar and wordfile for UltraEdit/UEStudio users.AutoIt Graphical Debugger - A graphical debugger for AutoIt.SimMetrics COM Wrapper - Calculate string similarity.

Link to comment
Share on other sites

  • Developers

Thanks Stumpii, I didn't know about that.

However, I have followed the instructions given by JdeB and run Scite and run Koda, made a design, closed Koda (seems a shame to need to do that) and nothing happens.

How did you start Koda ? it needs to be started with the option under Tools....

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

How did you start Koda ? it needs to be started with the option under Tools....

OK, I've tried that (I had been starting KodaWrapper by double clicking on it in explorer, but the result is no different.)

I am asked the form name so I type 'AForm2'. I don't know what the new name is for but I type something in. Koda starts but not with either form. I open the project which has the AForm2 and when I close Koda using Alt X I get a message

"Nothing from Koda to insert into Scite."

The operation seems a bit awkward, and I don't know what the form name and new name are for. My impression at the moment is that is isn't quicker and easier than cutting and pasting from the Koda Code form.

My solution was not wonderful but with my approach you only have to choose the source file and then run Koda.

You don't have to close Koda and you can keep going back to it as often as you like. You just press F9 to view code whenever you have changed the design, and your source is updated. It may be your solution is much better but for me it isn't as good yet.

Any idea what I'm doing wrong?

One thing that could be the problem is the folders everything is stored in. Does KodaWrapper need to have everything in a certain place?

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

  • Developers

KodaWrapper was just a proof of concept at the time and didn't get a lot of chears so I haven't continued.

I believe a asked for testers and ideas and only Stumpii replied, so assumed there was no greater interest in the development.

I still think that the ideal world would be that you can maintain the GUI's by starting a program from within the Editor which will pickup the GUI and show it in the GUI editor.

To my knowlegde that should still work with Kodawrapper, but am not 100% sure...

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

Ok well I'm convinced my method is an easy one and it works. I have changed it so that it now inserts the design directly into the source code, or replaces the existing design if there is one.

To use it you just compile Kodaid2.au3 and run it. It starts by asking for the source file to have the design code inserted.

It doesn't matter if it's started after or before Koda and it can be used with any editor.

If the source is new and doesn't have a Koda design included then you must add the line

;KODA_START

or at least a line with KODA_START in it so that the porgram knows where to insert the code.

If Koda is closed then Kodaid2 closes too. Otherwise it can be closed by CTRL + Alt + K.

As soon as you change the Koda design just press F9, and when the Code form appears you can close it. Your code is then updated with the new design. Also, Koda can be kept open.

Here is the code.

;Kodaid2.au3
;Modified 17th Sept to allow for changes in latest version of Koda = 1.601
;works with version 1.5 or later
#include 'D:\Program Files\AutoIt3\beta\Include\GUIConstants.au3'
;#include <GUIConstants.au3>


HotKeySet("^!k", "MyExit");CTRL ALT K to abort otherwise it will close when Koda Designer closes

;this file is the where the Koda design will be inserted
;if the file is new and there is not a koda design inserted yet then add a line;KODA_START to
;mark where the design code should go.
$file1 = FileOpenDialog('Select Source file forvthe Koda design','\',"Autoit Script file (*.au3)",2)


WinWaitActive('oda FormDesigner')
While 1
    WinWaitActive('Code',"",3)

    If WinActive('Code') Then
        $t = WinGetText ( "Code")
;MsgBox(0,'','K copy starting')
        InsertKoda()
;must wait untill not active because it still exists when its 'closed'
;maybe just invisible
        WinWaitNotActive('Code')

    EndIf
      ;if Koda closed then stop
    If NOT WinExists('oda FormDesigner') Then ExitLoop


WEnd
;################endof program


Func InsertKoda()

FileCopy($file1,'sourcecopy.txt',1)

If NOT FileExists($file1) Then
    MsgBox(0,'',$file1 & ' has disappeared!')
    Exit
EndIf

$ff = FileOpen('tempkodaid.txt',2)
FileWriteLine($ff,'start of copy from Code window')
FileWriteLine($ff,$t)
FileClose($ff)

$fout = FileOpen('sourcecopy.txt',2)
If $fout = -1 Then
 MsgBox(0,'','Cannot open $fout')
 Exit
EndIf


$fink = FileOpen('tempkodaid.txt',0)
If $fink = -1 Then
 MsgBox(0,'','Cannot open $fink')
 Exit
EndIf

$fins = FileOpen($file1,0)
If $fins = -1 Then
    MsgBox(0, "Error", "Unable to open file fins.")
    Exit
EndIf



$firstK = 0;
;copy source copy to $fout until we get to ### Koda
While 1
    $ll = FileReadline($fins)
    If @error = 1 Then MsgBox(0,'','@error 1 from read line from $fins')
    If @error = -1 Then MsgBox(0,'','@error 0 from readline from $fins')

    If StringInStr($ll,'KODA_START') Then
        $firstK = 1
        ExitLoop
    EndIf

    If @error = -1  Then ExitLoop
    $llup = StringUpper($ll)
    if StringInStr($llup,'KODA') and StringinStr($llup,'START') and StringInStr($llup,'GUI')Then ExitLoop
    FileWriteLine($fout,$ll)

    WEnd

While 1;find start of Koda design
    $ll = FileReadline($fink)
    If @error = -1 Then ExitLoop
    $llup = StringUpper($ll)
    if StringInStr($llup,'KODA') and StringinStr($llup,'START') and StringInStr($llup,'GUI')Then ExitLoop
    
    WEnd
While 1;copy Koda design to source file
    FileWriteLine($fout,$ll)
    $ll = FileReadline($fink)
    If @error = -1 Then ExitLoop
    If StringInStr($ll,'KODA') and StringInStr($llup,'END') and StringInStr($llup,'GUI') then
     ExitLoop
        EndIf

    WEnd

If $firstk = 0 Then;find strat of remaining source code if Koda design has been inserted before
    While 1
    $ll = FileReadline($fins)
    If (@error = -1) OR StringInStr($ll,'### Koda GUI section end   ###')  Then ExitLoop

    WEnd
 EndIf


While 1;copy rest of source code
    $ll = FileReadline($fins)
    If @error = -1  Then ExitLoop
    FileWriteLine($fout,$ll)
    WEnd


If FileClose($fins) = 0 Then MsgBox(0,'','cannot close $fins')

If FileClose($fink) = 0 Then MsgBox(0,'','cannot close $fink')

If FileClose($fout) = 0 Then MsgBox(0,'','cannot close $fout')

If FileCopy('sourcecopy.txt',$file1,1) = 0 Then MsgBox(0,'','copy failed')


EndFunc

Func MyExit()
    MsgBox(0x40000,"Stopped " ,"Kodaid Aborted.")
    Exit
EndFunc
Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

I use Koda and I use this program to insert the gui design into my script.

It's very basic and does what I need but it might be of help to someone.

The idea is that in your script where the gui design has to go you simply write an include statement

Martin, you didn't noticed "Update" menu item under Tools menu? This function is allow you to do exactly what you want.

First, start and save form, then generate code and save it to au3 file near the form. Now, you ready to use update function: each time you call it, corresponding GUI section in your script will be updated.

You can have multiple GUI sections in one script too (section beginning refer to form file).

You can open au3 file directly from the Koda - all GUIs will be opened.

PS I know, this is undocumented yet... :)

Link to comment
Share on other sites

Martin, you didn't noticed "Update" menu item under Tools menu? This function is allow you to do exactly what you want.

First, start and save form, then generate code and save it to au3 file near the form. Now, you ready to use update function: each time you call it, corresponding GUI section in your script will be updated.

You can have multiple GUI sections in one script too (section beginning refer to form file).

You can open au3 file directly from the Koda - all GUIs will be opened.

PS I know, this is undocumented yet... :)

Thanks Lazycat, it sounds like it's just what I want. I had noticed the update option but it was greyed out so I assumed it was to be developed. I've tried saving the script to a file but the Update option is still disabled.

What do you mean by 'save it to au3 file near the form'? Maybe this is the bit I.m doing wrong.

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Thanks Lazycat, it sounds like it's just what I want. I had noticed the update option but it was greyed out so I assumed it was to be developed. I've tried saving the script to a file but the Update option is still disabled.

What do you mean by 'save it to au3 file near the form'? Maybe this is the bit I.m doing wrong.

(Sorry I misssed that feature.)

Near - I mean in same folder with form. In this case script will be found when opening form.

But you right - Koda not found script with saved GUI code until you restart Koda... This is not convenient behaviour, I think this function should be updated in some way.

Link to comment
Share on other sites

Near - I mean in same folder with form. In this case script will be found when opening form.

But you right - Koda not found script with saved GUI code until you restart Koda... This is not convenient behaviour, I think this function should be updated in some way.

I've done that and it works great. Really good.

It would be better if there was a menu option to let you asscoiate the script at any time rather than just at start up. It was not obvious to me that I had to save the form, close Koda then start again before I could use the Update feature. Even better if you were also asked every time you started a new design or 'saved as'.

Koda has become an excellect tool. Congratulations. I look forward to future developments.

(By the way, the Options,Format 'indent' and 'strip "A" prefix from default name' are not saved and have to be reset every time.)

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...