Page 1 of 2

DRAKON-AutoHotkey: Visual programming with AutoHotkey

Posted: 28 Mar 2014, 06:37
by vasili111
DRAKON-AutoHotkey: Visual programming with AutoHotkey




What is DRAKON
DRAKON is a is an algorithmic visual programming system for making complex and at the same time easy to understand algorithms. DRAKON is made for easy understanding for humans, not machines. DRAKON is used for programming software (including programming software for various space projects). Also DRAKON is used in medicine, law, business processes and in other non-programming related fields.


Why DRAKON is better then any other visual programming solutions?
In DRAKON clarity is above all. DRAKON is made as much ergonomic as possible, as much human readable as possible. DRAKON is very powerful and easy way for making complex algorithms. DRAKON rules for creating diagrams are cognitively optimized for easy comprehension, making it a tool for intelligence augmentation.
Some facts about DRAKON:
  • No line intersections. You will never find in DRAKON diagram two or more lines intersecting each other! Not seen in other diagramming systems!
  • Silhouette structure. It allows to break one diagram in to several logical parts. Not seen in other diagramming systems!
  • No slanting or curved lines. Only straight lines with right angles.
  • Icons are placed only on vertical lines.
  • Branching is done in a simple, visible and consistent way.
  • Each diagram has one entry and one exit.

History of DRAKON
Spoiler

What is DRAKON-AutoHotkey?
DRAKON-AutoHotkey is a hybrid visual programming language which consists of visual part of DRAKON and textual part of AutoHotkey. You can make diagrams in DRAKON and use AutoHotkey code in icons of that diagram.


More about DRAKON here:
http://drakon-editor.sourceforge.net/DRAKON.pdf
http://drakon-editor.sourceforge.net/language.html
http://en.wikipedia.org/wiki/DRAKON


What is DRAKON Editor?
DRAKON Editor is free, open source and multiplatform tool for creating DRAKON diagrams and generating code from them. In most part DRAKON Editor is developed using DRAKON system. There are several software for creating DRAKON diagrams. Currently generation of AutoHotkey code from DRAKON diagrams is possible only with DRAKON Editor. DRAKON Editor main developer is Stepan Mitkin. AutoHotkey code generator for DRAKON Editor is created by me.

Warning: At the moment code generation for AutoHotkey is on beta stage of development and some details is subject to change!

DRAKON Editor also supports code generation for other programming languages: Java, Processing.org, D, C#, C/C++ (with Qt support), Python, Tcl, Javascript, Lua, Erlang and Verilog.

Homepage of DRAKON Editor: http://drakon-editor.sourceforge.net/
GitHub of DRAKON Editor: http://github.com/stepan-mitkin/drakon_editor/


How to install DRAKON Editor:
1. Download and install latest version of ActiveTcl Free version from here: http://www.activestate.com/activetcl
2. Download DRAKON Editor from http://drakon-editor.sourceforge.net/ed ... #downloads and unpack in any location.
3. Double click drakon_editor.tcl file (is located in DRAKON Editor folder) to launch DRAKON Editor.


Documentations and examples for DRAKON-AutoHotkey:
Documentations for using DRAKON-AutoHotkey are located in docs\AutoHotkey folder. Read it before using AutoHotkey! If you read old version of documentation from attachment of this post then you need to read documentation from current version of DRAKON Editor, because there are substantial changes in a new AutoHotkey code generator.

Examples of DRAKON-AutoHotkey are located in examples\AutoHotkey


Known bugs:
There is no working Foreach loop in AutoHotkey code generator. Don't try to use it until it officially added to prevent unexpected behaviour! I mean the Foreach loop of DRAKON here, not the Foreach loops of AutoHotkey!



The main thread of DRAKON-AutoHotkey is this current thread. But there is also another thread about DRAKON-AutoHotkey: http://www.autohotkey.com/board/topic/1 ... utohotkey/


Please give me your feedback about AutoHotkey code generation. What you think about it? What you think need to be changed? What you think need to be added? Is there any bugs?

Ask any questions you want related to DRAKON, using DRAKON Editor and AutoHotkey code generation in current thread. I will be glad to help you as much as I can.




Don't Use AutoHotkey code generator and documentation from attachment of this post! They are outdated and are here only if you have diagrams that need that version of code generator!
To use this old version of code generator:
1. Download and install latest version of ActiveTcl Free version from here: http://www.activestate.com/activetcl
2. Download DRAKON Editor 1.22 from here: http://sourceforge.net/projects/drakon-editor/files/ . Unpack anywhere you want.
3. Download AutoHotkey code generator.zip from the attachment and unpack it to \generators folder of DRAKON Editor.

Re: DRAKON-AutoHotkey: Space programs programming technology

Posted: 29 Mar 2014, 02:56
by vasili111
There are two videos of DRAKON Editor:



and



In these two videos is used another programming language, not Autohotkey. Also these videos are form old version of DRAKON Editor and new versions have some improvments.


Also some screenshots:
Spoiler

Re: DRAKON-AutoHotkey: Space programs programming technology

Posted: 29 Mar 2014, 15:17
by vasili111
I think this question will be interesting for users of DRAKON Editor at ahkscript.org .
I was asked by ObiWanKenobi at http://www.autohotkey.com/board/topic/1 ... /?p=640232
Hello vasili how do you handle return?
There is only one "End" allowed in charts, but how would i draw several returns like für example:
function my_function(a) {
if (a=0) {
return "zero"
} else if (a=1) {
return "one"
} else {
return "any other"
}
}
My answer:
I do it that way:

Code: Select all

my_function(a) {
    if (a=0) {
	b := "zero" 
    } else if (a=1) {
	b := "one"
    } else {
	b := "any other"
    }
    return b
}
Here is DRAKON diagram for that code:
Image


In attachment you can download that diagram in .drn format (DRAKON Editor format).

Re: DRAKON-AutoHotkey: Space programs programming technology

Posted: 30 Mar 2014, 15:22
by vasili111
At autohotkey.com thread there was interesting question from ObiWanKenobi:
Hello Vasili, what does shelf icon and connector icon mean?
Currently ahkscript.org does not supports large images in posts, so I will be putting here a links of my posts at autohotkey.com :

Connector icon
http://www.autohotkey.com/board/topic/1 ... /?p=640352

Shelf icon
http://www.autohotkey.com/board/topic/1 ... /?p=640372

Re: DRAKON-AutoHotkey: Space programs programming technology

Posted: 01 Apr 2014, 01:23
by vasili111
Here is an example of using AutoHotkey with DRAKON : http://www.autohotkey.com/board/topic/1 ... /?p=640550

Re: DRAKON-AutoHotkey: Space programs programming technology

Posted: 03 Apr 2014, 02:08
by vasili111
Generator for AutoHotkey updated, beta v1.5:
Added extra return to end of header and beginning of footer.
Some corrections of autogenerated comments for generated code.

Download links are in the attachment of first post.

Re: DRAKON-AutoHotkey: Space programs programming technology

Posted: 19 Apr 2014, 10:11
by vasili111
DRAKON Editor is now on GitHub: http://github.com/stepan-mitkin/drakon_editor/

Re: DRAKON-AutoHotkey: Space programs programming technology

Posted: 02 May 2014, 16:19
by toralf
Drakon is very interesting.
I read the PDF and looked on the Wikipedia info. The PDF mentions Drakon-2, but I Couldn't find any info on that.

As far as I understood the language so far: you write the individual AHK commands as actions but the program flow is defined grafically. I can see the use when it is essential to be error free and maintain friendly.

But how are GUI programmed?
1 start
2 build GUI
3 show GUI

But how do you then programm the different options the user has? I guess the switch is not the right command?
Is there a visual representation in Drakon to "list/show" all the possible actions?

How do you distinguish in Drakon between subroutines and functions? How do you hand over parameters ?

Re: DRAKON-AutoHotkey: Space programs programming technology

Posted: 04 May 2014, 11:47
by vasili111
toralf wrote:Drakon is very interesting.
I read the PDF and looked on the Wikipedia info. The PDF mentions Drakon-2, but I Couldn't find any info on that.
As far as I know author of DRAKON does not using term DRAKON-2. I think that term is used by pdf autor only. There are aditional icons for realtime programming. It is possible to draw diagrams using realtime icons with DRAKON editor, but at that time there is not code generation support from them. If you are interested in realtime icons I can explain them, but as I mention before code generation is not supported by DRAKON Editor at that time.
If you need to use parallel process you can use Process icon to implement it.
toralf wrote: As far as I understood the language so far: you write the individual AHK commands as actions but the program flow is defined grafically. I can see the use when it is essential to be error free and maintain friendly.
Exactly. All program flow is graphical only and the code for script flow is generated by DRAKON Editor from diagrams. You dont wright any program flow code. You can only use goto and/or gosub command ONLY for calling Free type diagram (See more about Free type in documentation zip file).
DRAKON is extensively used in Space programs, where clarity of algorithms is at first place, where errors in code have very dramatic consequences. It is made for making as less possible errors in code as possible.
toralf wrote: But how are GUI programmed?
1 start
2 build GUI
3 show GUI
You are writing all commands for GUI creation inside action icons. Here is one simple GUI script example: http://www.autohotkey.com/board/topic/1 ... /?p=640550
If you need to use non standard If statments like IfMsgBox the only way to use it is to write all statement it inside action icon. Also as far as I know the AutoHotkey v2 will get remove all nonstandard If statements.
If you need some other example of creating GUI with DRAKON, then please give me the AutoHotkey code for it and I will try to make DRAKON diagram for it.
toralf wrote: But how do you then programm the different options the user has? I guess the switch is not the right command
You mean the case when there is several options to choose from and not only YES or NO ? You can implement that using several question icons or with Switch macroicon (read more in documentations.zip that is attached to the first post). Keep in mind that I have submitted patch for next version of DRAKON Editor code generation for Switch macroicon for all supported languages (you can get development version that supports improved version of Switch macroicon form http://github.com/stepan-mitkin/drakon_editor/ . Read readme.md how to use it. Also read updated documentation form examples\AutoHotkey folder. keep in mind also that in developmet version for parameter commenting we use ;)
toralf wrote: Is there a visual representation in Drakon to "list/show" all the possible actions?
Can you please explain that question more?

toralf wrote: How do you distinguish in Drakon between subroutines and functions? How do you hand over parameters ?
About using subroutins, functions and hotkeys and parameters for functions please read about them in documentations.zip that is attached to the first post.

If my answers need some more clarification feel free to ask. If you have some other questions I will be glad to answer.

SOLVED: cannot generate AHK code

Posted: 27 Jun 2014, 04:30
by Awannaknow
*** UPDATE ***
I found out:
1- After close/reopen Drakon, all is working
2- Found in the doc (your link in your 1rst post: Doc1.docx in Documentation.zip) :"DRAKON Editor is currently tested with only AutoHotkey_L"
*** UPDATE ***
Hi Vasili111,
I luckily found out your thread about DRAKON and wanted to try it, downloaded and installed:
1- ActiveTcl8.6.1.0.297577-win32-ix86-threaded.exe
2- drakon_editor1.22.zip
3- AutoHotkey code generator beta v1.5.zip
Other details:
1- Win XP Pro
2- AutoHotkey Unicode 32-bit 1.1.11.02

I got an error:
No generator for language 'AutoHotkey_L'.
here is the pic
Spoiler
Apparently, this ahk version, which appear on the pic as AHK_L, is not the right one to try with Drakon, which version work with Drakon ?

Thanks for this DRAKON EDITOR and for help, I think I'll use it if I can make it works.

Re: SOLVED: cannot generate AHK code

Posted: 27 Jun 2014, 10:07
by vasili111
Awannaknow wrote:*** UPDATE ***
I found out:
1- After close/reopen Drakon, all is working
2- Found in the doc (your link in your 1rst post: Doc1.docx in Documentation.zip) :"DRAKON Editor is currently tested with only AutoHotkey_L"
*** UPDATE ***
Hi Vasili111,
I luckily found out your thread about DRAKON and wanted to try it, downloaded and installed:
1- ActiveTcl8.6.1.0.297577-win32-ix86-threaded.exe
2- drakon_editor1.22.zip
3- AutoHotkey code generator beta v1.5.zip
Other details:
1- Win XP Pro
2- AutoHotkey Unicode 32-bit 1.1.11.02

I got an error:
No generator for language 'AutoHotkey_L'.
here is the pic
Spoiler
Apparently, this ahk version, which appear on the pic as AHK_L, is not the right one to try with Drakon, which version work with Drakon ?

Thanks for this DRAKON EDITOR and for help, I think I'll use it if I can make it works.
Hi Awannaknow
Did you unpacked the content of AutoHotkey code generator beta v1.5.zip in the \Drakon Editor\generators folder? DRAKON Editor 1.22 works fine with AutoHotkey code generator beta v1.5.

OR

You can use DRAKON Editor from github https://github.com/stepan-mitkin/drakon_editor/ . There is upcoming version of DRAKON Editor. In current state it is tested by me and I think it works fine. That version has improvements of code generation for all supported languages and also has built in the newest version of AutoHotkey code generator wich also has some improvements. To use that version follow these steps:
1. Download upcoming version from here: https://github.com/stepan-mitkin/drakon ... master.zip
2. Unzip archive.
3. If you need to launch English version of DRAKON Editor delete folder \msgs . If you need Russion version of DRAKON Editor skip step 3.
4. Run drakon_editor.tcl

It the folder examples\AutoHotkey\ you will find updated documentation and some examples. Please read that documentation, becose it contains some changes of AutoHotkey code generator.

If something dont works after following steps above or you have any question related to DRAKON or DRAKON Editor write them here and I will help you with them.

Write ShortcutGetHotkey ShortcutSetHotkey with DRAKON

Posted: 06 Nov 2014, 03:25
by Awannaknow
Hi vasili111,
Thanks for Drakon, it easier with it.
I wonder if it's possible to write this 2 functions with it, I tried but can't find how.
I can't really 100% understand the code, because of lack of knowledge with com, object, dll . . .
Maybe it's part of why I can't write it in Drakon.
just me (ahk member) just created them to find a solution for a problem I had.
I past the whole code, so if you or someone wants to test it it'll be easy, but only the 2 functions (ShortcutGetHotkey and ShortcutSetHotkey) are what I try to write with drakon.
Here they are:

Code: Select all

#NoEnv
Target := A_ScriptDir . "\TestLnk.txt"
LnkFile := A_Desktop . "\TestLnk.lnk"
FileOpen(Target, "w").Close()
FileCreateShortcut, %Target%, %LnkFile%, , , LnkFile Test, , b
MsgBox, 0, Hotkey, % ShortcutGetHotkey(LnkFile)
ShortcutSetHotkey(LnkFile, "A", "Ctrl+Alt+Shift")
MsgBox, 0, Hotkey, % ShortcutGetHotkey(LnkFile)
ExitApp
; ======================================================================================================================
ShortcutGetHotkey(ShortcutPath) {
   SplitPath, ShortcutPath, Name, Dir
   Shell := ComObjCreate("Shell.Application")
   ShellLink := Shell.NameSpace(Dir).ParseName(Name).GetLink
   HK := ShellLink.Hotkey
   Key := Chr(DllCall("User32.dll\MapVirtualKey", "UInt", HK & 0xFF, "UInt", 2, "UInt"))
   HK >>= 8
   Mods := (HK & 2 ? "Ctrl+" : "") . (HK & 4 ? "Alt+" : "") . (HK & 1 ? "Shift+" : "")
   Return (Mods . Key)
}
; ======================================================================================================================
ShortcutSetHotkey(ShortcutPath, Key, Modifiers := "") {
   Static ModValues := {Alt: 4, Ctrl: 2, Shift: 1}
   Key := DllCall("User32.dll\VkKeyScan", A_IsUnicode ? "UShort" : "UChar", Asc(Key), "Short") & 0xFF
   If (Key = 0xFF)
      Return False
   ModArray := StrSplit(Modifiers, "+")
   If (ModArray.MaxIndex() < 2) || (ModArray.MaxIndex() >  3)
      Return False
   Mods := 0
   For Each, Mod In ModArray
      Mods |= (M := ModValues[Mod]) ? M : 0
   If Mods In 0,1,2,4
      Return False
   SplitPath, ShortcutPath, Name, Dir
   Shell := ComObjCreate("Shell.Application")
   ShellLink := Shell.NameSpace(Dir).ParseName(Name).GetLink
   ShellLink.Hotkey := (Key | (Mods << 8))
   ShellLink.Save
   Return True
}

yes no msgbox

Posted: 12 Nov 2014, 10:06
by Awannaknow
Any help appreciated.
From example code in help file which is almost what I need to do,

Code: Select all

MsgBox, 4,, Would you like to continue? (press Yes or No)
IfMsgBox Yes
    MsgBox You pressed Yes.
else
    MsgBox You pressed No.
I tried this, and lots of variations, but not working:Image
This is working, but surely not the correct way of doing it:
Image
Thanks in advance.

Re: DRAKON-AutoHotkey: Space programs programming technology

Posted: 12 Nov 2014, 14:44
by vasili111
Hi Awannaknow :)

I cant tell you anything about two AutoHotkey functions that you posted above because I don't understand it (I don't know how to use com, object, dll and etc. with AutoHotkey).
But, actually any AutoHotkey code can be converted to DRAKON-AutoHotkey (hybrid language, AutoHotkey with DRAKON) with DRAKON Editor. But because AutoHotkey has several different If (IfXXX, like IfMsgBox and etc.) statements and currently AutoHotkey code generation with DRAKON Editor supports only regular If statement, we can't use directly not regular If statments (like IfMsgBox and etc). But there are two other ways we can use them:

First, as you mentioned before:
Image

Just remember any code that is inside Action icon is always directly sent to generated .ahk file as is.

Second:
Image

The idea above is that, in Action icon we put code with not regular If statement which will assign the result to the variable. After that we can use that variable in DRAKON If icon or in DRAKON Switch macroicone (Select/Case icons). So that way we can manage the result in DRAKON way. For, example we can:

Image

In above example, in any way we are not changing Action icon which assigns variable. We operate with the result of that action icon in DRAKON way. I understand that it is not really DRAKON way of making diagrams, because in DRAKON we should not need to use that Action icon and we should never use directly If or any other branching statements with DRAKON. But I think that because we can manage the result in DRAKON way Second method is better than First.

Also, DRAKON-AutoHotkey code generator has improved and I will post last version in several days.

If you have any other questions or you don't understand something that I wrote, ask and I will be glad to answer :)

Re: DRAKON-AutoHotkey: Space programs programming technology

Posted: 12 Nov 2014, 20:42
by Awannaknow
Everything is perfectly clear, the var=yes, var= no solution is what I will use until some new version comes out.
Thanks a lot.
It's perfectly usable like that, for what I want to do.
I can't tell you anything about two AutoHotkey functions that you posted above because I don't understand it (I don't know how to use com, object, dll and etc. with AutoHotkey).
Neither do I . . .
I though I was unable to do anything concerning ahk and drakon.
What a relief!
;-)
About the functions, I will write them manually at the end of the code in created ahk file as I do when I code directly in an ahk file.
I'm so curious to see how they looks like graphically in drakon, maybe one day . . . someone will know how to code it in drakon.
And also, having them presented graphically may be helpful to understand them.

Re: DRAKON-AutoHotkey: Space programs programming technology

Posted: 13 Nov 2014, 08:52
by vasili111
Awannaknow wrote:Everything is perfectly clear, the var=yes, var= no solution is what I will use until some new version comes out.
As far as I know, AutoHotkey V2 will only have one If statement. All IfXXX (like IfMsgBox and etc.) will be replaced like: IfMsgBox replaced with A_MsgBoxResult. So it will be much easier to use AutoHotkey with DRAKON Editor.

Awannaknow wrote: About the functions, I will write them manually at the end of the code in created ahk file as I do when I code directly in an ahk file.
You dont need to add AutoHotkey code manually. Actually, you never have to edit .ahk file manually. You can put all that kind of code in Action icon in Free type diagram (look in Documentation.zip) and all code will go to generated .ahk file as is and you can call that functions from other diagrams.

Re: DRAKON-AutoHotkey: Space programs programming technology

Posted: 13 Nov 2014, 09:18
by Awannaknow
So it will be much easier to use AutoHotkey with DRAKON Editor.

Good! It is already very helpful (for me).
You can put all that kind of code in Action icon in Free type diagram

Yes, of course! I didn't thought about doing it like that when I wrote my answer.

Re: DRAKON-AutoHotkey: visual programming with AutoHotkey

Posted: 28 Nov 2014, 10:50
by vasili111
1. First post of this thread updated.
2. New version of DRAKON Editor with current version of AutoHotkey code generator added (see the section "How to install DRAKON Editor" of the first post of current thread).

Re: DRAKON-AutoHotkey: Visual programming with AutoHotkey

Posted: 29 Nov 2014, 10:20
by vasili111
1. New version of DRAKON Editor released, v 1.24! It has built in correct version of AutoHotkey code generator. Download it from: http://drakon-editor.sourceforge.net/ed ... #downloads
2. If you read old version of documentation from attachment of first post of this thread, then you need to read documentation from current version of DRAKON Editor (located in docs\AutoHotkey folder), because there are substantial changes in a new AutoHotkey code generator.
3. You can check some examples of DRAKON-AutoHotkey from examples\AutoHotkey folder.

Re: DRAKON-AutoHotkey: Visual programming with AutoHotkey

Posted: 03 Dec 2014, 09:09
by vasili111
Example
Screenshot of the diagram for calculation Fibonacci numbers


Image