mikeyww wrote: ↑24 Jan 2022, 12:23
That's exactly what
this script does.
Your script is a different script, which you have not posted.
That's very true... having had a second look at the script and doing a clean troubleshoot (analyzing with
ListLines), it turns out the problem wasn't the if statement at all but a practice I've long adopted was failing me.
Code: Select all
pagelight:= True
Up::
if pagelight
Click WU
else
Up::Up
return
Code: Select all
pagelight:= True
Up::
if pagelight
Click WU
else
{
Up::Up
}
return
The two script above were all run alone (the first, being by initial) and the second works alright. It just scrolls and doesn't move the cursor.
First of, normally if I want to make the function of a hotkey an option in an if statement as in the above two scripts, I use
Up::Up instead of
Send {Up}. Secondly, I know single line commands for
If statements doesn't need curly braces.
If I just changed the
Up::Up to
Send {Up} in the first script it works fine. If I wanted to maintain
Up::Up and just used curly braces around it (as in the case of the second script above), it then also works fine.
The lesson to be length is not quiet clear. Should it be a practice to always use curly braces in an if statement (whether there are single or multiline commands)? Or having been using
Up::Up in most instances in my script (like in the scripts above) which tends to work perfectly than
Send {Up}, it is actually not a good practice?