Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Adding Text to Windows Desktop


  • Please log in to reply
10 replies to this topic

#1 MikeOsdx

MikeOsdx

    Never trust a Monkey

  • Active Members
  • PipPipPipPipPipPip
  • 543 posts

Posted 14 November 2008 - 02:18 PM

I'm trying to figure out how to display some text on the desktop simmilar to how some trial OS's will put the OS, Build Number, and Trial info.

I found this ResHacker option but i'm looking for something a bit cleaner so I can update the text when needed.

Anybody have an idea?

Thanks,
Mike
Posted Image







#2 Manadar

Manadar

         

  • MVPs
  • 10,789 posts

Posted 14 November 2008 - 02:49 PM

My idea is to use what lod3n did here: http://www.autoitscript.com/forum/index.php?showtopic=47651

You basically make an invisible GUI on the desktop. Never activate the GUI ( @SW_SHOWMINNOACTIVE ), and in the GUI loop make sure it is in the right Z-index on the desktop.

#3 MikeOsdx

MikeOsdx

    Never trust a Monkey

  • Active Members
  • PipPipPipPipPipPip
  • 543 posts

Posted 14 November 2008 - 02:51 PM

yeah, i thought about that also but I really don't want to have a script running all the time just to display some text.
Posted Image

#4 ResNullius

ResNullius

    Drink Deep, or Taste Not the Pierian Spring

  • Active Members
  • PipPipPipPipPipPip
  • 1,033 posts

Posted 15 November 2008 - 10:23 AM

yeah, i thought about that also but I really don't want to have a script running all the time just to display some text.

You can use bginfo http://technet.microsoft.com/en-us/sysinte...s/bb897557.aspx and just customize the output to show your desired text only.
Note that you can't redistribute bginfo, but you could probably even hack together your own version using some of the graphics/GDI functions that have been posted.

#5 martin

martin

    ~~\o/~~~/0\=¬''~~~

  • MVPs
  • 7,313 posts

Posted 15 November 2008 - 10:52 AM

yeah, i thought about that also but I really don't want to have a script running all the time just to display some text.

Maybe find the file used for the desktop, create a copy and add text to it then switch the desktop to use that file.
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

#6 Malkey

Malkey

  • Active Members
  • PipPipPipPipPipPip
  • 1,497 posts

Posted 15 November 2008 - 02:01 PM

If you want to go with GDI functions, here is something you can play with.

AutoIt         
#include <GDIPlus.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> HotKeySet("{ESC}", "Quit") CreateFloatText("Tweaking with Vishal" & @CRLF & "Build 6001", @DesktopWidth / 1.4, @DesktopHeight / 1.1, "Arial", 12, 0xFFFFFFFF, 2) ;or ;CreateFloatText("Where to go to from here.", 100, 10, "Arial" , 25, 0xFFFF00ff) While 1     Sleep(20) WEnd Func CreateFloatText($nText, $Left = -1, $Top = -1, $nFontName = "Arial", _         $nFontSize = 12, $iARGB = 0xFFFFFFFF, $iAlign = 1)     Local $hWnd, $hDC, $hBitmap, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend     Local $iOpacity = 255     Local $ULW_ALPHA = 2     Local $hGui, $hGraphic, $GuiWidth, $GuiHeight     Local $hBrush, $hFormat, $hFamily, $hFont, $tLayout     $txtlen = StringLen($nText)     $GuiWidth = Int($nFontSize * $txtlen * 37 / 40) ;Tweak here to de/increase text box width size     $GuiHeight = Int(($nFontSize * 37 / 30) * (17 / 9) * ((StringInStr($nText, @CRLF) > 0) + 1))     ;ConsoleWrite("$GuiWidth = " & $GuiWidth & "  $GuiHeight = "& $GuiHeight & @CRLF)     $hGui = GUICreate("Text", $GuiWidth, $GuiHeight, $Left, $Top, -1, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))     GUISetState()     _GDIPlus_Startup()     $hWnd = _WinAPI_GetDC($hGui)     $hDC = _WinAPI_CreateCompatibleDC($hWnd)     $hBitmap = _WinAPI_CreateCompatibleBitmap($hWnd, $GuiWidth, $GuiHeight)     _WinAPI_SelectObject($hDC, $hBitmap)     $hGraphic = _GDIPlus_GraphicsCreateFromHDC($hDC)     ; Parameters for GDIPlus_GraphicsDrawStringEx()     $hBrush = _GDIPlus_BrushCreateSolid($iARGB)     $hFormat = _GDIPlus_StringFormatCreate()     $hFamily = _GDIPlus_FontFamilyCreate($nFontName)     $hFont = _GDIPlus_FontCreate($hFamily, $nFontSize, 1, 3)     $tLayout = _GDIPlus_RectFCreate(0, 0, $GuiWidth, $GuiHeight)     $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $nText, $hFont, $tLayout, $hFormat)     $rectWidth = DllStructGetData($aInfo[0], "Width")     $rectHeight = DllStructGetData($aInfo[0], "Height")     ;ConsoleWrite("$rectWidth = " & $rectWidth & "  $rectHeight = "& $rectHeight & @CRLF)     WinMove("Text", "", $Left, $Top, Int($rectWidth), Int($rectHeight))     _GDIPlus_StringFormatSetAlign($hFormat, $iAlign)     _GDIPlus_GraphicsDrawStringEx($hGraphic, $nText, $hFont, $tLayout, $hFormat, $hBrush)     ; Parameters for _WinAPI_UpdateLayeredWindow     $tSize = DllStructCreate($tagSIZE)     $pSize = DllStructGetPtr($tSize)     DllStructSetData($tSize, "X", $GuiWidth)     DllStructSetData($tSize, "Y", $GuiHeight)     $tSource = DllStructCreate($tagPOINT)     $pSource = DllStructGetPtr($tSource)     $tBlend = DllStructCreate($tagBLENDFUNCTION)     $pBlend = DllStructGetPtr($tBlend)     DllStructSetData($tBlend, "Alpha", $iOpacity)     DllStructSetData($tBlend, "Format", 1)     _WinAPI_UpdateLayeredWindow($hGui, $hWnd, 0, $pSize, $hDC, $pSource, 0, $pBlend, $ULW_ALPHA)     ; Clean up resources     _GDIPlus_FontDispose($hFont)     _GDIPlus_FontFamilyDispose($hFamily)     _GDIPlus_StringFormatDispose($hFormat)     _GDIPlus_BrushDispose($hBrush)     _GDIPlus_GraphicsDispose($hGraphic)     _WinAPI_ReleaseDC(0, $hWnd)     _WinAPI_DeleteObject($hBitmap)     _WinAPI_DeleteDC($hDC)     _GDIPlus_Shutdown()     Return 1 EndFunc   ;==>CreateFloatText Func _GDIPlus_StringFormatSetAlign($hStringFormat, $iFlag)     Local $aResult     $aResult = DllCall($ghGDIPDll, "int", "GdipSetStringFormatAlign", "ptr", $hStringFormat, "short", $iFlag)     If @error Then Return SetError(@error, @extended, 0)     If $aResult[0] = 0 Then Return SetError(0, 0, 1)     Return SetError(1, 0, 0) EndFunc   ;==>_GDIPlus_StringFormatSetAlign Func Quit()     Exit EndFunc   ;==>Quit


Interesting thing about this example is it appears to place part of the text where the invisible title bar is. This is the reason, I believe, that the top line of the text is dragable. And, on my system, when I click on the top left stem of the capital V of the text, the invisible GUI minimizes.

#7 Valuater

Valuater

    www.PayFreeWireless.com

  • MVPs
  • 11,199 posts

Posted 15 November 2008 - 02:58 PM

FreeText.au3 id your friend...

http://www.autoitscript.com/forum/index.ph...st&p=527912

8)

Edited by Valuater, 15 November 2008 - 02:59 PM.

Posted Image

Clic The Pic!!!


#8 MikeOsdx

MikeOsdx

    Never trust a Monkey

  • Active Members
  • PipPipPipPipPipPip
  • 543 posts

Posted 16 November 2008 - 02:58 PM

You can use bginfo http://technet.microsoft.com/en-us/sysinte...s/bb897557.aspx and just customize the output to show your desired text only.
Note that you can't redistribute bginfo, but you could probably even hack together your own version using some of the graphics/GDI functions that have been posted.


That is PERFECT! Thanks ResNullius...

Now I have to figure out how to add text to an image file... and I can make this myself.

Mike
Posted Image

#9 Valuater

Valuater

    www.PayFreeWireless.com

  • MVPs
  • 11,199 posts

Posted 16 November 2008 - 03:12 PM

You can use bginfo http://technet.microsoft.com/en-us/sysinte...s/bb897557.aspx and just customize the output to show your desired text only.
Note that you can't redistribute bginfo, but you could probably even hack together your own version using some of the graphics/GDI functions that have been posted.


Actually, that is pretty cool!

8)

Posted Image

Clic The Pic!!!


#10 monoceres

monoceres

    asdf

  • MVPs
  • 4,015 posts

Posted 16 November 2008 - 03:18 PM

Now I have to figure out how to add text to an image file... and I can make this myself.

Mike

That's easy with GDI+ :mellow:

Plain Text         
#include <GDIPlus.au3> _GDIPlus_Startup() $image=_GDIPlus_ImageLoadFromFile(@ScriptDir&"\sample.jpg") $imagegraphics=_GDIPlus_ImageGetGraphicsContext($image) $w=_GDIPlus_ImageGetWidth($image) $h=_GDIPlus_ImageGetHeight($image) $whitebrush=_GDIPlus_BrushCreateSolid(0xFFFFFFFF) $fontfamily=_GDIPlus_FontFamilyCreate("Arial") $font=_GDIPlus_FontCreate($fontfamily,18) $stringformat=_GDIPlus_StringFormatCreate() _GDIPlus_StringFormatSetAlign($stringformat,2) $rect=_GDIPlus_RectFCreate(0,$h-25,$w,$h) _GDIPlus_GraphicsDrawStringEx($imagegraphics,"Sample Text",$font,$rect,$stringformat,$whitebrush) _GDIPlus_ImageSaveToFile($image,@ScriptDir&"\newimage.jpg") _GDIPlus_ImageDispose($image) _GDIPlus_GraphicsDispose($imagegraphics) _GDIPlus_BrushDispose($whitebrush) _GDIPlus_FontFamilyDispose($fontfamily) _GDIPlus_FontDispose($font) _GDIPlus_StringFormatDispose($stringformat) _GDIPlus_Shutdown() Func _GDIPlus_StringFormatSetAlign($hStringFormat, $iFlag)     Local $aResult     $aResult = DllCall($ghGDIPDll, "int", "GdipSetStringFormatAlign", "ptr", $hStringFormat, "short", $iFlag)     If @error Then Return SetError(@error, @extended, 0)     If $aResult[0] = 0 Then Return SetError(0, 0, 1)     Return SetError(1, 0, 0) EndFunc  ;==>_GDIPlus_StringFormatSetAlign


:(

Broken link? PM me and I'll send you the file!


#11 ResNullius

ResNullius

    Drink Deep, or Taste Not the Pierian Spring

  • Active Members
  • PipPipPipPipPipPip
  • 1,033 posts

Posted 16 November 2008 - 09:35 PM

That's easy with GDI+ :mellow:

I knew one of the GDI+ guys would have an answer.
So now MikeOsdx, all you need to do is read the appropriate registry entry to find the current wallpaper, use that as the source picture in monoceres's script and then update the wallpaper to the new picture.

Edited by ResNullius, 16 November 2008 - 09:35 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users