//autohotkey.com/board/topic/68710-autohotkey-toggle-state-function/?p=434956
Code: Select all
n=0 ; this isn't really needed, the invert of empty is 1
return
f1::
n:=!n ; invert or reverse the prior value, 1 or 0 are the only choices
if n=1
tooltip, this is true
else
tooltip, this is false
return
So I used WinGetPos, X, Y, Width, Height, A to store the current window settings and then I want to first alter the X coordinate by -27 pixels and the width value by +27 pixels, then on the subsequent toggle state, reverse that (i.e. X coordinate +27 pixels and width -27 pixels).
This is where I got into trouble (because I can't use expressions), but I tried the following:
Code: Select all
n=0
return
f1::
WinGetPos, X, Y, Width, Height, A
n:=!n ; invert or reverse the prior value, 1 or 0 are the only choices
if n=1
WinMove, A ,, (%X% - 27), , (%Width% + 27),
else
WinMove, A ,, (%X% + 27), , (%Width% - 27),
return
Also, as far as I understand, this routine always starts in the same state, but will it go out of sync if I start using other windows from the same program? Presumably I you could use window ID instead of class or exe name and have the routine start with from its default state with each new window instance, but I don;t know how to do that.
The purpose of this is to have my text editor window content area remain constant in size when I toggle line numbering on and off (which takes up 27 pixels of space on the left hand side) therefore it's important the the resizing stays in sync and doesn't end up reducing the window with when the line numbering column is added (and vice versa). Unfortunately there's no way to detect the line number toggle status (no visible toolbar button, accessible menu, or even registry key to determine the line number toggle state) so the only thing I have going for me is the fact that line numbering always defaults to off when a new window is opened.So this should give a consistent starting point.
Would appreciate some help getting a working script.