Jump to content

Is it possible to increase and decrease font size for given edit


E1M1
 Share

Recommended Posts

$EM_SETCHARFORMAT? GuiCtrlSetFont?

GuiCtrlSetFont sets font for gui that is generated by running autoit script, but notepad is not generated by autoit, notepad is made by Bill Gates and his team :P

edited

Link to comment
Share on other sites

I made something up but it seems like it dosn't work

#Include <WinAPI.au3>
#include <FontConstants.au3>
$hFont = _WinAPI_CreateFont(14, 0, 0, 0, "FW_DONTCARE", False, False, False, $DEFAULT_CHARSET, _
        $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Arial')
_WinAPI_PostMessage("[CLASS:Edit; INSTANCE:1]", "WM_SETFONT", "WPARAM ("&$hFont&")", True)

edited

Link to comment
Share on other sites

I made something up but it seems like it dosn't work

#Include <WinAPI.au3>
#include <FontConstants.au3>
$hFont = _WinAPI_CreateFont(14, 0, 0, 0, "FW_DONTCARE", False, False, False, $DEFAULT_CHARSET, _
        $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Arial')
_WinAPI_PostMessage("[CLASS:Edit; INSTANCE:1]", "WM_SETFONT", "WPARAM ("&$hFont&")", True)
$FW_DONTCARE = 0

$WM_SETFONT = 0x0030

not

"FW_DONTCARE" and "WM_SETFONT" and after use $hFont use _WinAPI_DeleteObject($hFont)

When the words fail... music speaks.

Link to comment
Share on other sites

Ugly but work:

AutoItSetOption("WinTitleMatchMode",2)
Run("notepad.exe")
WinWait("Notepad")
ControlSend("Notepad","","Edit1","This is a test")
Sleep(3000)
WinMenuSelectItem("Notepad","","F&ormat","&Font...")
ControlSetText("Font","","Edit3","20")
ControlClick("Font","","Button5")

When the words fail... music speaks.

Link to comment
Share on other sites

It seems like I've done something wrong, it still wont work.

#Include <WinAPI.au3>
#include <FontConstants.au3>
$WM_SETFONT = 0x0
$hFont = _WinAPI_CreateFont(14, 0, 0, 0, $FW_DONTCARE = 0, False, False, False, $DEFAULT_CHARSET, _
        $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Arial')
_WinAPI_PostMessage("[CLASS:Edit; INSTANCE:1]", $WM_SETFONT = 0x0030, $hFont, True)
_WinAPI_DeleteObject($hFont)

edited

Link to comment
Share on other sites

Ugly but work:

AutoItSetOption("WinTitleMatchMode",2)
Run("notepad.exe")
WinWait("Notepad")
ControlSend("Notepad","","Edit1","This is a test")
Sleep(3000)
WinMenuSelectItem("Notepad","","F&ormat","&Font...")
ControlSetText("Font","","Edit3","20")
ControlClick("Font","","Button5")
it works but I need speed so I need to sent direct command(message) to edit control or modify memory address (last option is hard like hell)

edited

Link to comment
Share on other sites

#include <FontConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Run('Notepad.exe')
WinWaitActive('Untitled')

Dim $hEdit = ControlGetHandle('Untitled', '', 'Edit1')
Dim $hFont = _WinAPI_CreateFont(-13, 0, 0, 0, 400, 0, 0, 0, 0, _
        $OUT_STROKE_PRECIS, $CLIP_STROKE_PRECIS, $DRAFT_QUALITY, 18, 'Castellar')

Dim $hDC = _WinAPI_GetDC($hEdit)
Dim $hOldFont = _WinAPI_SelectObject($hDC, $hFont)
;_WinAPI_PostMessage($hEdit, $WM_SETFONT, $hFont, True)
ControlSend('Untitled', '', 'Edit1', 'String')
_WinAPI_SelectObject($hDC, $hOldFont)
_WinAPI_DeleteObject($hFont)

Isn't it pretty?

Link to comment
Share on other sites

I don't know why it's not working for you, I may guess you don't have this font. Or maybe your locale isn't english?

I have this font +english locale.

There should be way to communicate with notepad as font window does.

I am wondering how it can be so hard to modify simple edit control.

I dont know if this is possible and if it is good idea but what about write dll (c++) and inject it in notepad?

Edited by E1M1

edited

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...