On trying to make a small counter in AutoHotkey AHK to count some stuff, when I press Page down and Up for + and minus, all work well with a small problem the GUI that it opens is so small and I can't move it unless I use the arrows from keyboard and windows does not remember its last position when reopening it.

This is what I have until now. I tried a lot of stuff over the course of the weekend but I don't seem to figure it out how to make the window that opens to show the window title or set a title for it to be able to move it as I please

Gui, Add, Text, vCount w100, PgDn pressed 0 times.
Gui, Show,

Count := 0

$PgDn::   ;Default behavior is to block keystroke, ~ allows it to pass through
  Count := Count + 1
  GuiControl,,Count, PgDn pressed %Count% times.
  KeyWait, PgDn  ;Wait for PgDn to be released
return

$PgUp::   ;Default behavior is to block keystroke, ~ allows it to pass through
  Count := Count - 1
  GuiControl,,Count, PgUp pressed %Count% times.
  KeyWait, PgUp  ;Wait for PgUp to be released
return

GuiClose:
  ExitApp
return

Any help would be appreciated.

Finally got it right!

x := (A_ScreenWidth/2)-(Width/2)
y := (A_ScreenHeight/2)-(Height/2)
Gui, Show, %x% %y% w200 h50
Gui, Add, Text, vCount w150, PgDn pressed 0 times.
Count := 0

$PgDn::   ;Default behavior is to block keystroke, ~ allows it to pass through
  Count := Count + 1
  GuiControl,,Count, PgDn pressed %Count% times.
  KeyWait, PgDn  ;Wait for PgDn to be released
return

$PgUp::   ;Default behavior is to block keystroke, ~ allows it to pass through
  Count := Count - 1
  GuiControl,,Count, PgUp pressed %Count% times.
  KeyWait, PgUp  ;Wait for PgUp to be released
return

GuiClose:
  ExitApp
return

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.