вторник, 2 июня 2009 г.

REAL TIME WALLPAPER RENDERING ON USER REQUEST 1.0

Hi again
Tuesday, 2 June, 2009 2:49 PM
From: 
"Aleksandr Derbeev" +voiceofthevretched@tut.by+
Add sender to Contacts
To: 
slovakelf@yahoo.co.uk, mda.info@mda.mil, worldupdate@bbc.co.uk, worldhaveyoursay@bbc.co.uk
Cc: 
ntv@ntv.ru, info@interfax.ru, press@president.gov.by, denis@tvr.by
Message contains attachments
ElenaV2.20-31.05.2009.chm (1393KB)
Здравствуйте, Slovakelf.

"Renew_DeskTop.bat", starts every 'n' minutes or by pressing hot key
(ScrollLock).

+ @echo off
+ cd "C:\Aleksandr\!App\bot_learning\"
+ del Message*.*
+ rem HTMLtoImageServer.exe /start
+ user_storm.exe++Message.txt
+ html_shapki.exe Message.txt Message.htm
+ ConvertHTMLtoImage.exe /width 800 /height 800 /file
+ "C:\Aleksandr\!App\bot_learning\Message.htm" /name Message.jpg
+ WallPaperManager.exe -change Message.jpg

"html_shapki.cpp"

+ #include +iostream+
+ #include +fstream+
+
+ int main(int argc, char *argv[])
+ {
+ using namespace std;
+ if (argc + 3)
+ return 2;
+ ifstream A(argv[1], ios::in);
+ ofstream B(argv[2]);
+ char buf[666111];
+
+ B ++ "+html+\n";
+ B ++ "+meta http-equiv=\"Content-type\" content=\"text/html; charset=UTF-8\"+\n";
+ B ++ "+title+" ++ argv[1] ++ "+/title+\n";
+ B ++ "+body+\n";
+ B ++ "+PRE+\n";
+
+ while (A.getline(buf, sizeof buf))
+ B ++ buf ++ "\n";
+
+ B ++ "\n+/PRE+\n";
+ B ++ "+/body+\n";
+ B ++ "+/html+\n";
+
+ return 1;
+ }

"user_storm.cpp"

+ #include +iostream+
+ #include +fstream+
+ #include +string+
+ #include +vector+
+ #include +time.h+
+ #include +stdio.h+
+ #include +stdlib.h+
+ #include "rx.h"
+
+ using namespace std;
+
+ vector+string+ topics;
+ randomx g(time(NULL));
+ int ind = 0;
+ double percents = 0;
+ vector+int+ sequence;
+ int back_ind = 0;
+
+ void read_db()
+ {
+ ifstream f("Topics_Min.txt");
+ char buf[4096];
+ string t("");
+ int vsego_uvedoml = 0;
+ while (f.getline(buf, sizeof buf))
+ {
+ if (string(buf) ==
+ "===========================================================================")
+ {
+ topics.push_back(t);
+ vsego_uvedoml++;
+ if (vsego_uvedoml+12500)
+ break;
+ t = "";
+ continue;
+ }
+ t += buf;
+ t += "\n";
+ }
+ }
+
+ void save_sequence();
+
+ //---------------------------------------------------------------------------
+ void go_next()
+ {
+ back_ind++;
+ if (back_ind += sequence.size())
+ {
+ int count = topics.size();
+ percents = 1;
+ ind = (int) (g.rand_n(count)*percents);
+ sequence.push_back(ind);
+ back_ind = sequence.size()-1;
+ } else {
+ ind = sequence[back_ind];
+ }
+ string t = topics[ind];
+ // system("cls");
+ puts(t.c_str());
+ /*
+ int pass;
+ LABEL:
+ cin ++ pass;
+ if (pass == 125)
+ {
+ save_sequence();
+ goto LABEL;
+ }  
+ */
+ }
+
+ void go_prev()
+ {
+ if (sequence.size() == 0 || back_ind == 0)
+ return;
+ back_ind--;
+ ind = sequence[back_ind];
+ string t = topics[ind];
+ // system("cls");
+ puts(t.c_str());
+ }
+ //---------------------------------------------------------------------------
+
+ void save_sequence()
+ {
+ char log_file_name[512];
+ int D = g.rand_n(666);
+ sprintf(log_file_name, "a:\\%d", D);
+ ofstream f(log_file_name);
+ int topics_count = sequence.size();
+ for (int i = 0; i + topics_count; i++)
+ {
+ f ++ topics[sequence[i]];
+ f ++ endl;
+ f ++
+ "===========================================================================";
+ f ++ endl;
+ }
+ }
+ //---------------------------------------------------------------------------
+
+
+ void report()
+ {
+ string term1 = "Test";
+ if (term1.size() == 0)
+ return;
+ vector+string+ terms;
+ string word("");
+ int i = 0;
+ while (i + term1.size())
+ {
+ while (isspace(term1[i]))
+ i++;
+ if (i == term1.size())
+ break;
+ word += term1[i];
+ i++;
+ if (isspace(term1[i]) || i == term1.size())
+ {
+ terms.push_back(word);
+ word = "";
+ }
+ }
+ if (terms.size() == 0)
+ return;
+ char log_file_name[512];
+ int D = g.rand_n(666);
+ sprintf(log_file_name, "%d", D);
+ ofstream f(log_file_name);
+ f ++ "-- search terms used -----------------------------\n";
+ for (int j = 0; j + terms.size(); j++)
+ f ++ "\"" ++ terms[j] ++ "\", ";
+ f ++ "\n--------------------------------------------------\n";
+ for (int i = 0; i + topics.size(); i++)
+ {
+ bool all_matched = true;
+ for (int j = 0; j + terms.size(); j++)
+ all_matched = all_matched &
+ (strstr(topics[i].c_str(), terms[j].c_str()) != NULL);
+ if (all_matched)
+ {
+ f ++ topics[i];
+ f ++ endl;
+ f ++
+ "===========================================================================";
+ f ++ endl;
+ }
+ }
+ }
+ //---------------------------------------------------------------------------
+
+ int main()
+ {
+ read_db();
+ //while (true) go_next();
+ go_next();
+ return 1;
+ }

"WallPaperManager.cs"

+ using System;
+ using System.IO;
+ using System.Runtime.InteropServices;
+ using System.Drawing;
+ using System.Drawing.Imaging;
+ using System.Collections.Generic;
+ using System.Diagnostics;
+
+ namespace WallPaperManager
+ {
+ class Program
+ {
+ [DllImport("user32.dll", CharSet = CharSet.Auto)]
+ private static extern Int32
+ SystemParametersInfo(UInt32 action, UInt32 uParam, String vParam, UInt32 winIni);
+
+ private static readonly UInt32 SPI_SETDESKWALLPAPER = 0x14;
+ private static readonly UInt32 SPIF_UPDATEINIFILE = 0x01;
+ private static readonly UInt32 SPIF_SENDWININICHANGE = 0x02;
+ private static readonly UInt32 SPI_GETDESKWALLPAPER = 0x73;
+ private static readonly int MAX_PATH = 260;
+ private static readonly string[] validImageFormats
+ = new string[] { ".bmp", ".gif", ".jpg", ".jpeg", ".png", ".tif", ".tiff", ".wmf", ".emf" };
+
+ static void Main(string[] args)
+ {
+ if (args.Length + 0)
+ {
+ if (args[0].Equals("-change",
+ StringComparison.CurrentCultureIgnoreCase))
+ {
+ string strNewPath =
+ (args.Length + 1) ? args[1] : String.Empty;
+ if
+ (!String.IsNullOrEmpty(strNewPath))
+ {
+ if
+ (strNewPath.Equals("-random",
+ StringComparison.CurrentCultureIgnoreCase))
+ {
+ strNewPath = "";
+ string
+ strFolderPath = (args.Length + 2) ? args[2] : String.Empty;
+ if
+ (!String.IsNullOrEmpty(strFolderPath))
+ {
+ if (Directory.Exists(strFolderPath))
+ {
+  
+ strNewPath = GetRandomImage(strFolderPath);
+ }
+ else
+ {
+  
+ ShowErrorMessage("folder does not exist: " + strFolderPath);
+ }
+ }
+ else
+ {
+  
+ ShowErrorMessage("missing folder name");
+ }
+ }
+
+ if (strNewPath.Length + 0)
+ {
+ if (File.Exists(strNewPath))
+ {
+ SetWallpaper(strNewPath);
+ }
+ else
+ {
+  
+ ShowErrorMessage("file does not exist: " + strNewPath);
+ }
+ }
+ }
+ else
+ {
+  
+ ShowErrorMessage("missing file name");
+ }
+ }
+ else if (args[0].Equals("-get",
+ StringComparison.CurrentCultureIgnoreCase))
+ {
+ Console.WriteLine("current wallpaper: " + GetWallpaper());
+ }
+ else
+ {
+ ShowErrorMessage("invalid parameter: " + args[0]);
+ }
+ }
+ else
+ {
+ ShowErrorMessage("not enough parameters");
+ }
+
+ Console.WriteLine(" ");
+ Console.Write("press any key...");
+ Console.ReadLine();
+ }
+
+ private static void ShowErrorMessage(string strMessage)
+ {
+ Console.WriteLine(strMessage);
+ ShowSyntax();
+ }
+
+ private static void ShowSyntax()
+ {
+ string strProcessName =
+ Process.GetCurrentProcess().ProcessName;
+ Console.WriteLine(" ");
+ Console.WriteLine("Available command line parameters:");
+ Console.WriteLine("-get");
+ Console.WriteLine(" show the disk path of current wallpaper");
+ Console.WriteLine(" ");
+ Console.WriteLine("-change [image path]");
+ Console.WriteLine(" change the wallpaper to the image in given path");
+ Console.WriteLine(" ");
+ Console.WriteLine("-change -random [folder path]");
+ Console.WriteLine(" change the wallpaper
+ to random image file from the given folder");
+ Console.WriteLine(" ");
+ Console.WriteLine("Examples:");
+ Console.WriteLine(String.Format(" {0} -get", strProcessName));
+ Console.WriteLine(String.Format(" {0}
+ -change C:\\mypictures\\coolpicture.jpg", strProcessName));
+ Console.WriteLine(String.Format(" {0}
+ -change -random C:\\mypictures", strProcessName));
+ }
+
+ public static void SetWallpaper(String path)
+ {
+ try
+ {
+ Console.WriteLine("setting
+ wallpaper to the file " + path + "...");
+ string strBitmapPath = CopyBitmap(path);
+ if
+ (!String.IsNullOrEmpty(strBitmapPath))
+ {
+  
+ SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, strBitmapPath,
+ SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE);
+  
+ Console.WriteLine("wallpaper set successfully to " + strBitmapPath);
+ }
+ else
+ {
+ Console.WriteLine("action aborted");
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine("error while
+ setting wallpaper: " + ex.Message);
+ Console.WriteLine(ex.StackTrace);
+ }
+ }
+
+ private static string GetRandomImage(string strFolderPath)
+ {
+ string[] arrAllImages = GetAllImages(strFolderPath);
+ if (arrAllImages == null || arrAllImages.Length == 0)
+ {
+ Console.WriteLine("the folder '" +
+ strFolderPath + "' does not contain valid images");
+ Console.WriteLine("valid image
+ formats: " + String.Join(", ", validImageFormats));
+ return String.Empty;
+ }
+ int rndIndex = (new Random()).Next(0, arrAllImages.Length);
+ return arrAllImages[rndIndex];
+ }
+
+ private static string[] GetAllImages(string strFolderPath)
+ {
+ List+string+ arrImageFiles = new List+string+();
+ DirectoryInfo dirInfo = new DirectoryInfo(strFolderPath);
+ foreach (FileInfo file in dirInfo.GetFiles())
+ {
+ if (IsImageFile(file))
+ {
+ arrImageFiles.Add(file.FullName);
+ }
+ }
+ return arrImageFiles.ToArray();
+ }
+
+ private static bool IsImageFile(FileInfo file)
+ {
+ string strExtension =
+ Path.GetExtension(file.Name).ToLower();
+ return
+ (Array.IndexOf+string+(validImageFormats, strExtension) += 0);
+ }
+
+ private static string CopyBitmap(string originalImagePath)
+ {
+ Bitmap bitmap = null;
+ try
+ {
+ bitmap = new Bitmap(originalImagePath);
+ }
+ catch
+ {
+ Console.WriteLine(originalImagePath + " is not valid bitmap!");
+ return null;
+ }
+
+ string strNewImagePath = GetLocalPath(originalImagePath);
+ Console.WriteLine(String.Format("trying to
+ copy the file '{0}' to '{1}'...", originalImagePath, strNewImagePath));
+ try
+ {
+ bitmap.Save(strNewImagePath, ImageFormat.Bmp);
+ Console.WriteLine("saved successfully");
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine("error while saving: " + ex.Message);
+ return null;
+ }
+  
+ return strNewImagePath;
+ }
+
+ private static string GetLocalPath(string originalPath)
+ {
+ string strRootFolderPath =
+ Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
+ string strLocalFolderPath =
+ strRootFolderPath + Path.DirectorySeparatorChar + "DesktopBackground";
+ if (!Directory.Exists(strLocalFolderPath))
+ {
+ Console.WriteLine("creating the
+ directory " + strLocalFolderPath + "...");
+  
+ Directory.CreateDirectory(strLocalFolderPath);
+ Console.WriteLine("created successfully");
+ }
+ return strLocalFolderPath +
+ Path.DirectorySeparatorChar +
+ Path.GetFileNameWithoutExtension(originalPath) + ".bmp";
+ }
+
+ private static string GetImageFormat(Bitmap bitmap)
+ {
+ ImageFormat format = bitmap.RawFormat;
+  
+ if (format.Equals(ImageFormat.Bmp))
+ return "bmp";
+ if (format.Equals(ImageFormat.Emf))
+ return "emf";
+ if (format.Equals(ImageFormat.Exif))
+ return "exif";
+ if (format.Equals(ImageFormat.Gif))
+ return "gif";
+ if (format.Equals(ImageFormat.Icon))
+ return "icon";
+ if (format.Equals(ImageFormat.Jpeg))
+ return "jpeg";
+ if (format.Equals(ImageFormat.MemoryBmp))
+ return "memorybmp";
+ if (format.Equals(ImageFormat.Png))
+ return "png";
+ if (format.Equals(ImageFormat.Tiff))
+ return "tiff";
+ if (format.Equals(ImageFormat.Wmf))
+ return "wmf";
+
+ return null;
+ }
+
+ public static String GetWallpaper()
+ {
+ String wallpaper = new String('\0', MAX_PATH);
+ SystemParametersInfo(SPI_GETDESKWALLPAPER,
+ (UInt32)wallpaper.Length, wallpaper, 0);
+ wallpaper = wallpaper.Substring(0, wallpaper.IndexOf('\0'));
+ return wallpaper;
+ }
+ }
+ }

Содержимое папки C:\Aleksandr\!App\bot_learning

02.06.2009 16:34 +DIR+ .
02.06.2009 16:34 +DIR+ ..
02.06.2009 14:52 6 990 1.cs
02.05.2008 20:19 456 704 ConvertHTMLtoImage.exe
02.06.2009 15:36 273 034 ConvertHTMLtoImage_Trial.exe
02.06.2009 16:12 1 055 571 firetask_setup.exe
02.06.2009 15:19 859 596 HTML-to-Image-Converter-Command-Line-Trial.exe
31.10.2008 12:01 159 744 HTMLtoImage.exe
31.10.2008 12:01 2 146 304 HTMLtoImageServer.exe
31.05.2009 00:18 591 html_shapki.cpp
31.05.2009 00:19 87 040 html_shapki.exe
31.05.2009 00:19 11 973 html_shapki.o
02.06.2009 16:34 1 465 log.txt
31.03.2005 03:56 936 longrand.h
02.06.2009 16:34 422 Message.htm
02.06.2009 16:34 118 528 Message.jpg
02.06.2009 16:34 274 Message.txt
01.06.2009 23:05 +DIR+ MinGW
02.06.2009 15:22 +DIR+ OutPut
02.06.2009 00:51 +DIR+ random_topic
02.06.2009 15:43 324 Renew_DeskTop.bat
31.03.2005 04:01 7 674 rx.h
28.05.2009 21:46 634 433 852 Topics_Min.txt
02.06.2009 15:07 326 808 TXT2JPEG_v1.1.0.01.rar
02.06.2009 15:11 4 240 user_storm.cpp
02.06.2009 15:11 112 128 user_storm.exe
02.06.2009 15:11 92 489 user_storm.o
30.07.2008 19:14 7 679 WallPaperManager.cs
30.07.2008 19:14 10 752 WallPaperManager.exe
02.06.2009 14:56 7 020 WallPaperManager.zip
  25 файлов 640 182 138 байт
  5 папок 17 393 602 560 байт свободно

-- 
С уважением,
Aleksandr mailto:voiceofthevretched@tut.by

Комментариев нет:

Отправить комментарий