NerdFencer Posted January 23, 2010 Share Posted January 23, 2010 (edited) This is a program that I wrote to surprise my girlfriend Victoria on Valentines day. Feel free to adapt it for your own significant other! Suggestions welcome http://autoclean.computersitter.com/Vday.zip It comes with a pre-compiled executable and batch files to install, uninstall, and force execution (it wont do anything unless its valentines day). The batch files just execute the program with command line options. The source is in the zip and below. expandcollapse popup#NoTrayIcon #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=VDay.ico #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_Run_Obfuscator=y #Obfuscator_Parameters=/SO #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.2.0 Author: Matthew McMullan Script Function: Valentines Day Script. #ce ---------------------------------------------------------------------------- #include <GDIPlus.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> ; =============================================================================================================================== ; Globals ; =============================================================================================================================== Global Const $AC_SRC_ALPHA = 1 Global $Himg[3] Global $minihearts[2][10] Global $ll, $lr ; =============================================================================================================================== ; Command Line Interpretation ; =============================================================================================================================== If $CmdLine[0] = 0 Then If @MON=="02" And @MDAY="14" Or Not(@Compiled) Then Main() EndIf ElseIf $CmdLine[1]=="/install" Then DirCreate(@ProgramFilesDir&"\Valentines Day\") FileCopy(@ScriptDir&"\valentine-heart-small.png",@ProgramFilesDir&"\Valentines Day\") FileCopy(@ScriptDir&"\valentine-heart-small-left.png",@ProgramFilesDir&"\Valentines Day\") FileCopy(@ScriptDir&"\valentine-heart-small-right.png",@ProgramFilesDir&"\Valentines Day\") FileCopy(@ScriptDir&"\VDgui.png",@ProgramFilesDir&"\Valentines Day\") FileCopy(@ScriptDir&"\Bryan Adams - When You Love Someone.mp3",@ProgramFilesDir&"\Valentines Day\") FileCopy(@ScriptFullPath,@ProgramFilesDir&"\Valentines Day\") RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run","Valentines Day","REG_SZ",@ProgramFilesDir&"\Valentines Day\"&@ScriptName) ElseIf $CmdLine[1]=="/uninstall" Then RegDelete("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run","Valentines Day") DirRemove(@ProgramFilesDir&"\Valentines Day\",1) DirRemove(@ProgramFilesDir&"\Valentines Day\",0) ElseIf $CmdLine[1]=="/force" Then Main() EndIf ; =============================================================================================================================== ; Here lies the romantic magic ; =============================================================================================================================== Func main() Init() SoundSetWaveVolume(100) SoundPlay(@ScriptDir&"\Bryan Adams - When You Love Someone.mp3") Local $gui = GUICreate("Valentines Day",811,750,-1,-1,-1,BitOR($WS_EX_LAYERED,$WS_EX_TOPMOST)) Local $guiimg = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\VDgui.png") SetBitMap($gui, $guiimg, 255) PopulateMiniHearts($gui) GUISetState(@SW_SHOW,$gui) Local $msg While 1 $msg = GUIGetMsg() Switch $msg Case -3 Exit EndSwitch Sleep(15) UpdateMiniHearts() WEnd Denit() EndFunc ; =============================================================================================================================== ; Determines the placement for a heart ; =============================================================================================================================== Func PlaceHeart(ByRef $last, $left, $right) Local $place = $last While $last-40<$place And $last+40>$place $place = Random($left,$right,1) WEnd $last = $place Return $place EndFunc ; =============================================================================================================================== ; Initialize the screen full of romantic hearts ; =============================================================================================================================== Func PopulateMiniHearts($gui) $ll = -300 $lr = -300 Local $left = (@DesktopWidth-811)/2 Local $right = (@DesktopWidth+811)/2-49 For $i=0 To 9 $minihearts[0][$i]=CreateOverlayGui(PlaceHeart($ll,0,$left),$i*((@DesktopHeight+63)/10),Random(0,2,1),$gui,"0"&$i) $minihearts[1][$i]=CreateOverlayGui(PlaceHeart($lr,$right,@DesktopWidth-49),$i*((@DesktopHeight+63)/10),Random(0,2,1),$gui,"1"&$i) Next EndFunc ; =============================================================================================================================== ; Make them bubble! ; =============================================================================================================================== Func UpdateMiniHearts() Local $pos For $i=0 To 9 For $j=0 To 1 $pos = WinGetPos($minihearts[$j][$i]) $pos[1]-=1 If $pos[1]<-63 Then $pos[1] = @DesktopHeight If $j=0 Then $pos[0]=PlaceHeart($ll,0,(@DesktopWidth-811)/2) Else $pos[0]=PlaceHeart($lr,(@DesktopWidth+811)/2,@DesktopWidth-49) EndIf EndIf WinMove($minihearts[$j][$i],"",$pos[0],$pos[1]) Next Next EndFunc ; =============================================================================================================================== ; Create overlay gui ; =============================================================================================================================== Func CreateOverlayGUI($x,$y,$img=-1,$master=-1,$title="OLgui") Local $retgui = GUICreate("OLgui",49,63,$x,$y,$WS_POPUP,$WS_EX_LAYERED,$master) If $img==-1 Then SetBitMap($retgui, $Himg[Random(0,2,1)], 128) Else SetBitMap($retgui, $Himg[$img], 128) EndIf GUISetState(@SW_SHOW,$retgui) Return $retgui EndFunc ; =============================================================================================================================== ; Initialize ; =============================================================================================================================== Func Init() ; Load layered image _GDIPlus_Startup() $Himg[0] = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\valentine-heart-small.png") $Himg[1] = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\valentine-heart-small-left.png") $Himg[2] = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\valentine-heart-small-right.png") EndFunc ; =============================================================================================================================== ; denit ; =============================================================================================================================== Func denit() ; Release resources _GDIPlus_ImageDispose($Himg[0]) _GDIPlus_ImageDispose($Himg[1]) _GDIPlus_ImageDispose($Himg[2]) _GDIPlus_Shutdown() EndFunc ; =============================================================================================================================== ; SetBitMap ; =============================================================================================================================== Func SetBitmap($hGUI, $hImage, $iOpacity) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize ) DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth ($hImage)) DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage)) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha" , $iOpacity ) DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC (0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC ($hMemDC) EndFunc It displays an image in the middle (semi-transparent) and has random hearts scrolling up the left and right sides. Update: Made the center text generic (Happy Valentines Day! I Love You!), fixed a display bug found by rogue5099, added a base heart image with no text (for easier customization), and merged the code into one source file. Edited February 5, 2010 by NerdFencer JiBe and argumentum 2 _________[u]UDFs[/u]_________-Mouse UDF-Math UDF-Misc Constants-Uninstaller Shell Link to comment Share on other sites More sharing options...
James Posted January 23, 2010 Share Posted January 23, 2010 That is lovely of you. Very sweet Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
1957classic Posted January 24, 2010 Share Posted January 24, 2010 Nice script.Thanks for sharing it. Link to comment Share on other sites More sharing options...
NerdFencer Posted January 24, 2010 Author Share Posted January 24, 2010 You're welcome I'm glad that other people are finding this useful _________[u]UDFs[/u]_________-Mouse UDF-Math UDF-Misc Constants-Uninstaller Shell Link to comment Share on other sites More sharing options...
blitzkrg Posted January 24, 2010 Share Posted January 24, 2010 $gfname = "insert name" Local $gui = GUICreate($gfname,811,750,-1,-1,-1,BitOR($WS_EX_LAYERED,$WS_EX_TOPMOST)) Don't want to get anyone in trouble thanks for sharing. Link to comment Share on other sites More sharing options...
SkellySoul Posted January 24, 2010 Share Posted January 24, 2010 It's an awesome script but why two scripts why not combine them? Link to comment Share on other sites More sharing options...
chaitanyagutala Posted January 26, 2010 Share Posted January 26, 2010 This is really a fentastic script dude. I was really surprised seeing it. starting from the song, the background, the shape,colour,,,,,, everything is good man fentastic. I am not a very big scripting guy like you but I have small doubt can you please help me out????? Thanks Link to comment Share on other sites More sharing options...
chaitanyagutala Posted January 26, 2010 Share Posted January 26, 2010 If you dont mind can you please tell me how to change victoria's name in the scrip.... I have tried but no use. So I am asking you now. Thanks Link to comment Share on other sites More sharing options...
BigDod Posted January 26, 2010 Share Posted January 26, 2010 If you dont mind can you please tell me how to change victoria's name in the scrip.... I have tried but no use. So I am asking you now.You have to edit VDgui.png or create your own. Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
chaitanyagutala Posted January 27, 2010 Share Posted January 27, 2010 Thank you very much. I ll try and get back to you. Thanks Link to comment Share on other sites More sharing options...
chaitanyagutala Posted January 28, 2010 Share Posted January 28, 2010 It is really working dude thank you very much. I tried of modifying VDgui.png and it worked. Thank you once again Thanks Link to comment Share on other sites More sharing options...
stinson6016 Posted February 3, 2010 Share Posted February 3, 2010 that's really cool, I have to say thumbs up! Gnatwork Networks Link to comment Share on other sites More sharing options...
Rogue5099 Posted February 4, 2010 Share Posted February 4, 2010 (edited) This works fine on my computer but once I force it on her computer it has little windows which the small hearts are in... me: Windows 7 (AutoIt installed, dunno if that makes a difference) her: windows vista I've tried editing: Func CreateOverlayGUI($x,$y,$img=-1,$master=-1,$title="OLgui") Local $retgui = GUICreate("OLgui",49,63,$x,$y,-1,$WS_EX_LAYERED,$master) If $img==-1 Then SetBitMap($retgui, $Himg[Random(0,2,1)], 128) Else SetBitMap($retgui, $Himg[$img], 128) EndIf GUISetState(@SW_SHOW,$retgui) Return $retgui EndFunc No luck, also I have tried it on XP and another windows 7 machine and it works fine it just her comp. Thinking I need to install something on her comp to get ti to work correctly.. Solution: (Changed -1 to $WS_POPUP) Func CreateOverlayGUI($x,$y,$img=-1,$master=-1,$title="OLgui") Local $retgui = GUICreate("OLgui",49,63,$x,$y,$WS_POPUP,$WS_EX_LAYERED,$master) If $img==-1 Then SetBitMap($retgui, $Himg[Random(0,2,1)], 128) Else SetBitMap($retgui, $Himg[$img], 128) EndIf GUISetState(@SW_SHOW,$retgui) Return $retgui EndFunc Edited February 4, 2010 by rogue5099 My projects: Inventory / Mp3 Inventory, Computer Stats Link to comment Share on other sites More sharing options...
Rogue5099 Posted February 4, 2010 Share Posted February 4, 2010 (edited) Attached is the Main heart that says "Happy Valentines Day". I edited the picture to say just "I love you." Instead of saying "I love you Victoria". Also I made all of the white background of the Image Transparent and changed the white letters to Red so they wouldn't be transparent as well. Just replace this file with the one you have currently to apply the change. By the way very nice script, opened up several options for the future for me. Edited February 4, 2010 by rogue5099 My projects: Inventory / Mp3 Inventory, Computer Stats Link to comment Share on other sites More sharing options...
NerdFencer Posted February 5, 2010 Author Share Posted February 5, 2010 Thanks for all the feedback I have updated the source and image to include rogue5099's fix and a couple of other things (see main post). _________[u]UDFs[/u]_________-Mouse UDF-Math UDF-Misc Constants-Uninstaller Shell Link to comment Share on other sites More sharing options...
Rogue5099 Posted February 5, 2010 Share Posted February 5, 2010 Very Nice additions: Never to place a heart in the same spot... Func PlaceHeart(ByRef $last, $left, $right) Local $place = $last While $last-40<$place And $last+40>$place $place = Random($left,$right,1) WEnd $last = $place Return $place EndFunc Also I like the whole heart being transparent, I tried this with WinSetTrans but was unsuccessfull. The Capital L and Y in "I Love You" does make a differnce!!! Last but not least changing the GUI window name was a good idea to not let us idiot guys get in trouble with some other girls name!! Glad I could be of some help. My projects: Inventory / Mp3 Inventory, Computer Stats Link to comment Share on other sites More sharing options...
smcombs Posted February 6, 2010 Share Posted February 6, 2010 I love this lol. Totally implementing. Link to comment Share on other sites More sharing options...
Jeff West Posted February 15, 2010 Share Posted February 15, 2010 This was a big hit with my wife. I modified my copy to wait until she typed "Valentine" in Facebook, then the hearts popped up and began to play "Keeper of the Stars" (our wedding song). Thank you for the script. --Jeff Link to comment Share on other sites More sharing options...
NerdFencer Posted February 15, 2010 Author Share Posted February 15, 2010 Glad to hear it worked out for you It worked wonderfully with my girlfriend as well -Matt _________[u]UDFs[/u]_________-Mouse UDF-Math UDF-Misc Constants-Uninstaller Shell Link to comment Share on other sites More sharing options...
Rogue5099 Posted February 15, 2010 Share Posted February 15, 2010 I modified mine as well for my wife. She has windows Vista and we all know how long it take vista to start up so she pushes power then walks off. I used _IsPressed to wait till she left clicked then it poped up and she loved it! Thanks NerdFencer My projects: Inventory / Mp3 Inventory, Computer Stats Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now