v1 -> v2 Script Converter
v1 -> v2 Script Converter
AHK v2 Script Converter
This is a work in progress. But it should be good enough to save you a lot of time with some of the more tedious conversions.
This script will attempt to convert a script written in AHK v1 to the correct syntax so that it works in AHK v2.
It is useful to quickly convert some of the bigger syntax changes. Afterwards you can investigate the converted version for other minor changes that the converter didn't cover.
I took Frankie's original converter, and updated it to work with the latest AHK v2 beta build.
I've also added essential unit tests using the Yunit framework to encourage contributions from others.
Latest Download:
https://github.com/mmikeww/AHK-v2-script-converter/archive/master.zip
Usage instructions on the project page:
https://github.com/mmikeww/AHK-v2-script-converter
------------
This is a work in progress. But it should be good enough to save you a lot of time with some of the more tedious conversions.
This script will attempt to convert a script written in AHK v1 to the correct syntax so that it works in AHK v2.
It is useful to quickly convert some of the bigger syntax changes. Afterwards you can investigate the converted version for other minor changes that the converter didn't cover.
I took Frankie's original converter, and updated it to work with the latest AHK v2 beta build.
I've also added essential unit tests using the Yunit framework to encourage contributions from others.
Latest Download:
https://github.com/mmikeww/AHK-v2-script-converter/archive/master.zip
Usage instructions on the project page:
https://github.com/mmikeww/AHK-v2-script-converter
------------
Last edited by guest3456 on 04 Apr 2024, 11:24, edited 11 times in total.
Re: v1 -> v2 Script Converter
Really very necessary project
There is already lots of useful code for AutoHotkey v1 and without this project, it will be hard to easy migrate from v1 to v2. This project will greatly help the process.
There is already lots of useful code for AutoHotkey v1 and without this project, it will be hard to easy migrate from v1 to v2. This project will greatly help the process.
DRAKON-AutoHotkey: Visual programming for AutoHotkey.
Re: v1 -> v2 Script Converter
why should i use AHK2?
Re: v1 -> v2 Script Converter
Excellent! I just tried this on a ~1200 lines script, and it did a lot of changes I wouldn't want to do manually. So it is already useful. But I see there is a lot of work to be done still.
The visual diff is a really nice feature!
The visual diff is a really nice feature!
Re: v1 -> v2 Script Converter
well, here's a coupleSnowFlake wrote:why should i use AHK2?
1. you can call all commands as functions. thats good enough for me
Code: Select all
;v1
WinGetTitle, Title, A
MsgBox, The active window is %Title%.
MsgBox, % "1+1=" 1+1
;v2
Title := WinGetTitle("A")
MsgBox("The active window is %Title%.")
MsgBox("1+1=%1+1%")
Last edited by guest3456 on 08 Jan 2018, 20:24, edited 4 times in total.
Re: v1 -> v2 Script Converter
update:
lexikos recommends var=value should always assign a string, even if value is numeric
Code: Select all
var2 = 2 ;v1
var2 := "2" ;v2 converted
Re: v1 -> v2 Script Converter
please post the results of any failed or incorrect conversions, either here in this thread or on github:Helgef wrote:Excellent! I just tried this on a ~1200 lines script, and it did a lot of changes I wouldn't want to do manually. So it is already useful. But I see there is a lot of work to be done still.
The visual diff is a really nice feature!
https://github.com/mmikeww/AHK-v2-scrip ... ter/issues
Last edited by guest3456 on 01 Dec 2016, 09:20, edited 2 times in total.
Re: v1 -> v2 Script Converter
I didn't experience any incorrect convertions, just missed one, from my short-term memory, things that I had to fix manually after the conversion:guest3456 wrote: please post the results of any failed or incorrect conversions, either here in this thread or on github:
- SetBatchLines, removed
- StringReplace, ... changed to StrReplace,...
- IfMsgBox Yes/... See comment
Comment on IfMsgBox
I just removed them for now, I'm not sure if it has been decided what will happen to that. There was a thread about it recently, I'm sure you saw it.
Re: v1 -> v2 Script Converter
yep, there are many more that still need to be doneHelgef wrote: I didn't experience any incorrect convertions, just missed one, from my short-term memory, things that I had to fix manually after the conversion:There were more but I don't remember at this point, sorry.
- SetBatchLines, removed
- StringReplace, ... changed to StrReplace,...
- IfMsgBox Yes/... See comment
i didn't see the thread you're talking about. but this was changed to A_MsgBoxResult as mentioned in v2-changesHelgef wrote: Comment on IfMsgBox
I just removed them for now, I'm not sure if it has been decided what will happen to that. There was a thread about it recently, I'm sure you saw it.
Re: v1 -> v2 Script Converter
I was referring to this threadguest3456 wrote:i didn't see the thread you're talking about
Re: v1 -> v2 Script Converter
ah yes i did see that. so its best for the converter not to make a decision yetHelgef wrote:I was referring to this threadguest3456 wrote:i didn't see the thread you're talking about
Re: v1 -> v2 Script Converter
updates
- fix, return %var% now does double deref in v2
- use A_StringCaseSense for InStr replacements instead of outputting warning comment
- if var is 'type'
- StrReplace
- fix, return %var% now does double deref in v2
- use A_StringCaseSense for InStr replacements instead of outputting warning comment
- if var is 'type'
- StrReplace
Re: v1 -> v2 Script Converter
updates to handle parameters that "can be an expression"
Code: Select all
; all of these
StringLeft, OutputVar, String, %count%
StringLeft, OutputVar, String, % count
StringLeft, OutputVar, String, count
; should convert to this
OutputVar := SubStr(String, 1, count)
Code: Select all
; these
Sleep, %count%
Sleep, count
Sleep, count*2
; should convert to these
Sleep, %count%
Sleep, %count%
Sleep, %count*2%
Re: v1 -> v2 Script Converter
updates:
- convert all IfXXX commands
- convert File*Dir commands
- convert if between
- convert renamed vars and funcs
- detect empty params
- convert all IfXXX commands
- convert File*Dir commands
- convert if between
- convert renamed vars and funcs
- detect empty params
Re: v1 -> v2 Script Converter
Wow, I forgot about this.... Cool!
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
-
- Posts: 316
- Joined: 23 Jan 2015, 01:49
Re: v1 -> v2 Script Converter
just replied to get subscribed to the post
Re: v1 -> v2 Script Converter
Does anyone know editor support v2 syntax? Thank you!
-
- Posts: 316
- Joined: 23 Jan 2015, 01:49
Re: v1 -> v2 Script Converter
I am greatly an AHK dependent, and I am from a non-programming background, more than writing code I do analyze codes written by others and learn from them doing small changes.
Till date, all of our codes are written in v1, if I need to test, learn, and analyze these scripts >>> I cant change codes manually all the time if something can be automated, we should, it would be a great help, please think of all the guys like me and future learners like me for whom AHK is or might be a breadwinner.
Till date, all of our codes are written in v1, if I need to test, learn, and analyze these scripts >>> I cant change codes manually all the time if something can be automated, we should, it would be a great help, please think of all the guys like me and future learners like me for whom AHK is or might be a breadwinner.
Re: v1 -> v2 Script Converter
Is somebody planning of updating this convertor to the new AHK V2 Beta?
I tried it out on a script, it did some conversion wel, but failed in a lot of lines. (msgbox, iniRead, loop read, iniwrite,inputbox,...)
This is of course normal because the AHK V2 Beta is just released and this convetor is 4 years old.
I tried it out on a script, it did some conversion wel, but failed in a lot of lines. (msgbox, iniRead, loop read, iniwrite,inputbox,...)
This is of course normal because the AHK V2 Beta is just released and this convetor is 4 years old.