Sign in to follow this  
Followers 0
tylerh27

FONT COLOR??

4 posts in this topic

I'm going to be getting text from a web server, and i'll receive something like: <font color="green">Username:</font> string for message

Anyway, i wanna i wanna string replace the font tags, and make the actual text "Username" green when its displayed, but idk how to change colors.

It will also be in an edit box "GuiCtrlCreateEdit"

Can someone tell me how to make certain text green?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

you could either create an array with the hex color and assign the word to a number

say:

Dim $color_array[3]

$color_array[0] = 0x00FF00

$color_array[1] = 0x0000FF

$color_array[2] = 0xFF0000

*edit*

a better way to write the array:

Local $color_array[3] = [0x00FF00,0x0000FF,0xFF0000]

*end edit*

then get your text from the web page and search for the color

if $color = "green" then

$i = 0

elseif $color = "blue" then

$i = 1

elseif $color = "red" then

$i = 2

etc.

then you can use

GUICtrlSetColor($Handle_to_Text, $color_array[$i])

Edited by kaotkbliss

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hi,

Here you go :

#include <Array.au3>

ConsoleWrite("red: " & _HTMLColorToHex("red") & @CRLF) ;decimal
ConsoleWrite("red: 0x" & Hex(_HTMLColorToHex("red"), 6) & @CRLF) ;hex

;the hex color written in the array is converted to decimal

Func _HTMLColorToHex($sHTMLColorToHex_HTMLColor)
Local $aHTMLColorToHex_Color[3][2] = [ _ ;Don't forget to edit the size of the array
[0xFF0000, "red"], _
[0xFFFFFF, "white"], _
[0x000000, "black"]] ;and so on

Local $iHTMLColorToHex_ColorIndex = _ArraySearch($aHTMLColorToHex_Color, $sHTMLColorToHex_HTMLColor, 0, 0, 0, 0, 1, 1)

If $iHTMLColorToHex_ColorIndex <> -1 Then
Return $aHTMLColorToHex_Color[$iHTMLColorToHex_ColorIndex][0]
Else
Return -1
EndIf
EndFunc   ;==>_HTMLColorToHex

Br, FireFox.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

Can someone tell me how to make certain text green?

Just making certain text of specific color is not possible in Edit controls

U should use RichEdit controls


My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

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