AHK-v2-script-converter icon indicating copy to clipboard operation
AHK-v2-script-converter copied to clipboard

InputBox code not converted

Open user1823 opened this issue 1 year ago • 3 comments

Input:

InputBox, Hotstring, New Hotstring, Provide the corrected word on the right side. You can also edit the left side if you wish.`n`nExample entry:`n::teh::the,,,,,,,, ::%Hotstring%::%Hotstring%

The converter didn't convert this code.

Manually converted code:

Hotstring := InputBox("Provide the corrected word on the right side. You can also edit the left side if you wish.`n`nExample entry:`n::teh::the", "New Hotstring", "", "::%Hotstring%::%Hotstring%")

user1823 avatar Jan 24 '24 14:01 user1823

InputBox() returns an obj so your conversion is wrong

if/when we add conversion support, we should probably do it like this:

v1

InputBox, OutputVar , Title, Prompt

v2

OutputVar := InputBox(Prompt, Title).VALUE

but there is also the hassle of converting all the options

mmikeww avatar Jan 24 '24 17:01 mmikeww

From V1 docs:

ErrorLevel is set to 1 if the user presses the CANCEL button, 0 if the user presses OK, or 2 if the dialog times out.

From v2 docs:

This function returns an object with the following properties:

  • Value (String): The text entered by the user.
  • Result (String): One of the following words indicating how the input box was closed: OK, Cancel, or Timeout.

So, if Errorlevel is present after the InputBox as in https://github.com/mmikeww/AHK-v2-script-converter/issues/134#issuecomment-1908633632, it needs to converted as well.

user1823 avatar Jan 24 '24 19:01 user1823

yep thats annoying

maybe a multi line conversion, something like this

v1

InputBox, OutputVar, Title, Prompt

v2

InputBoxObj := InputBox(Prompt, Title)
OutputVar := InputBoxObj.Value
ErrorLevel := (InputBOxObj.Result = "OK") ? 0 : (InputBoxObj.Result = "Cancel") ? 1 : 2

something like that.. would need testing

mmikeww avatar Jan 24 '24 20:01 mmikeww

Minimal example InputBox, Test, ::Test::Test I think the hotkey regexs are firing even when it shouldn't

Banaanae avatar Jun 18 '24 22:06 Banaanae

This RegEx probably could be used, needs more testing

From: ^\s*(.*[^\s]::).*$ To:___ ^\s*([^,\s]*|[$~!^#+]*,)::.*$

Banaanae avatar Jun 18 '24 22:06 Banaanae