Jump to content

Change "notepad.exe" edit color


Recommended Posts

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
Link to comment
Share on other sites

  • Moderators

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()

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • Moderators

 

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.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Moderators

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.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
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.

Link to comment
Share on other sites

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
Link to comment
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

Link to comment
Share on other sites

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
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...