Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Scrolling tray icon


  • Please log in to reply
6 replies to this topic
Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
This is a proof of concept, only. It works with 256 color 32x32 pixel bmp files, as tray icons, although it is easy to modify it for other sizes and bit-map formats, like .ico files.

The actual bitmap, one byte of color information for each pixel, is at the end of the file. We keep the beginning of the image file, read the first 31 rows of the image and the last row, and write into the same file swapped. Setting this as the new tray icon has the effect of the picture scrolled up cyclically by one pixel. Scrolling down is similar.

The hotkey Win-1 scrolls up, Win-2 scrolls down and Win-0 stops the icon. You can use your favorite one, or use the 3rd script to decode the Ascii85 encoded example.
file0= %A_ScriptDir%\l0.bmp   ; <-- your bmp file
file = %A_ScriptDir%\l.bmp    ; working copy
GoTo #0

#1::
   SetTimer ScrollUp,  50
   SetTimer ScrollDown,Off
Return

#2::
   SetTimer ScrollUp,  Off
   SetTimer ScrollDown,50
Return

#0::
   SetTimer ScrollUp,  Off
   SetTimer ScrollDown,Off
   FileCopy %file0%, %file%, 1
   Menu Tray, Icon, %file%
Return

ScrollUp:
   Menu Tray, Icon, %file%
   BinRead( file, D1, 992,-1024)
   BinRead( file, D2,  32,  -32)
   BinWrite(file, D2,  32,-1024)
   BinWrite(file, D1, 992, -992)
Return

ScrollDown:
   Menu Tray, Icon, %file%
   BinRead( file, D1,  32,-1024)
   BinRead( file, D2, 992, -992)
   BinWrite(file, D2, 992,-1024)
   BinWrite(file, D1,  32,  -32)
Return

BinWrite(file, ByRef data, n=0, offset=0) {  ; n = #bytes/all; neg offset from end, "A" = Append
   h := DllCall("CreateFile",Str,file, UInt,0x40000000, UInt,0, UInt,0, UInt,4, UInt,0, UInt,0)
   m := 2*(offset+0 < 0)                  ; offset >= 0 : m = 0; offset < 0, non-numeric: m = 2
   offset += 0                            ; non-numeric -> 0
   DllCall("SetFilePointerEx",UInt,h, Int64,offset, UIntP,p, Int,m)
   m := VarSetCapacity(data)
   If n not between 1 and %m%
      n = %m%
   DllCall("WriteFile",UInt,h, Str,data, UInt,n, UIntP,U, UInt,0)
   DllCall("CloseHandle", UInt,h)
}

BinRead(file, ByRef data, n=0, offset=0)  {  ; n = #bytes/all; neg offset from end
   h := DllCall("CreateFile",Str,file, UInt,0x80000000, UInt,3, UInt,0, UInt,3, UInt,0, UInt,0)
   m := 2*(offset < 0)                       ; offset >= 0 : m = 0; offset < 0: m = 2
   DllCall("SetFilePointerEx",UInt,h, Int64,offset, UIntP,U, Int,m)
   m := DllCall("GetFileSize",UInt,h, Int64P,r)
   If n not between 1 and %m%
      n = %m%
   VarSetCapacity(data, n)
   DllCall("ReadFile",UInt,h, Str,data, UInt,n, UIntP,r, UInt,0)
   DllCall("CloseHandle", UInt,h)
   Return r
}
You can encode your favorite bmp file (for copying from the MsgBox to the script) with the following script:
nD := BinRead(file, D)	; include file and BinRead from above
Ascii85Encode(C, D, nD)

StringReplace C, C, ``, ````, All
StringReplace C, C, `%, ```%, All
StringReplace C, C, `), ```), All
Loop % (StrLen(C)+79)//80
{
   StringMid x, C, A_Index*80-79, 80
   B = %B%%x%`n
}
MsgBox %B%

Ascii85Encode(ByRef code, ByRef data, n=0) {
   If n not between 1 and % VarSetCapacity(data)
      n := StrLen(data)          ; If no \0 in data, can omit n
   x = 0
   code = <~
   Loop %n% {
      x += *(&data+A_Index-1) << (24-8*((A_Index-1)&3))
      If !(A_Index & 3) {        ; Mod(i,4) = 0
         IfEqual x,0, SetEnv code,%code%z
         Else Loop 5
            code := code  Chr(33+Mod(x//85**(5-A_Index),85))
         x = 0
      }
   }
   If (n & 3)                    ; Mod(n,4) > 0
      Loop % (n&3)+1
         code := code  Chr(33+Mod(x//85**(5-A_Index),85))
   code = %code%~>
}
Pressing Ctrl-C when the message box is active, copies the content to the clipboard, which you can paste to the script in an editor. This is how the encoded file is used (as Veovis suggested).
C =
(
<~6;9?Dz!!"n[!!"DI!!",A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&5"U,&5"U,`)7"pP&-"U,&5"U,&5!!!0+"U,&5"U,&5"U,&5"U,`)7"pP&-"U,&5"U,&5!!!0+"U,
&5"U,&5"U,&5"U,`)7"pP&-"U,&5"U,&5!!!0+"U,&5"U,&5"U,&5"U,`)7"pP&-"U,&5"U,&5!!!0+"
U,&5"U,&5"U,&5"U,`)7"pP&-"U,&5"U,&5!!!0+"U,&5"U,&5"U,&5"U,`)7"pP&-"U,&5"U,&5!!!0
+"U,&5"U,&5"U,&5"U,`)7"pP&-"U,&5"U,&5!!!0+"U,&5"U,&5"U,&5"U,`)7"pP&1"U,&5"U,&5!!
!0+"U,&5"U,&5"U,&5"U,`)7"pP57"U,&5"U,&5!!!0+"U,&5"U,&5"U,&5"U+u4"p5#4"U,&5"U,&5!
!!0+"U,&5"U,&5"U,&5"U,&5"U,&5"U,&5"U,&5!<E?-"U,&5"U,&5"U,&5"U,&5"U,&5"U,&5"U,&5!<E~>
)
Ascii85Decode(B,C,nB)
BinWrite(file0, B, nB)	; use file0 and BinWrite from the 1st script

Ascii85Decode(ByRef data, code, ByRef len) {
   StringReplace, code, code, <~
   StringReplace, code, code, ~>
   StringReplace, code, code, `n,, All
   StringReplace, code, code, `r,, All
   StringReplace, code, code, %A_Space%,,All

   StringCaseSense On         ; needed for z -> !!!!!
   StringReplace, code, code, z, !!!!!, All

   m := Mod(StrLen(code),5) - (Mod(StrLen(code),5)>0) ; 12345 -> ?1230
   len := (StrLen(code)//5)*4 + m
   VarSetCapacity(data,len,0)
   p := &data
   x = 0
   Loop Parse, code
      If Mod(A_Index,5) = 0 {
         x := x*85 + Asc(A_LoopField)-33
         Loop 4 {
            DllCall("RtlFillMemory",UInt,p, UInt,1, UChar,x>>(32-8*A_Index))
            p++
         }
         x = 0
      }
      Else
         x := x*85 + Asc(A_LoopField)-33
   x := (x+1) * 85**(4-m) ; omitted code chars -> 85+33, carry stops at trailing 0's of x
   Loop %m%  {
      DllCall("RtlFillMemory",UInt,p, UInt,1, UChar,x>>(32-8*A_Index))
      p++
   }
}


BoBo
  • Guests
  • Last active:
  • Joined: --
C8)8)LASZL:wink:

JSLover
  • Members
  • 920 posts
  • Last active: Nov 02 2012 09:54 PM
  • Joined: 20 Dec 2004
[color=red][size=18][/color][co[color=null][/color]lor=blue][color=red][b][/color]C[color=red][/b][/color][/color][color=red][/size][/color]8)8)[color=red][size=18][/color]
[co[color=null][/color]lor=red][color=red][b][/color]L[color=red][/b][/color][/color][color=red][/size][b][size=18][/color]ASZL[color=red][/size][/b][/color]:wink:
...can be written...

[color=blue][b][size=18][/color][co[color=null][/color]lor=blue]C[/color]8)8)[co[color=null][/color]lor=red]L[/color]ASZL[color=blue][/size][/b][/color]:wink:
...if the whole thing is bold 18, then you don't need to keep opening & closing em...

overkill ---> C8)8)LASZL:wink: = C8)8)LASZL:wink: <--- compact
Useful forum links: New content since: Last visitPast weekPast 2 weeks (links will show YOUR posts, not mine)

OMFG, the AutoHotkey forum is IP.board now (yuck!)...I may not be able to continue coming here (& I love AutoHotkey)...I liked phpBB, but not this...ugh...

Note...
I may not reply to any topics (specifically ones I was previously involved in), mostly cuz I can't find the ones I replied to, to continue helping, but also just cuz I can't stand the new forum...phpBB was soo perfect. This is 100% the opposite of "perfect".

I also semi-plan to start my own, phpBB-based AutoHotkey forum (or take over the old one, if he'll let me)
PM me if you're interested in a new phpBB-based forum (I need to know if anyone would use it)
How (or why) did they create the Neil Armstrong memorial site (neilarmstronginfo.com) BEFORE he died?

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
:D :D :D

Thank you very much, Sir.

:D :D :D
kWo4Lk1.png

BoBo
  • Guests
  • Last active:
  • Joined: --

...if the whole thing is bold 18, then you don't need to keep opening & closing em...

During its design I changed the variants multiple times. Therefore that code is less jsloverished as it should have been, confirmed. :lol:

WarrenFaith
  • Members
  • 11 posts
  • Last active: Jul 21 2006 01:09 PM
  • Joined: 11 Jul 2006
You have problems... :shock:

Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005

You have problems... :shock:

Never mind... JSlover is also a venerable member of the "mine is shorter than yours" camp.