Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

control+ and control- (change font size) in an AHK gui.


  • Please log in to reply
7 replies to this topic
jleslie48
  • Members
  • 145 posts
  • Last active: Sep 28 2017 07:13 PM
  • Joined: 29 Jun 2010

I can't figure it out, and I can't find a solution online/forum, so I ask those more experienced here. I have the gui it uses gui, add,text, and gui,add,button, and gui,add, edit and such, but on some screens the font is too small.   Like the current browser, I'd like to implement the control+ and control- controls were when the user hits ^+, the font size increases by 1, and ^- decreases it by one.   Any help outthere?

 

TIA,

 

Jleslie48

 

 



tyrer
  • Members
  • 270 posts
  • Last active: Apr 10 2015 05:10 PM
  • Joined: 23 Sep 2012

I'm a beginner too, but this may help:

 

Gui, add, text, vscore w200 h200,Hello
Gui, show
size=12
return


F1::
size +=2
Gui, Font, s%size%
GuiControl, Font, score

return


F2::
size -=2
Gui, Font, s%size%
GuiControl, Font, score
return


jleslie48
  • Members
  • 145 posts
  • Last active: Sep 28 2017 07:13 PM
  • Joined: 29 Jun 2010

yes that works nicely thank you.  My only issue with it is that my Gui has many, many TEXT and EDIT, and, BUTTON's, and I was hoping for a solution that won't force me to call out every variable with a GUICONTROL, FONT



uname
  • Members
  • 194 posts
  • Last active: Oct 17 2015 08:46 AM
  • Joined: 13 Jun 2012
fontSize := 12
ChangeFont := RegisterCallback("ChangeFont")

Gui +hwndhwnd
Gui Add, text, w400 h200, Hello World
Gui Add, text, w400 h200, Hello World
Gui Show, w400 h400
return

^-::
    fontSize -= 2
^=::
    fontSize += 1
    Gui Font, s%fontSize%
    DllCall("EnumChildWindows", "Ptr", hwnd, "Ptr", ChangeFont)
    return

ChangeFont(hwnd, l) {
    GuiControl Font, %hwnd%
    return true
}


tyrer
  • Members
  • 270 posts
  • Last active: Apr 10 2015 05:10 PM
  • Joined: 23 Sep 2012

uname posted something better whilst I was posting!

 

size=12
gosub,themenu
return

F1::
size +=2
Gui,destroy
gosub,themenu
return


F2::
size -=2
Gui,destroy
gosub, themenu
return

themenu:
gui, font, s%size%
Gui, add, text, w200 ,Hello
Gui, add, text, w200 ,Bye

Gui,show
return


jleslie48
  • Members
  • 145 posts
  • Last active: Sep 28 2017 07:13 PM
  • Joined: 29 Jun 2010

I couldn't get unames solution to work. this is what I have: 

 


 


;
; AutoHotkey Version: 1.x
; Language:       English
; Platform:       Win9x/NT
; Author:         uname
;
; Script Function:
; Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder)
;
 
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
 
fontSize := 12
ChangeFont := RegisterCallback("ChangeFont")
 
Gui +hwndhwnd
Gui Add, text, w400 h200, Hello World
Gui Add, text, w400 h200, Hello World
Gui Show, w400 h400
return
 
F1::
^-::
    fontSize -= 2
F2::
^+::
    
    fontSize += 1
    ; msgbox, changing font size to %fontsize%
    Gui, Font, s%fontSize%
    DllCall("EnumChildWindows", "Ptr", hwnd, "Ptr", ChangeFont)
    return
 
ChangeFont(hwnd, l) {
    GuiControl, Font, %hwnd%
    return true
}
 
 
GuiClose:
exitapp


jleslie48
  • Members
  • 145 posts
  • Last active: Sep 28 2017 07:13 PM
  • Joined: 29 Jun 2010

tyrer's code works!   

 

;
; AutoHotkey Version: 1.x
; Language:       English
; Platform:       Win9x/NT
; Author:         tyrer
;
; Script Function:
;	Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder)
;

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

size=12
gosub,themenu
return

F1::
size +=2
Gui,destroy
gosub,themenu
return


F2::
size -=2
Gui,destroy
gosub, themenu
return

themenu:
gui, font, s%size%
Gui, add, text, w200 ,Hello
Gui, add, text, w200 ,Bye

Gui,show
return

GuiClose:
	exitapp


jonathan scott james
  • Members
  • 24 posts
  • Last active: May 04 2018 03:25 PM
  • Joined: 23 Feb 2015

oooooh

GuiControl, Font, "control variable name"

i always thought 

gui,show 

updated the screen.

thanks tyrer