Page 6 of 10

Re: v1 -> v2 Script Converter

Posted: 16 Apr 2023, 12:15
by guest3456
jsong55 wrote:
16 Apr 2023, 05:36
Are Devs still making active updates to this converter?
this is a community project. everyone is a dev. if you write AHK code you are a dev. feel free to contribute and submit pull requests along with associated test cases and they will be accepted.

Re: v1 -> v2 Script Converter

Posted: 19 Apr 2023, 06:32
by submeg
guest3456 wrote:
16 Apr 2023, 12:15
jsong55 wrote:
16 Apr 2023, 05:36
Are Devs still making active updates to this converter?
this is a community project. everyone is a dev. if you write AHK code you are a dev. feel free to contribute and submit pull requests along with associated test cases and they will be accepted.
Is there a Discord for this?

Re: v1 -> v2 Script Converter

Posted: 19 Apr 2023, 08:39
by joedf
@submeg I think this is in the AHK discord.
https://www.autohotkey.com/discord

Re: v1 -> v2 Script Converter

Posted: 19 Apr 2023, 11:25
by guest3456
submeg wrote:
19 Apr 2023, 06:32
Is there a Discord for this?
not for this specific project, no. the discord joedf linked is a general ahk discord. work on this project is coordinated on github and in this thread

Re: v1 -> v2 Script Converter

Posted: 19 Apr 2023, 16:34
by sashaatx
@guest3456

hello there,

I would love really quick pointers, huge fan and user of the converter. I am looking to add to some functions I've run in to while developing these projects:
https://github.com/samfisherirl/Auto-GUI-for-AHK-v2

I'm processing hundreds of massive GUI clone requests in AutoGUI and seeing the bounds of the converter. Its very powerful and want to propose some solutions.

I know very basic amounts of regex. If you wouldnt mind providing details on (one or more question):
- In the example of adding to improvements to the `Menu := Menu()` conversion
- It appears to happen from line ~2130-2170
- I dont understand beyond a replacement is happening, maybe this is a perfect function and I need to focus on other areas
- What are the recommended ways to translate this regex to something a newbie would understand
- Is there a key elsewhere or are embedded instructions past what Im seeing

thank you

Code: Select all

_Menu(p) {
   global Orig_Line_NoComment
   global MenuList
   global Indentation
   MenuLine := Orig_Line_NoComment
   LineResult := ""
   menuNameLine := RegExReplace(MenuLine, "i)^\s*Menu\s*[,\s]\s*([^,]*).*$", "$1", &RegExCount1)
   ; e.g.: Menu, Tray, Add, % func_arg3(nested_arg3a, nested_arg3b), % func_arg4(nested_arg4a, nested_arg4b), % func_arg5(nested_arg5a, nested_arg5b)
   Var2 := RegExReplace(MenuLine, "
      (
      ix)                  # case insensitive, extended mode to ignore space and comments
      ^\s*Menu\s*[,\s]\s*  #
      ([^,]*) \s* ,   \s*  # arg1 Tray {group $1}
      ([^,]*)              # arg2 Add  {group $2}
      .*                   #
      )"
      , "$2", &RegExCount2) ; =Add
   Var3 := RegExReplace(MenuLine, "
      (
      ix)                   #
      ^\s*Menu \s*[,\s]\s*  #
      ([^,] *)     ,   \s*  # arg1 Tray {group $1}
      ([^,] *) \s* ,   \s*  # arg2 Add  {group $2}
      ([^,(]*  \(?          # % func_arg3(nested_arg3a, nested_arg3b) {group $3 start
         (?(?<=\()[^)]*\))  #   nested function conditional, if matched ( then match everything up to and including the )
         [^,]*)             #   group $3 end}
      .*$                   #
      )"
      , "$3", &RegExCount3) ; =% func_arg3(nested_arg3a, nested_arg3b)
      ; and so on..... with more clauses
     
I ended up taking a hatchet to the output gui naming scheme as a ham-fisted solution for the mean time.

Code: Select all

add_menuhandler(FNOut) ;outscript_path
{
    menuhandle := 0 ; => these denote true[1]/false[0]
    GuiEsc:= 0 ; => for various bad output code, such as 
    FindMenu := 0 ; => once MenuBar := Menubar() is found FindMenu:= 1; 
    FindMenuBar := 0 ; => 
    ; this will all get removed with methods
    ; && for loops
    newoutscript := ""
    intxt := FileRead(FNOut)
    Loop Parse, intxt, "`n", "`r" {
        if menuhandle == 0 && InStr(A_LoopField, "MenuHandler"){
            menuhandle := 1
            newoutscript .= A_LoopField . "`n"
        }
        else if (menuhandle == 1) && (GuiEsc== 0) && InStr(A_LoopField, "GuiEscape(*)") {
            newoutscript .= "MenuHandler(*) {`n`tToolTip `"Click!`", 100, 150`n}`n" A_LoopField
            GuiEsc:= 1
        }
        else if InStr(A_LoopField, "myGui.OnEvent(`"Close`", GuiEscape)") || InStr(A_LoopField, "myGui.OnEvent(`"Escape`", GuiEscape)") || InStr(A_LoopField, "Bind(`"Normal`")") || (A_LoopField == "")  {
            continue
        }
        ; else if InStr(LTrim(A_LoopField), "MenuBar.Add(") && a == 1 {
        ;     if StrSplit(LTrim(A_LoopField), "(")[1] == "MenuBar.Add" {
        ;         newoutscript .= StrReplace(A_LoopField, "MenuBar.Add(", "MenBar.Add(")
        ;         newoutscript .= "`n"
        ;     }
        ; ; }
        else if (LTrim(A_LoopField) == "Menu := Menu()") {
            newoutscript .= StrReplace(A_LoopField, "Menu := Menu()", "Men := Menu()")
            newoutscript .= "`n"
            FindMenu := 1
        }
        else if (FindMenu == 1 && InStr(LTrim(A_LoopField), "Menu.Add(")) {
            if (StrSplit(LTrim(A_LoopField), "(")[1] == "Menu.Add") {
                newoutscript .= StrReplace(A_LoopField, "Menu.Add(", "Men.Add(")
                newoutscript .= "`n"
            }
        }
        else if (LTrim(A_LoopField) == "MenuBar := Menu()") {
            newoutscript .= StrReplace(A_LoopField, "MenuBar := Menu()", "MenBars := MenuBar()")
            newoutscript .= "`n"
            FindMenuBar := 1
        }
        else if (FindMenuBar == 1) && InStr(LTrim(A_LoopField), "MenuBar.Add(") {
            if (StrSplit(LTrim(A_LoopField), "(")[1] == "MenuBar.Add") {
                newoutscript .= StrReplace(A_LoopField, "MenuBar.Add(", "MenBars.Add(")
                newoutscript .= "`n"
            }
        }
        else if (A_Index == 2) {
            newoutscript := "`;AutoGUI 2.5.8 `n`;Auto-GUI-v2 credit to autohotkey.com/boards/viewtopic.php?f=64&t=89901`n`;AHKv2converter credit to github.com/mmikeww/AHK-v2-script-converter`n"
        }
        else if InStr(A_LoopField, ".MenuToolbar := MenuBar") {
            newoutscript .= StrReplace(A_LoopField, "MenuToolbar := MenuBar", "MenuBar := MenBars")
            newoutscript .= "`n"
        }
        else {
            newoutscript .= A_LoopField . "`n"
        }
    }
    FileDelete(FNOut)
    FileAppend(newoutscript, FNOut)
}

Re: v1 -> v2 Script Converter

Posted: 20 Apr 2023, 08:03
by AHK_user
sashaatx wrote:
19 Apr 2023, 16:34
@guest3456

hello there,

I would love really quick pointers, huge fan and user of the converter. I am looking to add to some functions I've run in to while developing these projects:
https://github.com/samfisherirl/Auto-GUI-for-AHK-v2

I'm processing hundreds of massive GUI clone requests in AutoGUI and seeing the bounds of the converter. Its very powerful and want to propose some solutions.

I know very basic amounts of regex. If you wouldnt mind providing details on (one or more question):
- In the example of adding to improvements to the `Menu := Menu()` conversion
- It appears to happen from line ~2130-2170
- I dont understand beyond a replacement is happening, maybe this is a perfect function and I need to focus on other areas
- What are the recommended ways to translate this regex to something a newbie would understand
- Is there a key elsewhere or are embedded instructions past what Im seeing

thank you

Code: Select all

_Menu(p) {
   global Orig_Line_NoComment
   global MenuList
   global Indentation
   MenuLine := Orig_Line_NoComment
   LineResult := ""
   menuNameLine := RegExReplace(MenuLine, "i)^\s*Menu\s*[,\s]\s*([^,]*).*$", "$1", &RegExCount1)
   ; e.g.: Menu, Tray, Add, % func_arg3(nested_arg3a, nested_arg3b), % func_arg4(nested_arg4a, nested_arg4b), % func_arg5(nested_arg5a, nested_arg5b)
   Var2 := RegExReplace(MenuLine, "
      (
      ix)                  # case insensitive, extended mode to ignore space and comments
      ^\s*Menu\s*[,\s]\s*  #
      ([^,]*) \s* ,   \s*  # arg1 Tray {group $1}
      ([^,]*)              # arg2 Add  {group $2}
      .*                   #
      )"
      , "$2", &RegExCount2) ; =Add
   Var3 := RegExReplace(MenuLine, "
      (
      ix)                   #
      ^\s*Menu \s*[,\s]\s*  #
      ([^,] *)     ,   \s*  # arg1 Tray {group $1}
      ([^,] *) \s* ,   \s*  # arg2 Add  {group $2}
      ([^,(]*  \(?          # % func_arg3(nested_arg3a, nested_arg3b) {group $3 start
         (?(?<=\()[^)]*\))  #   nested function conditional, if matched ( then match everything up to and including the )
         [^,]*)             #   group $3 end}
      .*$                   #
      )"
      , "$3", &RegExCount3) ; =% func_arg3(nested_arg3a, nested_arg3b)
      ; and so on..... with more clauses
     
I ended up taking a hatchet to the output gui naming scheme as a ham-fisted solution for the mean time.

Code: Select all

add_menuhandler(FNOut) ;outscript_path
{
    menuhandle := 0 ; => these denote true[1]/false[0]
    GuiEsc:= 0 ; => for various bad output code, such as 
    FindMenu := 0 ; => once MenuBar := Menubar() is found FindMenu:= 1; 
    FindMenuBar := 0 ; => 
    ; this will all get removed with methods
    ; && for loops
    newoutscript := ""
    intxt := FileRead(FNOut)
    Loop Parse, intxt, "`n", "`r" {
        if menuhandle == 0 && InStr(A_LoopField, "MenuHandler"){
            menuhandle := 1
            newoutscript .= A_LoopField . "`n"
        }
        else if (menuhandle == 1) && (GuiEsc== 0) && InStr(A_LoopField, "GuiEscape(*)") {
            newoutscript .= "MenuHandler(*) {`n`tToolTip `"Click!`", 100, 150`n}`n" A_LoopField
            GuiEsc:= 1
        }
        else if InStr(A_LoopField, "myGui.OnEvent(`"Close`", GuiEscape)") || InStr(A_LoopField, "myGui.OnEvent(`"Escape`", GuiEscape)") || InStr(A_LoopField, "Bind(`"Normal`")") || (A_LoopField == "")  {
            continue
        }
        ; else if InStr(LTrim(A_LoopField), "MenuBar.Add(") && a == 1 {
        ;     if StrSplit(LTrim(A_LoopField), "(")[1] == "MenuBar.Add" {
        ;         newoutscript .= StrReplace(A_LoopField, "MenuBar.Add(", "MenBar.Add(")
        ;         newoutscript .= "`n"
        ;     }
        ; ; }
        else if (LTrim(A_LoopField) == "Menu := Menu()") {
            newoutscript .= StrReplace(A_LoopField, "Menu := Menu()", "Men := Menu()")
            newoutscript .= "`n"
            FindMenu := 1
        }
        else if (FindMenu == 1 && InStr(LTrim(A_LoopField), "Menu.Add(")) {
            if (StrSplit(LTrim(A_LoopField), "(")[1] == "Menu.Add") {
                newoutscript .= StrReplace(A_LoopField, "Menu.Add(", "Men.Add(")
                newoutscript .= "`n"
            }
        }
        else if (LTrim(A_LoopField) == "MenuBar := Menu()") {
            newoutscript .= StrReplace(A_LoopField, "MenuBar := Menu()", "MenBars := MenuBar()")
            newoutscript .= "`n"
            FindMenuBar := 1
        }
        else if (FindMenuBar == 1) && InStr(LTrim(A_LoopField), "MenuBar.Add(") {
            if (StrSplit(LTrim(A_LoopField), "(")[1] == "MenuBar.Add") {
                newoutscript .= StrReplace(A_LoopField, "MenuBar.Add(", "MenBars.Add(")
                newoutscript .= "`n"
            }
        }
        else if (A_Index == 2) {
            newoutscript := "`;AutoGUI 2.5.8 `n`;Auto-GUI-v2 credit to autohotkey.com/boards/viewtopic.php?f=64&t=89901`n`;AHKv2converter credit to github.com/mmikeww/AHK-v2-script-converter`n"
        }
        else if InStr(A_LoopField, ".MenuToolbar := MenuBar") {
            newoutscript .= StrReplace(A_LoopField, "MenuToolbar := MenuBar", "MenuBar := MenBars")
            newoutscript .= "`n"
        }
        else {
            newoutscript .= A_LoopField . "`n"
        }
    }
    FileDelete(FNOut)
    FileAppend(newoutscript, FNOut)
}
@sashaatx

I do not think this is the correct approach. Guis from v1 and v2 are completely different, so I would not advice to add this to a v1 Gui creator.
You must accept that converting Gui`s from v1 to v2 will never be optimal, because they are quite different.

I actually started with a auto-Gui for V2, written in V2, but have not done a lot of work at it recently.
Of course it is not as good and tested as the v1 original, because I started almost from scratch, but a lot of functions already work quite well.

Extracting Gui data from existing windows already works very well, also the placing and positioning controls.

Feel free to improve it, and in the same time learn more about v2.

https://github.com/dmtr99/V2GuiCreator

Re: v1 -> v2 Script Converter

Posted: 20 Apr 2023, 08:05
by SirSocks
This is very helpful. Thank you.

Re: v1 -> v2 Script Converter

Posted: 20 Apr 2023, 08:26
by sashaatx
AHK_user wrote:
20 Apr 2023, 08:03
sashaatx wrote:
19 Apr 2023, 16:34
@guest3456

hello there,

I would love really quick pointers, huge fan and user of the converter. I am looking to add to some functions I've run in to while developing these projects:
https://github.com/samfisherirl/Auto-GUI-for-AHK-v2

I'm processing hundreds of massive GUI clone requests in AutoGUI and seeing the bounds of the converter. Its very powerful and want to propose some solutions.

I know very basic amounts of regex. If you wouldnt mind providing details on (one or more question):
- In the example of adding to improvements to the `Menu := Menu()` conversion
- It appears to happen from line ~2130-2170
- I dont understand beyond a replacement is happening, maybe this is a perfect function and I need to focus on other areas
- What are the recommended ways to translate this regex to something a newbie would understand
- Is there a key elsewhere or are embedded instructions past what Im seeing

thank you

Code: Select all

_Menu(p) {
   global Orig_Line_NoComment
   global MenuList
   global Indentation
   MenuLine := Orig_Line_NoComment
   LineResult := ""
   menuNameLine := RegExReplace(MenuLine, "i)^\s*Menu\s*[,\s]\s*([^,]*).*$", "$1", &RegExCount1)
   ; e.g.: Menu, Tray, Add, % func_arg3(nested_arg3a, nested_arg3b), % func_arg4(nested_arg4a, nested_arg4b), % func_arg5(nested_arg5a, nested_arg5b)
   Var2 := RegExReplace(MenuLine, "
      (
      ix)                  # case insensitive, extended mode to ignore space and comments
      ^\s*Menu\s*[,\s]\s*  #
      ([^,]*) \s* ,   \s*  # arg1 Tray {group $1}
      ([^,]*)              # arg2 Add  {group $2}
      .*                   #
      )"
      , "$2", &RegExCount2) ; =Add
   Var3 := RegExReplace(MenuLine, "
      (
      ix)                   #
      ^\s*Menu \s*[,\s]\s*  #
      ([^,] *)     ,   \s*  # arg1 Tray {group $1}
      ([^,] *) \s* ,   \s*  # arg2 Add  {group $2}
      ([^,(]*  \(?          # % func_arg3(nested_arg3a, nested_arg3b) {group $3 start
         (?(?<=\()[^)]*\))  #   nested function conditional, if matched ( then match everything up to and including the )
         [^,]*)             #   group $3 end}
      .*$                   #
      )"
      , "$3", &RegExCount3) ; =% func_arg3(nested_arg3a, nested_arg3b)
      ; and so on..... with more clauses
     
I ended up taking a hatchet to the output gui naming scheme as a ham-fisted solution for the mean time.

Code: Select all

add_menuhandler(FNOut) ;outscript_path
{
    menuhandle := 0 ; => these denote true[1]/false[0]
    GuiEsc:= 0 ; => for various bad output code, such as 
    FindMenu := 0 ; => once MenuBar := Menubar() is found FindMenu:= 1; 
    FindMenuBar := 0 ; => 
    ; this will all get removed with methods
    ; && for loops
    newoutscript := ""
    intxt := FileRead(FNOut)
    Loop Parse, intxt, "`n", "`r" {
        if menuhandle == 0 && InStr(A_LoopField, "MenuHandler"){
            menuhandle := 1
            newoutscript .= A_LoopField . "`n"
        }
        else if (menuhandle == 1) && (GuiEsc== 0) && InStr(A_LoopField, "GuiEscape(*)") {
            newoutscript .= "MenuHandler(*) {`n`tToolTip `"Click!`", 100, 150`n}`n" A_LoopField
            GuiEsc:= 1
        }
        else if InStr(A_LoopField, "myGui.OnEvent(`"Close`", GuiEscape)") || InStr(A_LoopField, "myGui.OnEvent(`"Escape`", GuiEscape)") || InStr(A_LoopField, "Bind(`"Normal`")") || (A_LoopField == "")  {
            continue
        }
        ; else if InStr(LTrim(A_LoopField), "MenuBar.Add(") && a == 1 {
        ;     if StrSplit(LTrim(A_LoopField), "(")[1] == "MenuBar.Add" {
        ;         newoutscript .= StrReplace(A_LoopField, "MenuBar.Add(", "MenBar.Add(")
        ;         newoutscript .= "`n"
        ;     }
        ; ; }
        else if (LTrim(A_LoopField) == "Menu := Menu()") {
            newoutscript .= StrReplace(A_LoopField, "Menu := Menu()", "Men := Menu()")
            newoutscript .= "`n"
            FindMenu := 1
        }
        else if (FindMenu == 1 && InStr(LTrim(A_LoopField), "Menu.Add(")) {
            if (StrSplit(LTrim(A_LoopField), "(")[1] == "Menu.Add") {
                newoutscript .= StrReplace(A_LoopField, "Menu.Add(", "Men.Add(")
                newoutscript .= "`n"
            }
        }
        else if (LTrim(A_LoopField) == "MenuBar := Menu()") {
            newoutscript .= StrReplace(A_LoopField, "MenuBar := Menu()", "MenBars := MenuBar()")
            newoutscript .= "`n"
            FindMenuBar := 1
        }
        else if (FindMenuBar == 1) && InStr(LTrim(A_LoopField), "MenuBar.Add(") {
            if (StrSplit(LTrim(A_LoopField), "(")[1] == "MenuBar.Add") {
                newoutscript .= StrReplace(A_LoopField, "MenuBar.Add(", "MenBars.Add(")
                newoutscript .= "`n"
            }
        }
        else if (A_Index == 2) {
            newoutscript := "`;AutoGUI 2.5.8 `n`;Auto-GUI-v2 credit to autohotkey.com/boards/viewtopic.php?f=64&t=89901`n`;AHKv2converter credit to github.com/mmikeww/AHK-v2-script-converter`n"
        }
        else if InStr(A_LoopField, ".MenuToolbar := MenuBar") {
            newoutscript .= StrReplace(A_LoopField, "MenuToolbar := MenuBar", "MenuBar := MenBars")
            newoutscript .= "`n"
        }
        else {
            newoutscript .= A_LoopField . "`n"
        }
    }
    FileDelete(FNOut)
    FileAppend(newoutscript, FNOut)
}
@sashaatx

I do not think this is the correct approach. Guis from v1 and v2 are completely different, so I would not advice to add this to a v1 Gui creator.
You must accept that converting Gui`s from v1 to v2 will never be optimal, because they are quite different.

I actually started with a auto-Gui for V2, written in V2, but have not done a lot of work at it recently.
Of course it is not as good and tested as the v1 original, because I started almost from scratch, but a lot of functions already work quite well.

Extracting Gui data from existing windows already works very well, also the placing and positioning controls.

Feel free to improve it, and in the same time learn more about v2.

https://github.com/dmtr99/V2GuiCreator
Hey user,

It's probably on me for not being explicit, The solution works today as a patchwork, meanwhile-solution. I'm sure there will be challenges and a new one from the ground up is always best but I think you'd agree that's not always doable and every bridged gap between v1 and v2 means more people contributing. As of now it imports clones and writes relatively errorless GUIs. https://github.com/samfisherirl/Auto-GUI-for-AHK-v2


"You must accept that converting Gui`s from v1 to v2 will never be optimal, because they are quite different."

Thats fair, I was just hoping for regex help. "as a ham-fisted [clumbsy, sub-optimal] solution for the mean time" cheers m8

Image

Re: v1 -> v2 Script Converter

Posted: 22 Apr 2023, 05:01
by submeg
joedf wrote:
19 Apr 2023, 08:39
@submeg I think this is in the AHK discord.
https://www.autohotkey.com/discord
Thanks @joedf, I'm definitely on there already!

I just gave this a go on a test file, very cool. I'm guessing the easiest way to convert a large library would to do it function by function?

Also, how do you handle scripts / functions that others have wrote? I use plenty of things (MouseGesturesL, Radial Menu, etc) that I didn't create which have lots of depth. If I convert my "main" script that calls these others to v2, would they still work if they hadn't been converted over to v2?

Re: v1 -> v2 Script Converter

Posted: 22 Apr 2023, 05:38
by submeg
submeg wrote:
22 Apr 2023, 05:01
Also, how do you handle scripts / functions that others have wrote?
I'm using the converter to rebuild my script now, and I've found that MouseGestures and Radial Menu work fine, even though they are in v1 nomenclature. Not complaining, just surprised!

Re: v1 -> v2 Script Converter

Posted: 24 Apr 2023, 14:01
by AHK_user
@sashaatx Indeed, and it is indeed an advantage if the program can work with both v1 and v2.

I found it an interesting and usefull program, that is the reason why I made a v2 version, no idea if the original creator has any plans to move to v2.

Re: v1 -> v2 Script Converter

Posted: 04 May 2023, 05:00
by sashaatx
guest3456 wrote:
30 Nov 2016, 12:19
AHK v2 Script Converter

This is a work in progress and nowhere near complete.




------------
Hi Guest,

I reached out a week ago, I'd love to connect. I'm making a bunch of additions as I work with my EasyAutoGUI modded for v2 script.
I would just need your help with how to navigate the regex vs my instr mods. A brief chat would help me navigate the github.

Ill share what I've done with it (in a hamfisted way) but I'd need a quick chat to efficiently propose my progress with your github.

Ill post the out of context code here.

https://github.com/samfisherirl/Auto-GUI-for-AHK-v2

Code: Select all

add_menuHandler(FNOut := "path", script := "code") ;outscript_path
{
    menuHandle := 0 ; => these denote true[1]/false[0]
    GuiEsc := 0 ; => for various bad output code, such as
    FindMenu := 0 ; => once MenuBar := Menubar() is found FindMenu:= 1;
    FindMenuBar := 0 ; =>
    MenuHandleCount := 0
    brackets := 0
    RemoveFunction := 0 ; RemoveFunction==1 loops to find `}` while `{` not found in line
    new_outscript := ""
    buttonFound := 0
    editFound := 0
    editCount := 0
    Edit_Storage := []
    if FileExist(FNOut) {
        FileMove(FNOut, A_ScriptDir "\complete_application\convert\temp.txt", 1)
    }
    Loop Parse, script, "`n", "`r" {
        if (A_Index == 1) {
            new_outscript := "`n" ";AutoGUI 2.5.8 " "`n" ";Auto-GUI-v2 credit to Alguimist autohotkey.com/boards/viewtopic.php?f=64&t=89901`n;AHKv2converter credit to github.com/mmikeww/AHK-v2-script-converter`n`n"
        }
        if (RemoveFunction == 1) {
            if InStr(Trim(A_LoopField), "{") && not InStr(Trim(A_LoopField), "{") {
                brackets += 1 ; for every opening bracket, remove until equal number of closed brackets found
                continue
            }
            else if InStr(A_LoopField, "}") && not InStr(Trim(A_LoopField), "{") {
                if (brackets <= 1) {
                    RemoveFunction := 0
                    brackets := 0
                    continue
                }
                else if (brackets > 1) {
                    brackets := brackets - 1
                    continue
                }
            }
            else {
                continue
            }
        }
        if (menuHandle == 0) && (MenuHandleCount < 1) && InStr(A_LoopField, "MenuHandler") {
            menuHandle := 1
            new_outscript .= A_LoopField . "`n"
        }
        if InStr(A_LoopField, "MenuHandler(") {
            MenuHandleCount += 1
            RemoveFunction := 1
        }
        else if InStr(A_LoopField, ".Add(`"Edit`"") {
            editFound := 1
            editCount += 1
            Edit_Storage.Push("Edit_Storage" . editCount)
            new_outscript .= "Edit_Storage" editCount " := " A_LoopField "`n"
            ;ogcButtonOK.OnEvent("Click", GuiClose)
        }
        else if InStr(A_LoopField, ".Add(`"Button`"") {
            buttonFound := 1
            new_outscript .= A_LoopField "`n"
            variableName := Trim(StrSplit(A_LoopField, ":=")[1])
            ;ogcButtonOK.OnEvent("Click", GuiClose)
            val := variableName ".OnEvent(`"Click`", ButtonHandler)`n"
            new_outscript .= val
        }
        else if InStr(A_LoopField, "GuiEscape(*)") {
            ;if END OF SCRIPT found, attempt to append functions
            if (menuHandle == 1) && (MenuHandleCount < 2) {
                new_outscript .= "`nMenuHandler(*)`n" tooltip_()
                GuiEsc := 1
            }
            if (buttonFound == 1) && (editFound == 0) {
                new_outscript .= "`nButtonHandler(*)`n" tooltip_()
            }
            else if (editFound == 1) {
                if (buttonFound == 0) && (editFound == 1) {
                    func := "`nEditHandler(*)`n"
                    string := ""
                    ; for i in Edit_Storage {
                    ;     string .= Format(" `"``n // {1}.Value ==> `" {1}.Value", i)
                    ;     ;string .= " `"``n //%i% " A_Index "// `" " i ".Value"
                    ; }
                }
                else if (buttonFound == 1) && (editFound == 1) {
                    func .= "`nButtonHandler(*)`n"
                }
                string := ""
                for i in Edit_Storage {
                    string .= Format(" `"``n // {1}.Value ==> `" {1}.Value", i)
                }
                new_outscript .= func . tooltip_(string)

            }

            new_outscript .= A_LoopField "`n"
            ;if ()    GuiEsc := 1
        }
        else if (menuHandle == 1) && (MenuHandleCount >= 1) && InStr(A_LoopField, "MenuHandler(") {
            RemoveFunction := 1
            continue
        }
        else if InStr(A_LoopField, "myGui.OnEvent(`"Close`", GuiEscape)") || InStr(A_LoopField, "myGui.OnEvent(`"Escape`", GuiEscape)") || InStr(A_LoopField, "Bind(`"Normal`")") || (A_LoopField == "") {
            continue
        }
        ; else if InStr(LTrim(A_LoopField), "MenuBar.Add(") && a == 1 {
        ;     if StrSplit(LTrim(A_LoopField), "(")[1] == "MenuBar.Add" {
        ;         new_outscript .= StrReplace(A_LoopField, "MenuBar.Add(", "MenBar.Add(")
        ;         new_outscript .= "`n"
        ;     }
        ; ; }
        else if (Trim(A_LoopField) == "Menu := Menu()") {
            new_outscript .= StrReplace(A_LoopField, "Menu := Menu()", "Menu_Storage := Menu()")
            new_outscript .= "`n"
            FindMenu := 1
        }
        else if (FindMenu == 1) && (InStr(Trim(A_LoopField), "Menu.Add(")) {
            if (StrSplit(Trim(A_LoopField), "(")[1] == "Menu.Add") {
                new_outscript .= StrReplace(A_LoopField, "Menu.Add(", "Menu_Storage.Add(")
                new_outscript .= "`n"
            }
        }
        else if (Trim(A_LoopField) == "MenuBar := Menu()") {
            new_outscript .= StrReplace(A_LoopField, "MenuBar := Menu()", "MenuBar_Storage := MenuBar()")
            new_outscript .= "`n"
            FindMenuBar := 1
        }
        else if (FindMenuBar == 1) && InStr(Trim(A_LoopField), "MenuBar.Add(") {
            if (StrSplit(Trim(A_LoopField), "(")[1] == "MenuBar.Add") {
                new_outscript .= StrReplace(A_LoopField, "MenuBar.Add(", "MenuBar_Storage.Add(")
                new_outscript .= "`n"
            }
        }
        else if InStr(A_LoopField, ".MenuToolbar := MenuBar") {
            new_outscript .= StrReplace(A_LoopField, "MenuToolbar := MenuBar", "MenuBar := MenuBar_Storage")
            new_outscript .= "`n"
        }
        else if InStr(A_LoopField, ".Show(`"") && (buttonFound == 0) && (editFound == 1) {
            for i in Edit_Storage {
                new_outscript .= i ".OnEvent(`"Change`", EditHandler)`n"
            }
            new_outscript .= A_LoopField . "`n"

        }
        else {
            new_outscript .= A_LoopField . "`n"
        }
    }
    return new_outscript
}

tooltip_(string := "") {
    if (string != "") {
        string := "The edit values include:`" " . string
    }
    return "{`n`tToolTip `"Click! This is a sample action. ``n" string ", 20, 20`n`tSetTimer () => ToolTip(), -3000 `; timer expires in 2 seconds and tooltip disappears`n}`n"
}

Re: v1 -> v2 Script Converter

Posted: 04 May 2023, 12:32
by guest3456
sashaatx wrote:
04 May 2023, 05:00
Hi Guest,
I reached out a week ago, I'd love to connect. I'm making a bunch of additions as I work with my EasyAutoGUI modded for v2 script.
I would just need your help with how to navigate the regex vs my instr mods. A brief chat would help me navigate the github.
replied on github

Re: v1 -> v2 Script Converter

Posted: 05 Aug 2023, 13:44
by kunkel321
Hi there Guest3456. Thanks for making this excellent tool and sharing it. I had assumed that mmikeww was the same person as the forum user mikeyww, but I guess not. Anyway, should possible bugs by discussed here on this forum thread, or should we just post here: https://github.com/mmikeww/AHK-v2-script-converter/issues ?

Re: v1 -> v2 Script Converter

Posted: 05 Aug 2023, 15:46
by guest3456
kunkel321 wrote:
05 Aug 2023, 13:44
Hi there Guest3456. Thanks for making this excellent tool and sharing it. I had assumed that mmikeww was the same person as the forum user mikeyww, but I guess not. Anyway, should possible bugs by discussed here on this forum thread, or should we just post here: https://github.com/mmikeww/AHK-v2-script-converter/issues ?
yea sorry the confusion of usernames. probably best to post bugs on github i think. i dont work on it too much anymore and sometimes other contributors see the issues on there

Re: v1 -> v2 Script Converter

Posted: 05 Aug 2023, 18:21
by kunkel321
guest3456 wrote:
05 Aug 2023, 15:46
yea sorry the confusion of usernames. probably best to post bugs on github i think. i dont work on it too much anymore and sometimes other contributors see the issues on there
Makes sense. Thanks.

Re: v1 -> v2 Script Converter

Posted: 24 Aug 2023, 23:41
by akirofe
Hi, PLEASE help me :((( I don't have either V2 nor am able to install EXE at work :(((

Please help me converting the attached (V1) to (V2) please :(((

Thank you VERY MUCH!!

Re: v1 -> v2 Script Converter

Posted: 03 Feb 2024, 11:26
by geek
Would there be interest in a hosted version of this conversion tool? I should be able to pull all the code into the wiki sandbox (https://autohotkey.wiki/cloudahk) and write some front-end code to provide a diffing interface like shown in the original post. This should allow people to use the tool without needing to download anything, they'd just have to visit in the browser.

Re: v1 -> v2 Script Converter

Posted: 03 Feb 2024, 11:50
by andymbody
geek wrote:
03 Feb 2024, 11:26
This should allow people to use the tool without needing to download anything, they'd just have to visit in the browser.
Sounds good to me. I think it would also get more exposure and updates would be seamless to the users, right?

Re: v1 -> v2 Script Converter

Posted: 03 Feb 2024, 12:30
by guest3456
geek wrote:
03 Feb 2024, 11:26
Would there be interest in a hosted version of this conversion tool? I should be able to pull all the code into the wiki sandbox (https://autohotkey.wiki/cloudahk) and write some front-end code to provide a diffing interface like shown in the original post. This should allow people to use the tool without needing to download anything, they'd just have to visit in the browser.
i have no problem with you doing this