Guest User

Untitled

a guest
Jan 26th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 3.88 KB | None | 0 0
  1. #NoTrayIcon
  2. #include <Crypt.au3>
  3. #include <GDIPlus.au3>
  4. #include <Array.au3>
  5. #include <GUIConstantsEx.au3>
  6. #include <WindowsConstants.au3>
  7.  
  8. ConsoleWrite(TXTtoJPG(@DesktopDir&"\script\readme.txt",@DesktopDir&"\script\readme.jpg","Passwort"))
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18. Func TXTtoJPG($pTXT,$pJPG,$sPW)
  19.     $pTXTsplit = StringSplit($pTXT,"\")
  20.     if $pTXTsplit[0] = 1 Then
  21.         $pTXTsplit = StringSplit($pTXT,"/")
  22.         if $pTXTsplit[0] = 1 Then return -1
  23.     endif
  24.     $name = $pTXTsplit[$pTXTsplit[0]]
  25.     $file = FileOpen($pTXT,16)
  26.     $TXTdata = FileRead($file)
  27.     FileClose($file)
  28.     if _Crypt_Startup() = False Then return -1
  29.     $Key=_Crypt_DeriveKey($sPW,$CALG_RC4)
  30.     if $Key = -1 Then return -1
  31.     $write = "<JPGTXTCRYPT\NAME:"&$name&":NAME/>"&_Crypt_EncryptData($TXTdata,$Key,$CALG_USERKEY)&"</JPGTXTCRYPT>"
  32.     $i = StringLen($write) / 3
  33.     do
  34.     if Int($i) <> $i Then
  35.         $write &= " "
  36.         $i = StringLen($write) / 3
  37.     endif
  38.     until Int($i) = $i
  39.     _Crypt_DestroyKey($Key)
  40.     _Crypt_Shutdown()
  41.     $pixel = Sqrt(StringLen($write)/3)
  42.     $pixel = Int($pixel)
  43.     $pixel += 1
  44.     $GUI = GuiCreate("Generate",$pixel,$pixel,@DesktopWidth-$pixel-10,@DesktopHeight-$pixel-40,BitOR($WS_SYSMENU, $WS_POPUP, $WS_POPUPWINDOW, $WS_BORDER))
  45.     WinSetOnTop($Gui, "", 1)
  46.     FileInstall(@DesktopDir&"\ico.ico",@TempDir&"\Ic0n_20_Generate_TXTTOJPG.ico",1)
  47.     GuiSetIcon(@TempDir&"\Ic0n_20_Generate_TXTTOJPG.ico")
  48.     GuiSetState(@SW_SHOW)
  49.     _GDIPlus_Startup ()
  50.     $Graphic = _GDIPlus_GraphicsCreateFromHWND($GUI)
  51.     if $Graphic = 0 Then return -1
  52.     $chars = Stringsplit($write,"")
  53.     $s = 1
  54.     $pen = _GDIPlus_PenCreate(0xFF000000)
  55.     _GDIPlus_GraphicsFillRect($Graphic,0,0,$pixel,$pixel,$pen)
  56.     for $i=1 to $pixel
  57.         for $d=1 to $pixel
  58.         if $s > Ubound($chars)-1 Then
  59.             $pen = _GDIPlus_PenCreate(0xFF000000+RBG(0,0,0))
  60.             if _GDIPlus_GraphicsDrawRect($Graphic,$d,$i,1,1,$pen) = False Then return -1
  61.         Else
  62.             $pen = _GDIPlus_PenCreate("0xFF"&StringReplace(RBG(ASC($chars[$s]),ASC($chars[$s+1]),ASC($chars[$s+2])),"0x",""))
  63.             if _GDIPlus_GraphicsDrawRect($Graphic,$d,$i,1,1,$pen) = False Then return -1
  64.             $s += 3
  65.         endif
  66.         Next
  67.     Next
  68.     if _GDIPlus_Save_to_Image($pJPG,$GUI) = False Then return -1
  69.     _GDIPlus_Shutdown()
  70.     GuiDelete($GUI)
  71.     return 1
  72. EndFunc
  73.  
  74.  
  75. func RBGOfColor($RBGColor)
  76.     dim $rbg[3]
  77.     $RBGColor = StringReplace($RBGColor,"0x","")
  78.     $rbg[2] = StringRight($RBGColor,2)
  79.     $rbg[1] = StringLeft(StringRight($RBGColor,4),2)
  80.     $rbg[0] = StringRight(StringLeft($RBGColor,2),6)
  81.     $rbg[2] = Int("0x"&$rbg[2])
  82.     $rbg[1] = Int("0x"&$rbg[1])
  83.     $rbg[0] = Int("0x"&$rbg[0])
  84.     return $rbg
  85. endfunc
  86.  
  87. Func RBG($r2,$b2,$g2)
  88.     return "0x"&StringRight(Hex($r2),2)&StringRight(Hex($b2),2)&StringRight(Hex($g2),2)
  89. endfunc
  90.  
  91.  
  92. Func _GDIPlus_Save_to_Image($file, $hWnd)
  93.     Local $hDC, $memBmp, $memDC, $hImage, $w, $h, $size, $err, $sCLSID, $ext, $fExt
  94.     If $file <> "" Or $hWnd <> "" Then
  95.         $size = WinGetClientSize($hWnd)
  96.         $w = $size[0]
  97.         $h = $size[1]
  98.         $hDC = _WinAPI_GetDC($hWnd)
  99.         $memDC = _WinAPI_CreateCompatibleDC($hDC)
  100.         $memBmp = _WinAPI_CreateCompatibleBitmap($hDC, $w, $h)
  101.         _WinAPI_SelectObject ($memDC, $memBmp)
  102.         _WinAPI_BitBlt($memDC, 0, 0, $w, $h, $hDC, 0, 0, 0x00CC0020) ;  0x00CC0020 = $SRCCOPY
  103.         $hImage = _GDIPlus_BitmapCreateFromHBITMAP ($memBmp)
  104.         $ext = "png,bmp,jpg,tif,gif"
  105.         $fExt = StringRight($file, 3)
  106.         If Not StringInStr($ext, $fExt)  Then
  107.             $CLSID = "PNG"
  108.             $file &= ".png"
  109.         Else
  110.             $CLSID = $fExt
  111.         EndIf
  112.         $sCLSID = _GDIPlus_EncodersGetCLSID ($CLSID)
  113.         If Not _GDIPlus_ImageSaveToFileEx ($hImage, $file, $sCLSID) Then $err = 1
  114.         _GDIPlus_ImageDispose ($hImage)
  115.         _WinAPI_ReleaseDC($hWnd, $hDC)
  116.         _WinAPI_DeleteDC($memDC)
  117.         _WinAPI_DeleteObject ($memBmp)
  118.         If $err Then Return SetError(2, 0, 0)
  119.         Return SetError(0, 0, 0)
  120.     Else
  121.         Return SetError(1, 0, 0)
  122.     EndIf
  123. EndFunc
Add Comment
Please, Sign In to add comment