CD Autorun example
Posted: Sat Jun 24, 2006 3:24 pm
Here a small CD Autorun.
Source code + image here: DOWNLOAD
Regards
Code: Select all
; ------------------------------------------------------------------
;
; CD Autorun
; Version: 1.0
; PureBasic Version: 3.94
;
; Author: Oridan
; Date: 24/06/2006
;
; ------------------------------------------------------------------
;
;- Get Current Directory
CurrentDirectory$=Space(255)
GetCurrentDirectory_(255,@CurrentDirectory$)
If Right(CurrentDirectory$,1)<>"\":CurrentDirectory$+"\":EndIf
InitSound()
CatchSound(0,?IB1)
CatchSound(1,?IB3)
;- Fonts
Global FontID1
FontID1 = LoadFont(1, "Tahoma", 8)
;- Image Plugins
;- Image Globals
Global Image0
;- Catch Images
Image0 = CatchImage(0, ?Image0)
;- Images
DataSection
Image0:
IncludeBinary "BackGround.bmp"
EndDataSection
Procedure HotSpot()
Shared Cursor, Sound
Select ChildWindowFromPoint_(WindowID(0),WindowMouseX(),WindowMouseY())
Case GadgetID(2)
SetCursor_(Cursor)
If Sound = 1
StopSound(1)
Else
PlaySound(1,0)
Sound = 1
EndIf
Case GadgetID(3)
SetCursor_(Cursor)
If Sound = 1
StopSound(1)
Else
PlaySound(1,0)
Sound = 1
EndIf
Case GadgetID(4)
SetCursor_(Cursor)
If Sound = 1
StopSound(1)
Else
PlaySound(1,0)
Sound = 1
EndIf
Case GadgetID(1)
Sound = 0
EndSelect
EndProcedure
Procedure WindowMain()
If OpenWindow(0, 333, 135, 506, 286, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered , "Nero Burning ROM 7.2.0.3b - [ CD Autorun by Oridan ]")
;SetWindowPos_(WindowID(),#HWND_TOPMOST,0,0,0,0,#SWP_NOMOVE|#SWP_NOSIZE)
If CreateGadgetList(WindowID())
ButtonGadget(2, 20, 180, 240, 25, "Install Nero Burning ROM 7.2.0.3b")
SetGadgetFont(2, FontID1)
ButtonGadget(3, 20, 215, 240, 25, "Browse CD...")
SetGadgetFont(3, FontID1)
ButtonGadget(4, 20, 250, 240, 25, "Exit")
SetGadgetFont(4, FontID1)
ImageGadget(1, 0, 0, 492, 286, Image0)
SetWindowLong_(GadgetID(1), #GWL_STYLE, GetWindowLong_(GadgetID(1), #GWL_STYLE) | #WS_CLIPSIBLINGS)
EndIf
EndIf
EndProcedure
Cursor = LoadCursor_(0, #IDC_HAND)
WindowMain()
Repeat
Stop:
Event = WaitWindowEvent()
WindowID = EventWindowID()
GadgetID = EventGadgetID()
EventType = EventType()
HotSpot()
If Event = #PB_EventGadget
If GadgetID = 2
PlaySound(0,0)
If RunProgram(CurrentDirectory$+"YourFolder\YourProgram.exe","","",0) ; Run EXE
Else
Goto Stop
EndIf
EndIf
If GadgetID = 3
RunProgram(CurrentDirectory$,"","",0) ; Browse CD...
PlaySound(0,0)
EndIf
If GadgetID = 4 ; Exit
PlaySound(0,0)
End
EndIf
EndIf
Until Event = #PB_Event_CloseWindow
PlaySound(0,0)
DestroyCursor_(Cursor)
End
;- Include sound file binary
IB1:
IncludeBinary "click.wav"
IB2:
IB3:
IncludeBinary "over.wav"
IB4:
Regards
