Code:
;Oct 2010
;F9 is the launcher
ControlName=ThunderRT6TextBox1,ThunderRT6TextBox2,ThunderRT6TextBox3,ThunderRT6TextBox4
font := "Ariel"
style := "s16 bold italic"
color:=0xFF
SetBatchLines, -1
Gui, +AlwaysOnTop +ToolWindow
Gui, Add, Edit, % "x0 y0 w" A_ScreenWidth " h" A_ScreenHeight-100 " vData"
Gui, Add, Button, % "x0 y" A_ScreenHeight-90 " w" A_ScreenWidth/2 " h18 gSav",Save
Gui, Add, Button, % "x+0 y" A_ScreenHeight-90 " w" A_ScreenWidth/2 " h18 gCan",Cancel
return
;can I simply add this next line? Or will interfer with the ThunderRT6FormDC line that has worked for the other text boxes?
;#IfWinActive, ahk_class Internetexplorer_server3
#IfWinActive, ahk_class ThunderRT6FormDC
F9::
ControlGetFocus, Control, A
If Control in %ControlName%
{
WinGet, WID, ID, A
ControlGetText, Data, %Control%, ahk_id %WID%
GuiControl, , Data, %Data%
Gui, Show, % "x0 y0 w" A_ScreenWidth " h" A_ScreenHeight-70, Edit- F2 To Auto Increase Font Size --- F3 To Bring Up Standard Font Edit Window
}
Return
#IfWinActive
Sav:
GuiControlGet, Data, , Data
StringReplace, Data, Data, `n, `r`n, All
ControlSetText, %Control%, %Data%, ahk_id %WID%
GuiControl, , Data
Gui, Cancel
Return
Can:
GuiClose:
GuiControl, , Data
Gui, Cancel
Return
f3::
gui -alwaysontop
Dlg_Font( font := "Ariel", style := "s16 bold", color:=0xFF)
gui +alwaysontop
return
#ifwinactive Edit
f2::
Gui, Font, %style% c%color% Bold, %font%
GuiControl, Font, edit1
return
#IfWinActive
; the following code thanks to Majkinetor common dialog functions http://www.autohotkey.com/forum/topic17230.html
Dlg_Font(ByRef Name, ByRef Style, ByRef Color, Effects=true, hGui=0) {
LogPixels := DllCall("GetDeviceCaps", "uint", DllCall("GetDC", "uint", hGui), "uint", 90) ;LOGPIXELSY
VarSetCapacity(LOGFONT, 128, 0)
Effects := 0x041 + (Effects ? 0x100 : 0) ;CF_EFFECTS = 0x100, CF_SCREENFONTS=1, CF_INITTOLOGFONTSTRUCT = 0x40
;set initial name
DllCall("RtlMoveMemory", "uint", &LOGFONT+28, "Uint", &Name, "Uint", 32)
;convert from rgb
clr := ((Color & 0xFF) << 16) + (Color & 0xFF00) + ((Color >> 16) & 0xFF)
;set intial data
if InStr(Style, "bold")
NumPut(700, LOGFONT, 16)
if InStr(Style, "italic")
NumPut(255, LOGFONT, 20, 1)
if InStr(Style, "underline")
NumPut(1, LOGFONT, 21, 1)
if InStr(Style, "strikeout")
NumPut(1, LOGFONT, 22, 1)
if RegExMatch(Style, "s[1-9][0-9]*", s){
StringTrimLeft, s, s, 1
s := -DllCall("MulDiv", "int", s, "int", LogPixels, "int", 72)
NumPut(s, LOGFONT, 0, "Int") ; set size
}
else NumPut(16, LOGFONT, 0) ; set default size
VarSetCapacity(CHOOSEFONT, 60, 0)
,NumPut(60, CHOOSEFONT, 0) ; DWORD lStructSize
,NumPut(hGui, CHOOSEFONT, 4) ; HWND hwndOwner (makes dialog "modal").
,NumPut(&LOGFONT,CHOOSEFONT, 12) ; LPLOGFONT lpLogFont
,NumPut(Effects, CHOOSEFONT, 20)
,NumPut(clr, CHOOSEFONT, 24) ; rgbColors
r := DllCall("comdlg32\ChooseFontA", "uint", &CHOOSEFONT) ; Display the dialog.
if !r
return false
;font name
VarSetCapacity(Name, 32)
DllCall("RtlMoveMemory", "str", Name, "Uint", &LOGFONT + 28, "Uint", 32)
Style := "s" NumGet(CHOOSEFONT, 16) // 10
;color
old := A_FormatInteger
SetFormat, integer, hex ; Show RGB color extracted below in hex format.
Color := NumGet(CHOOSEFONT, 24)
SetFormat, integer, %old%
;styles
Style =
VarSetCapacity(s, 3)
DllCall("RtlMoveMemory", "str", s, "Uint", &LOGFONT + 20, "Uint", 3)
if NumGet(LOGFONT, 16) >= 700
Style .= "bold "
if NumGet(LOGFONT, 20, "UChar")
Style .= "italic "
if NumGet(LOGFONT, 21, "UChar")
Style .= "underline "
if NumGet(LOGFONT, 22, "UChar")
Style .= "strikeout "
s := NumGet(LOGFONT, 0, "Int")
Style .= "s" Abs(DllCall("MulDiv", "int", abs(s), "int", 72, "int", LogPixels))
;convert to rgb
oldFormat := A_FormatInteger
SetFormat, integer, hex ; Show RGB color extracted below in hex format.
Color := (Color & 0xff00) + ((Color & 0xff0000) >> 16) + ((Color & 0xff) << 16)
StringTrimLeft, Color, Color, 2
loop, % 6-strlen(Color)
Color=0%Color%
Color=0x%Color%
SetFormat, integer, %oldFormat%
return 1
}
;=========================================== PRIVATE ===============================================
Dlg_callback(wparam, lparam, msg, hwnd) {
static FR_DIALOGTERM = 0x40, FR_DOWN=1, FR_MATCHCASE=4, FR_WHOLEWORD=2, FR_HIDEMATCHCASE=0x8000, FR_HIDEWHOLEWORD=0x10000, FR_HIDEUPDOWN=0x4000, FR_REPLACE=0x10, FR_REPLACEALL=0x20, FR_FINDNEXT=8
static handler
ifEqual, hwnd, ,return handler := wparam
hFlags := NumGet(lparam+12)
if (hFlags & FR_DIALOGTERM)
return %handler%("C", "", "", "")
flags .= (hFlags & FR_MATCHCASE) && !(hFlags & FR_HIDEMATCHCASE)? "c" :
flags .= (hFlags & FR_WHOLEWORD) && !(hFlags & FR_HIDEWHOLEWORD)? "w" :
findText := DllCall("MulDiv", "Int", NumGet(lparam+16), "Int",1, "Int",1, "str")
if (hFlags & FR_FINDNEXT) {
flags .= (hFlags & FR_DOWN) && !(hFlags & FR_HIDEUPDOWN) ? "d" :
return %handler%("F", flags, findText, "")
}
if (hFlags & FR_REPLACE) || (hFlags & FR_REPLACEALL) {
event := (hFlags & FR_REPLACEALL) ? "A" : "R"
replaceText := DllCall("MulDiv", "Int", NumGet(lparam+20), "Int",1, "Int",1, "str")
return %handler%(event, flags, findText, replaceText)
}
}