DonationCoder.com Software > Post New Requests Here
IDEA: Draw on your desktop
skrommel:
:) Here's DesktopDrawer - Draw on your desktop!
Just run the script, paint using your mouse, press Esc to exit, or use the toolbar.
I was unable to post the whole code because of size limitations on the forum, so you have to download two files:
The script requires Gdip.ahk from http://www.autohotkey.com/forum/topic32238.html
and COM.ahk from http://www.autohotkey.com/forum/topic22923.html
Just place the ahk-files in the same folder as the script.
It's an early release! I'm having trouble with GDI+, Vista won't always update the desktop, and it's lacking in functionality, but give it a try.
Skrommel
--- ---;DesktopDrawer.ahk
; Paint on your desktop
; Just run the script, paint using your mouse, press Esc to quit
; Requires Gdip.ahk from http://www.autohotkey.com/forum/topic32238.html
; and COM.ahk from http://www.autohotkey.com/forum/topic22923.html
;Skrommel @ 2008
#SingleInstance, Force
#NoEnv
SetBatchLines,-1
SetWorkingDir %A_ScriptDir%
SetWinDelay,0
applicationname=DesktopDrawer
START:
IniRead,penwidth,%applicationname%.ini,Settings,penwidth
IniRead,pencolor,%applicationname%.ini,Settings,pencolor
If penwidth=ERROR
penwidth=4
If pencolor=ERROR
pencolor=FF0000
wallpaperfile=wallpaper.bmp
drawingfile=drawing.png
If !pToken := Gdip_Startup()
{
MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
ExitApp
}
;GUI
Gui,1:Destroy
Gui,1:-Caption +E0x80000 +LastFound -AlwaysOnTop -ToolWindow +OwnDialogs
Gui,1:Show, NA
hwnd1:= WinExist()
width1:=A_ScreenWidth
height1:=A_ScreenHeight
hbm1 := CreateDIBSection(width1,height1)
hdc1 := CreateCompatibleDC()
obm1 := SelectObject(hdc1, hbm1)
pGraphic1 := Gdip_GraphicsFromHDC(hdc1)
;LOADWALLPAPER
RegRead,tile,HKEY_CURRENT_USER,Control Panel\Desktop,TileWallpaper
RegRead,style,HKEY_CURRENT_USER,Control Panel\Desktop,WallpaperStyle
RegRead,wallpaper,HKEY_CURRENT_USER,Control Panel\Desktop,WallPaper
RegRead,background,HKEY_CURRENT_USER,Control Panel\Colors,Background
If wallpaper=%A_Scriptdir%\%wallpaperfile%
{
IniRead,tile,%applicationname%.ini,Settings,tile
IniRead,style,%applicationname%.ini,Settings,style
IniRead,wallpaper,%applicationname%.ini,Settings,wallpaper
}
Else
{
background:=DECR_G_BTOHEXRGB(background)
IniWrite,%tile%,%applicationname%.ini,Settings,tile
IniWrite,%style%,%applicationname%.ini,Settings,style
IniWrite,%wallpaper%,%applicationname%.ini,Settings,wallpaper
}
width3 := A_ScreenWidth
height3 := A_ScreenHeight
pBitmap3 := Gdip_CreateBitmap(width3,height3)
pGraphic3 := Gdip_GraphicsFromImage(pBitmap3)
pBitmapFile3 := Gdip_CreateBitmapFromFile(wallpaper)
fileWidth3 := Gdip_GetImageWidth(pBitmapFile3)
fileHeight3 := Gdip_GetImageHeight(pBitmapFile3)
Gdip_SetSmoothingMode(pGraphic3, 4)
Gdip_SetInterpolationMode(pGraphic3, 7)
hBrush:= Gdip_BrushCreateSolid("0xFF" background)
Gdip_FillRectangle(pGraphic3, hBrush, 0, 0, width3, height3)
Gdip_DeleteBrush(hBrush)
If tile=1 ;tile
{
x:=-1*filewidth3
y:=0
Loop
{
x+=filewidth3
If (x>=A_ScreenWidth)
{
x:=0
y+=fileheight3
If (y>=A_ScreenHeight)
Break
}
Gdip_DrawImage(pGraphic3, pBitmapFile3, x, y, filewidth3, fileheight3, 0, 0, filewidth3, fileheight3)
}
}
Else
If style=2 ;stretch
Gdip_DrawImage(pGraphic3, pBitmapFile3, 0, 0, width3, height3, 0, 0, filewidth3, fileheight3)
Else ;center
Gdip_DrawImage(pGraphic3, pBitmapFile3, width3/2-filewidth3/2, height3/2-fileheight3/2, filewidth3, fileheight3, 0, 0, filewidth3, fileheight3)
Gdip_DisposeImage(pBitmapFile3)
Gdip_DrawImage(pGraphic1, pBitmap3, 0, 0, width3, height3, 0, 0, width3, height3)
;LOADDRAWING
width2 := A_ScreenWidth
height2 := A_ScreenHeight
pBitmap2 := Gdip_CreateBitmap(width2,height2)
pGraphic2 := Gdip_GraphicsFromImage(pBitmap2)
pBitmapFile2 := Gdip_CreateBitmapFromFile(drawingfile)
fileWidth2 := Gdip_GetImageWidth(pBitmapFile2)
fileHeight2 := Gdip_GetImageHeight(pBitmapFile2)
Gdip_SetSmoothingMode(pGraphic2, 4)
Gdip_SetInterpolationMode(pGraphic2, 7)
Gdip_DrawImage(pGraphic2, pBitmapFile2, 0, 0, fileWidth2, fileheight2, 0, 0, fileWidth2, fileHeight2)
Gdip_DisposeImage(pBitmapFile2)
Gdip_DrawImage(pGraphic1, pBitmap2, 0, 0, width2, height2, 0, 0, width2, height2)
hBrush:=Gdip_BrushCreateSolid("0xFF" pencolor)
hPen := Gdip_CreatePen("0xFF" pencolor, penwidth)
DllCall("gdiplus\GdipSetPenLineCap197819",UInt,hpen,UInt,2,UInt,2,UInt,0)
Loop,10
UpdateLayeredWindow(hwnd1, hdc1, 0, 0, width1, height1, 25*A_Index+5)
;TOOLBAR
Gui,4:Destroy
Gui,4:Margin,0,0
Gui,4:+LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
Gui,4:Font,C000000 S20,Wingdings
Loop,5
Gui,4:Add,Text,% "x+0 yp GPEN Vwidth_" A_Index*2,% Chr(0x8B+A_Index*2)
Gui,4:Add,Picture,xm w0 h0
colors=000000|FFFFFF|FF0000|00FF00|0000FF
Loop,Parse,colors,|
{
Gui,4:Font,C%A_LoopField% S24,Wingdings
Gui,4:Add,Text,x+0 GPEN Vcolor_%A_LoopField%,% Chr(0x6C)
}
Gui,4:Font,
Gui,4:Add,Edit,xm,
Gui,4:Add,Button,xm w40 Default GSAVE,&Save
Gui,4:Add,Button,x+0 w40 GEXIT,&Quit
Gui,4:Add,Button,x+0 w40 GCLEAR,&Clear
Gui,4:Show,x0 y0 NA
hwnd4:= WinExist()
OnMessage(0x201, "WM_LBUTTONDOWN")
OnExit,Exit
Return
PEN:
StringSplit,part_,A_GuiControl,_
If part_1=color
pencolor:=part_2
If part_1=width
penwidth:=part_2
Gdip_DeleteBrush(hBrush)
Gdip_DeletePen(hPen)
hBrush:=Gdip_BrushCreateSolid("0xFF" pencolor)
hPen := Gdip_CreatePen("0xFF" pencolor, penwidth)
DllCall("gdiplus\GdipSetPenLineCap197819",UInt,hpen,UInt,2,UInt,2,UInt,0)
IniWrite,%pencolor%,%applicationname%.ini,Settings,pencolor
IniWrite,%penwidth%,%applicationname%.ini,Settings,penwidth
Return
UPDATE(pBitmap,width,height,x=0,y=0)
{
Local empty
Gdip_DrawImage(pGraphic1, pBitmap, x, y, width, height, x, y, width, height)
UpdateLayeredWindow(hwnd1, hdc1, 0, 0, width1, height1)
}
SAVETOFILE:
Gdip_SaveBitmapToFile(pBitmap2, drawingfile)
Gdip_DrawImage(pGraphic3, pBitmap2, 0, 0, width3, height3, 0, 0, width3, height3)
UpdateLayeredWindow(hwnd3, hdc3, 0, 0, width3, height3)
Gdip_SaveBitmapToFile(pBitmap3, wallpaperfile)
RegWrite,REG_SZ,HKEY_CURRENT_USER,Control Panel\Desktop,TileWallpaper,0
RegWrite,REG_SZ,HKEY_CURRENT_USER,Control Panel\Desktop,WallpaperStyle,2
RegWrite,REG_SZ,HKEY_CURRENT_USER,Control Panel\Desktop,WallPaper,%A_Scriptdir%\%wallpaperfile%
Gosub,CHANGEWALLPAPER
Return
CLEANUP:
Gui,4:Destroy
Loop,10
UpdateLayeredWindow(hwnd1, hdc1, 0, 0, width1, height1, 255-A_Index*25-5)
SelectObject(hdc1, obm1)
DeleteObject(hbm1)
DeleteDC(hdc1)
Gdip_DeleteGraphics(pGraphic1)
Gdip_DeletePen(hPen)
Gdip_DeletePen(hBrush)
Gdip_DeleteGraphics(pGraphic2)
Gdip_DisposeImage(pBitmap2)
Gdip_DeleteGraphics(pGraphic3)
Gdip_DisposeImage(pBitmap3)
Gdip_Shutdown(pToken)
Return
CLEAR:
FileDelete,%A_ScriptDir%\%wallpaperfile%
FileDelete,%A_ScriptDir%\%drawingfile%
Gosub,CLEANUP
Goto,START
GuiEscape:
GuiClose:
SAVE:
Gosub,SAVETOFILE
EXIT:
Gosub,CLEANUP
ExitApp
WM_LBUTTONDOWN(wParam, lParam)
{
Local empty
mx:=lParam & 0xFFFF
my:=lParam >> 16
Gdip_FillEllipse(pGraphic1, hBrush, mx-penwidth/2, my-penwidth/2, penwidth, penwidth)
UpdateLayeredWindow(hwnd1, hdc1, 0, 0, width1, height1)
Gdip_FillEllipse(pGraphic2, hBrush, mx-penwidth/2, my-penwidth/2, penwidth, penwidth)
OnMessage(0x200, "WM_MOUSEMOVE")
OnMessage(0x202, "WM_LBUTTONUP")
}
WM_LBUTTONUP(wParam, lParam)
{
OnMessage(0x200, "") ;"WM_MOUSEMOVE"
OnMessage(0x202, "") ;"WM_LBUTTONUP"
}
WM_MOUSEMOVE(wParam, lParam)
{
Local empty
oldlbutton:=lbutton
GetKeyState,lbutton,LButton,P
If (lbutton="U")
Return
oldmx:=mx
oldmy:=my
mx:=lParam & 0xFFFF
my:=lParam >> 16
Gdip_DrawLine(pGraphic1, hPen, oldmx, oldmy, mx, my)
UpdateLayeredWindow(hwnd1, hdc1, 0, 0, width1, height1)
Gdip_DrawLine(pGraphic2, hPen, oldmx, oldmy, mx, my)
}
RGBTOBGR(rgb)
{
StringMid, prefix, rgb, 1, 2
offset=0
If (prefix="0x")
offset=2
Else
prefix=
StringMid, r, rgb,% 1+offset, 2
StringMid, g, rgb,% 3+offset, 2
StringMid, b, rgb,% 5+offset, 2
Return, prefix . b . g . r
}
DECR_G_BTOHEXRGB(rgb)
{
StringSplit,color_,rgb,%A_Space% ;Transform dec "R G B" to hex "RGB"
rgb=
Loop,% color_0
{
tempcolor:=color_%A_Index%
SetFormat,Integer,Hex
EnvAdd,tempcolor,0x100
SetFormat,Integer,Dec
StringRight,tempcolor,tempcolor,2
rgb=%rgb%%tempcolor%
}
Return,rgb
}
CHANGEWALLPAPER:
;Stolen from Sean at http://www.autohotkey.com/forum/topic16905.html
sFile = %A_Scriptdir%\%wallpaperfile%
sOpt := "STRETCH"
WPSTYLE_CENTER := 0
WPSTYLE_TILE := 1
WPSTYLE_STRETCH := 2
WPSTYLE_MAX := 3
COM_Init()
pad := COM_CreateObject("{75048700-EF1F-11D0-9888-006097DEACF9}", "{F490EB00-1240-11D1-9888-006097DEACF9}")
DllCall(NumGet(NumGet(1*pad)+28), "Uint", pad, "int64P", WPSTYLE_%sOpt%<<32|8, "Uint", 0) ; SetWallpaperOptions
/*
DllCall(NumGet(NumGet(1*pad)+24), "Uint", pad, "int64P", nOpt:=8, "Uint", 0); GetWallpaperOptions
RegExMatch("CENTER TILE STRETCH MAX", "(?:\w+\s+){" . nOpt>>32 . "}(?<OPTION>\w+\b)", WPSTYLE_)
MsgBox, % WPSTYLE_OPTION
*/
DllCall(NumGet(NumGet(1*pad)+20), "Uint", pad, "Uint", COM_Unicode4Ansi(wFile,sFile), "Uint", 0) ; SetWallpaper
DllCall(NumGet(NumGet(1*pad)+12), "Uint", pad, "Uint", 7) ; ApplyChanges
COM_Release(pad)
COM_Term()
Return
#Include Gdip.ahk
;Download from tic at http://www.autohotkey.com/forum/topic32238.html
#Include COM.ahk
;Download from Sean at http://www.autohotkey.com/forum/topic22923.html
jgpaiva:
skrommel: Looks like you found a forum limitation. Your post is too big. I tried adding the final closing to the quote tag and a spoiler tag, but it looks like the text can't get any bigger than that (and from what i understand, it didn't get the whole code you posted the first time). Maybe it's better for you to post it as an attachment.
PS: I just noticed i tried to edit it at the same time you were editing it too. Sorry!!
mouser:
skrommel for the love of god put this on your site and update your web page!
(and recompile your exes to solve the false positive antivirus alerts).
your fans demand it!!!
skrommel:
:-[ I'll get right on it, mouser!
Skrommel
kartal:
Btw I have found this free alternative. Nice thing about this is your drawings scribbles stays on top of you application.
http://www.screenmarker.com/
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version