<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; VBScript: вывод текста поверх обоев Рабочего стола]]></title>
	<link rel="self" href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=2510&amp;type=atom" />
	<updated>2008-12-08T16:33:04Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=2510</id>
		<entry>
			<title type="html"><![CDATA[Re: VBScript: вывод текста поверх обоев Рабочего стола]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=16874#p16874" />
			<content type="html"><![CDATA[<p>Развитие предыдущего примера.<br />* более не используется компонент <strong><em>DynamicWrapperX</em></strong>, вместо него использован вызов функции UpdatePerUserSystemParameters из user32.dll посредством утилиты RUNDLL32.EXE;<br />* высота строки вычисляется только один раз (одинакова для всех символов, зависит только от шрифта и его размера);<br />* в примере размытие изображения не производится (при вызове функции SetWallpaper параметр boolBlur установлен == False);<br />* урезана длина выводимого в примере текста.<br /></p><div class="codebox"><pre><code>Option Explicit

Const OUTLINE              = &amp;H0002    &#039; Ореол

Dim strText

strText         = _
    &quot;И выше любого хотенья,&quot; &amp; vbCrLf &amp; _
    &quot;Сильнее любого знанья, —&quot; &amp; vbCrLf &amp; _
    &quot;Вечное жизни цветение&quot; &amp; vbCrLf &amp; _
    &quot;И вечное умиранье…&quot;


SetWallpaper _
    &quot;C:\Temp\background.bmp&quot;, _
    30, _
    20, _
    strText, _
    RGB(255, 255, 64), _
    &quot;Arial&quot;, _
    &quot;16&quot;, _
    False, _
    False, _
    OUTLINE, _
    RGB(32, 32, 32), _
    False

WScript.Quit 0
&#039;=============================================================================

&#039;=============================================================================
&#039; Процедура SetWallpaper
&#039;
&#039; strPath2SourceWallpaper : Полный путь к исходному графическому файлу
&#039; intMarginRight          : Поле от правого края изображения до текста
&#039; intMarginBottom         : Поле от нижнего края изображения до текста
&#039; strText                 : Текст
&#039; lngTextColor            : Цвет текста
&#039; strFontName             : Шрифт
&#039; intFontSize             : Размер шрифта
&#039; boolFontBold            : Жирный (True/False)
&#039; boolFontItalic          : Курсив (True/False)
&#039; intShadow               : Тень текста (0 — без тени, 1 — обычная тень, 2 — ореол)
&#039; lngShadowColor          : Цвет тени текста
&#039; boolBlur                : Размытие изображения (True/False)
&#039;=============================================================================
Sub SetWallpaper( _
    strPath2SourceWallpaper, _
    intMarginRight, intMarginBottom, _
    strText, lngTextColor, _
    strFontName, intFontSize, boolFontBold, boolFontItalic, _
    intShadow, lngShadowColor, _
    boolBlur _
    )
    
    Const WINDOWS              = &amp;H0000
    
    Const NONE                 = &amp;H0000    &#039; Нет тени
    Const SHADOW               = &amp;H0001    &#039; Тень
    Const OUTLINE              = &amp;H0002    &#039; Ореол
    
    
    Dim objGflAx
    Dim objFSO
    Dim objWshShell
    
    Dim strPath2DestWallpaper
    
    Dim intStringWidth
    Dim intStringMaxWidth
    Dim intStringMaxHeight
    
    Dim arrText
    Dim i
    Dim x
    Dim y
    
    
    Set objGflAx           = WScript.CreateObject(&quot;GflAx.GflAx&quot;)
    Set objFSO             = WScript.CreateObject(&quot;Scripting.FileSystemObject&quot;)
    Set objWshShell        = WScript.CreateObject(&quot;WScript.Shell&quot;)
    
    strPath2DestWallpaper   = objFSO.BuildPath(objFSO.GetSpecialFolder(WINDOWS), &quot;MyBackground.bmp&quot;)
    
    With objGflAx
        .LoadBitmap strPath2SourceWallpaper
        
        If boolBlur Then
            .GaussianBlur 10
        End If
        
        .FontName      = strFontName
        .FontSize      = intFontSize
        .FontBold      = boolFontBold
        .FontItalic    = boolFontItalic
        .FontAntialias = True
        
        arrText = Split(strText, vbCrLf)
        
        intStringMaxHeight = .GetTextHeight(arrText(LBound(arrText)))
        &#039; Вычисляем длину самой длинной строки текста
        intStringMaxWidth  = .GetTextWidth( arrText(LBound(arrText)))
        
        For i = LBound(arrText) + 1 To UBound(arrText)
            intStringWidth = .GetTextWidth(arrText(i))
            
            If intStringWidth &gt; intStringMaxWidth Then
                intStringMaxWidth = intStringWidth
            End If
        Next
        
        For i = UBound(arrText) To LBound(arrText) Step -1
            x = .width  - (intStringMaxWidth                              + intMarginRight )
            y = .height - (intStringMaxHeight * (UBound(arrText) - i + 1) + intMarginBottom)
            
            Select Case intShadow
                Case NONE
                    
                Case SHADOW
                    .TextOut arrText(i), x + 1, y + 1, lngShadowColor
                Case OUTLINE
                    .TextOut arrText(i), x + 1, y + 1, lngShadowColor
                    .TextOut arrText(i), x + 1, y - 1, lngShadowColor
                    .TextOut arrText(i), x - 1, y + 1, lngShadowColor
                    .TextOut arrText(i), x - 1, y - 1, lngShadowColor
                Case Else
            End Select
            
            .TextOut arrText(i), x, y, lngTextColor
        Next
        
        .SaveBitmap strPath2DestWallpaper
        
        &#039; Устанавливаем в качестве обоев сохранённый графический файл
        objWshShell.RegWrite &quot;HKEY_CURRENT_USER\Control Panel\Desktop\Wallpaper&quot;, strPath2DestWallpaper, &quot;REG_SZ&quot;
        objWshShell.Run &quot;&quot;&quot;%SystemRoot%\System32\RUNDLL32.EXE&quot;&quot; user32.dll,UpdatePerUserSystemParameters&quot;, 0, True
    End With
    
    Set objWshShell        = Nothing
    Set objFSO             = Nothing
    Set objGflAx           = Nothing
End Sub
&#039;=============================================================================</code></pre></div><p>Автор примера - <strong>alexii</strong>.</p>]]></content>
			<author>
				<name><![CDATA[The gray Cardinal]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=2</uri>
			</author>
			<updated>2008-12-08T16:33:04Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=16874#p16874</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[VBScript: вывод текста поверх обоев Рабочего стола]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=16379#p16379" />
			<content type="html"><![CDATA[<p>Требования: установленные компоненты <a href="http://www.xnview.com/en/download_gfl.html">GFLAx</a> и <a href="http://www.script-coding.com/dynwrapx1_00.zip">DynamicWrapperX</a>.<br /></p><div class="codebox"><pre><code>Option Explicit

Const OUTLINE              = &amp;H0002    &#039; Ореол

Dim strText

strText         = _
    &quot;Нас мотает от края до края —&quot; &amp; vbCrLf &amp; _
    &quot;По краям расположены двери:&quot; &amp; vbCrLf &amp; _
    &quot;На последней написано «Знаю»,&quot; &amp; vbCrLf &amp; _
    &quot;А на первой написано «Верю».&quot; &amp; vbCrLf &amp; _
    &quot;&quot; &amp; vbCrLf &amp; _
    &quot;И одной головой обладая,&quot; &amp; vbCrLf &amp; _
    &quot;Никогда не войдёшь в обе двери:&quot; &amp; vbCrLf &amp; _
    &quot;Если веришь — то вершь, не зная,&quot; &amp; vbCrLf &amp; _
    &quot;Если знаешь — то знаешь, не веря.&quot; &amp; vbCrLf &amp; _
    &quot;&quot; &amp; vbCrLf &amp; _
    &quot;И своё формируя сознанье,&quot; &amp; vbCrLf &amp; _
    &quot;С каждым днём от момента рожденья&quot; &amp; vbCrLf &amp; _
    &quot;Мы бредём по дороге познанья,&quot; &amp; vbCrLf &amp; _
    &quot;А с познаньем приходит сомненье.&quot; &amp; vbCrLf &amp; _
    &quot;&quot; &amp; vbCrLf &amp; _
    &quot;И загадка останется вечной,&quot; &amp; vbCrLf &amp; _
    &quot;Не помогут учёные лбы:&quot; &amp; vbCrLf &amp; _
    &quot;Если знаем — ничтожно слабы,&quot; &amp; vbCrLf &amp; _
    &quot;Если верим — сильны бесконечно.&quot; &amp; vbCrLf &amp; _
    &quot;&quot; &amp; vbCrLf &amp; _
    &quot;                        * * *&quot; &amp; vbCrLf &amp; _
    &quot;&quot; &amp; vbCrLf &amp; _
    &quot;И выше любого хотенья,&quot; &amp; vbCrLf &amp; _
    &quot;Сильнее любого знанья, —&quot; &amp; vbCrLf &amp; _
    &quot;Вечное жизни цветение&quot; &amp; vbCrLf &amp; _
    &quot;И вечное умиранье…&quot;


SetWallpaper _
    &quot;C:\Temp\background.bmp&quot;, _
    30, _
    20, _
    strText, _
    RGB(255, 255, 64), _
    &quot;Times New Roman&quot;, _
    &quot;20&quot;, _
    True, _
    True, _
    OUTLINE, _
    RGB(32, 32, 32), _
    True

WScript.Quit 0
&#039;=============================================================================

&#039;=============================================================================
&#039; Процедура SetWallpaper
&#039;
&#039; strPath2SourceWallpaper : Полный путь к исходному графическому файлу
&#039; intMarginRight          : Поле от правого края изображения до текста
&#039; intMarginBottom         : Поле от нижнего края изображения до текста
&#039; strText                 : Текст
&#039; lngTextColor            : Цвет текста
&#039; strFontName             : Шрифт
&#039; intFontSize             : Размер шрифта
&#039; boolFontBold            : Жирный (True/False)
&#039; boolFontItalic          : Курсив (True/False)
&#039; intShadow               : Тень текста (0 — без тени, 1 — обычная тень, 2 — ореол)
&#039; lngShadowColor          : Цвет тени текста
&#039; boolBlur                : Размытие изображения (True/False)
&#039;=============================================================================
Sub SetWallpaper( _
    strPath2SourceWallpaper, _
    intMarginRight, intMarginBottom, _
    strText, lngTextColor, _
    strFontName, intFontSize, boolFontBold, boolFontItalic, _
    intShadow, lngShadowColor, _
    boolBlur _
    )
    
    Const SPIF_UPDATEINIFILE   = &amp;H0001
    Const SPIF_SENDCHANGE      = &amp;H0002
    
    Const SPI_SETDESKWALLPAPER = &amp;H0014
    
    Const WINDOWS              = &amp;H0000
    
    Const NONE                 = &amp;H0000    &#039; Нет тени
    Const SHADOW               = &amp;H0001    &#039; Тень
    Const OUTLINE              = &amp;H0002    &#039; Ореол
    
    
    Dim objGflAx
    Dim objFSO
    Dim objDynamicWrapperX
    
    Dim strPath2DestWallpaper
    
    Dim intStringWidth
    Dim intStringHeight
    Dim intStringMaxWidth
    
    Dim arrText
    Dim i
    Dim x
    Dim y
    
    
    Set objGflAx           = WScript.CreateObject(&quot;GflAx.GflAx&quot;)
    Set objFSO             = WScript.CreateObject(&quot;Scripting.FileSystemObject&quot;)
    Set objDynamicWrapperX = WScript.CreateObject(&quot;DynamicWrapperX&quot;)
    
    objDynamicWrapperX.Register &quot;user32.dll&quot;, &quot;SystemParametersInfoW&quot;, &quot;i=uuwu&quot;, &quot;r=l&quot;
    
    strPath2DestWallpaper   = objFSO.BuildPath(objFSO.GetSpecialFolder(WINDOWS), &quot;MyBackground.bmp&quot;)
    
    With objGflAx
        .LoadBitmap strPath2SourceWallpaper
        
        If boolBlur Then
            .GaussianBlur 10
        End If
        
        .FontName      = strFontName
        .FontSize      = intFontSize
        .FontBold      = boolFontBold
        .FontItalic    = boolFontItalic
        .FontAntialias = True
        
        arrText = Split(strText, vbCrLf)
        
        &#039; Вычисляем длину самой длинной строки текста
        intStringMaxWidth = .GetTextWidth(arrText(LBound(arrText)))
        
        For i = LBound(arrText) + 1 To UBound(arrText)
            intStringWidth = .GetTextWidth(arrText(i))
            
            If intStringWidth &gt; intStringMaxWidth Then
                intStringMaxWidth = intStringWidth
            End If
        Next
        
        For i = UBound(arrText) To LBound(arrText) Step -1
            intStringHeight = .GetTextHeight(arrText(i))
            
            x = .width  - (intStringMaxWidth                             + intMarginRight )
            y = .height - (intStringHeight   * (UBound(arrText) - i + 1) + intMarginBottom)
            
            Select Case intShadow
                Case NONE
                    
                Case SHADOW
                    .TextOut arrText(i), x + 1, y + 1, lngShadowColor
                Case OUTLINE
                    .TextOut arrText(i), x + 1, y + 1, lngShadowColor
                    .TextOut arrText(i), x + 1, y - 1, lngShadowColor
                    .TextOut arrText(i), x - 1, y + 1, lngShadowColor
                    .TextOut arrText(i), x - 1, y - 1, lngShadowColor
                Case Else
            End Select
            
            .TextOut arrText(i), x, y, lngTextColor
        Next
        
        .SaveBitmap strPath2DestWallpaper
        
        &#039; Устанавливаем в качестве обоев сохранённый графический файл
        objDynamicWrapperX.SystemParametersInfoW SPI_SETDESKWALLPAPER, 0, strPath2DestWallpaper, SPIF_UPDATEINIFILE Or SPIF_SENDCHANGE
    End With
    
    Set objDynamicWrapperX = Nothing
    Set objFSO             = Nothing
    Set objGflAx           = Nothing
End Sub
&#039;=============================================================================</code></pre></div><p>Пример берёт файл &quot;C:\Temp\background.bmp&quot;, вставляет в него текст, размещает результат как &quot;C:\WINDOWS\MyBackground.bmp&quot; и делает его обоями Рабочего стола. Пример делает картинку немного размытой, чтобы текст был контрастнее. Это можно легко отключить единственным параметрм (см. комментарии в коде). Если картинка по размеру не совсем подходит под разрешение экрана, часть текста может оказаться невидимой.<br />Автор примера - <strong>alexii</strong>.</p>]]></content>
			<author>
				<name><![CDATA[The gray Cardinal]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=2</uri>
			</author>
			<updated>2008-11-28T15:28:46Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=16379#p16379</id>
		</entry>
</feed>
