mmikeww / AHK-v2-script-converter

AHK v1 -> v2 script converter
https://autohotkey.com/boards/viewtopic.php?f=6&t=25100
The Unlicense
526 stars 40 forks source link

Hotstring, hard to tell if it is label, function or hotstring #47

Open dmtr99 opened 3 years ago

dmtr99 commented 3 years ago

A possible problem when converting the Hotkey command, it does not understands that the second command is pointing to a Key. WheelUp should need to become quoted "WheelUp". I could check if the second parameter is a valid hotkey, but the string DoubleUp is also a valid hotstring...

I am tending to accept this error for now, the rest seems to be working ok. This will notice the user with an error.

input:

NumpadAdd::
Hotkey, If, MouseIsOver("ahk_class Shell_TrayWnd")
if (doubleup := !doubleup)
    Hotkey, WheelUp, DoubleUp
else
    Hotkey, WheelUp, WheelUp
return

DoubleUp:
Send {Volume_Up 2}
return

Result:

NumpadAdd::
{ ; V1toV2: Added bracket
Hotkey("If", MouseIsOver("ahk_class Shell_TrayWnd"))
if (doubleup := !doubleup)
    Hotkey("WheelUp", DoubleUp)
else
    Hotkey("WheelUp", WheelUp)
return
} ; Added bracket before function

DoubleUp(ThisHotkey)
{ ; V1toV2: Added bracket
Send("{Volume_Up 2}")
return
} ; V1toV2: Added bracket in the end
mmikeww commented 3 years ago

i dont believe this line Hotkey, WheelUp, WheelUp is valid v1 code anyway. there is no WheelUp label

dmtr99 commented 2 years ago

in the documentation it is converted as Hotkey("WheelUp", "WheelUp"), so probably interpreted as a sendInput... I think I will add a folder of examples that currently are not correct translated, but skipped at the moment

mmikeww commented 2 years ago

Where in the docs? I'm not seeing it on the Hotkey command page

dmtr99 commented 2 years ago

https://www.autohotkey.com/docs/commands/_If.htm

mmikeww commented 2 years ago

lets see: https://www.autohotkey.com/boards/viewtopic.php?f=86&t=94678