Jump to content
Sign in to follow this  
Zisly

If word = do then set color

Recommended Posts

Zisly

I want to set a color to a word if it's writen, ex: Do and the color of that word would be blue, how can I do that without changing everything?

ex:

if guictrlread($script) = "do" then
                            ; 
GUICtrlSetColor("VARGORESHERE", 0xFF0000); I know that the color is wrong, but it's just an example
endif

So anyone has any tips on what i should use?

Edited by Zisly

Share this post


Link to post
Share on other sites
oMBRa

I dont get what is the problem. GUICtrlSetColor change the text of the control u want, not all controls.

Share this post


Link to post
Share on other sites
Zisly

But this doesn't work, is there any other way to search and replace? (new to autoit)

If GUICtrlRead($script) = "do" Then

$getdo = _WordDocFindReplace($script, "do")

GUICtrlSetColor($getdo, 0xFF0000)

EndIf

Share this post


Link to post
Share on other sites
oMBRa

post all code btw I made an example script:

#include <GUIConstantsEx.au3>

GUICreate("Color")
$Edit = GUICtrlCreateEdit("type something", 100, 100)
GUISetState()

While 1
    Local $msg
    $msg = GUIGetMsg()
    $Word = GUICtrlRead($Edit)

    If $Word = "do" Then
        GUICtrlSetColor($Edit, 0x0000FF)
    EndIf
    If $Word <> "do" Then
        GUICtrlSetColor($Edit, 0xFF0000)
    EndIf
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    Sleep(200)
WEnd

Share this post


Link to post
Share on other sites
Zisly

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIComboBox.au3>
#include <Constants.au3>
#include <Clipboard.au3>
#include <misc.au3>
#include <GuiComboBoxEx.au3>
#include <file.au3>
#include <Word.au3> 
#include <GuiEdit.au3>

Opt("GUIOnEventMode", 1)

$Form1 = GUICreate("Scripter 1.0", 858, 366, 117, 117)
GUISetBkColor(0x0A246A)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
$script = GUICtrlCreateEdit("", 312, 8, 441, 345)

while 1 
    sleep(50)
    WEnd

I'm making a notepad..

Share this post


Link to post
Share on other sites
GEOSoft

If you are trying to do text highlighting then you will need a rich text edit control. There are examples of both the control and text highlighting in the Examples forum.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites
oMBRa

that's all your script??... btw did u try my script? tell me if it is what u are looking for

Share this post


Link to post
Share on other sites
Zisly

that's all your script??... btw did u try my script? tell me if it is what u are looking for

I only posted the related code..

Wasn't what I was looking for, but thanks anyways ;)

@GEOSoft; thanks! :D

Edited by Zisly

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.