Sign in to follow this  
Followers 0
TheAutomator

Change "notepad.exe" edit color

13 posts in this topic

#1 ·  Posted (edited)

I don't know if I should post this question here or in the "GUI" section so please don't kill me if i'm wrong  ^_^

Its a simple question I think, but I cant find a solution..

There are some examples where you can change a control with AutoIt in 'Notepad.exe' using the ControlCommand() function.

Is it also possible to change the color of the edit box in Notepad with AutoIt?

Saw an example for changing the control text or the color of the menu but I can't find a way for doing this with the edit control of Notepad.exe.

I'm searching something like this:

 
Example()

Func Example()


    ; Run Notepad
    Run("notepad.exe")


    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)


    ; Set the backgroundcolor of the Notepad edit control.
    ???($hWnd, "", 0x00FF00)


EndFunc   ;==>Example

Is this possible?

Thanks,

TheAutomator Edited by TheAutomator

Share this post


Link to post
Share on other sites



Must it be Notepad? Why not just create your own input context?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Local $msg
GUICreate("Test", 300, 300)
GUISetState(@SW_SHOW)
$sText = GUICtrlCreateInput("", 10, 10, 280, 280)
GUICtrlSetBkColor($sText, 0x00FF00)
    While 1
        $msg = GUIGetMsg()
   Select
    Case $msg = $GUI_EVENT_CLOSE
     ExitLoop
   EndSelect
    WEnd
GUIDelete()

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

JLogan3o13,

Must it be Notepad? Why not just create your own input context?

 

Yes, I'd like to know if this is possible with Notepad  :)

I could create my own version of Notepad but I want to know if it is possible to change the color of any control for a windows program

using the ControlCommand() function or something like that..

Thanks,

TheAutomator

Edited by TheAutomator

Share this post


Link to post
Share on other sites

 

This is still creating a custom GUI and not changing the native Notepad app. If, as the OP stated, he doesn't want a custom GUI, then he will need to update to a better application as JohnOne suggested.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

@JLogan3o13

OP stated

 

OP stated:

I could create my own version of Notepad but I want to know if it is possible to change the color of any control for a windows program

 

About Notepad++, he did not speak.

Share this post


Link to post
Share on other sites

Correct, he is saying he could create his own version of notepad, but does not want to. He reiterated this when I suggested a GUI with a custom input field.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Thought this might have been in with a shout...

#include <WinAPI.au3>

Run("notepad.exe")

WinWaitActive("Untitled - Notepad")

$whwnd = WinGetHandle("Untitled - Notepad")
If @error Then
    Exit MsgBox(0,"error","WinGetHandle")
EndIf

_WinAPI_FlashWindow($whwnd)

$chwnd = ControlGetHandle($whwnd, "", "[CLASS:Edit; INSTANCE:1]")
If @error Then
    Exit MsgBox(0,"error","ControlGetHandle")
EndIf

$cDC = _WinAPI_GetDC($chwnd)
If @error Then
    Exit MsgBox(0,"error","_WinAPI_GetDC")
EndIf

_WinAPI_SetBkColor($cDC, 0x0000ff00)
If @error Then
    Exit MsgBox(0,"error","_WinAPI_SetBkColor")
EndIf

;_WinAPI_RedrawWindow($whwnd)

Does not work though.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

AZJIO,
 
I have downloaded the "My_Notepad.7z". Nice program but not the answer on my question.  ;)
 
JLogan3o13,
 
Thank you for correcting some answers I got  :)
 
JohnOne,
 
The script you posted indeed does not work but thanks for trying, its probably not possible I guess. :)
 
Edited by TheAutomator

Share this post


Link to post
Share on other sites

The only way you can change the background color of notepad is to change the background color of all windows. There's no way to set it to a color without changing all other standard background colors.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

BrewManNH,

The only way you can change the background color of notepad is to change the background color of all windows. There's no way to set it to a color without changing all other standard background colors.

 

Ok, the reason I questioned this is because in AutoIt scripts you can set the colors of the controls individually,

I also saw an example for changing the color of the menu somewere (can't find it anymore, still searching...).

Thanks,

TheAutomator.

Edited by TheAutomator

Share this post


Link to post
Share on other sites
I also saw an example for changing the color of the menu somewere (can't find it anymore, still searching...).

 

example in the help file

_GUICtrlMenu_SetMenuBackground

Share this post


Link to post
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
Sign in to follow this  
Followers 0