forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Open/Close Multiple CD tray Door
Goto page Previous  1, 2
 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Advanced VDS 5 Source Code
View previous topic :: View next topic  
Author Message
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1054
Location: India

PostPosted: Fri Jul 11, 2003 1:59 pm    Post subject: Reply with quote

Here is a Script to open/close multiple CD drives.
The app sits nicely in systray an is vey convenient for use - I think.
I have seen many commercial products like this. This one i give here with commented source code.
It is basically written for vds 5.x but i have added comments for use with lower vds versions.
Please let me know if U have any comments/suggestions.
Enjoy !.
Code:

#----------------------------------------------------------------------------#
#Calling a Non-VDs dll; OPEN/CLOSE ANY CD DRIVE TRAY-------------------------#
#Use Shift click and Ctrl click ---------------------------------------------#
#Author:  CodeScript---------------------------------------------------------#
#---------Thanx to Snarlingsheep and others for valuable suggestions---------#
#Copyright:You can remove this info while(if) Using this code in your app.---#
# Donot just compile this script as a standalone exe & use for sale/shareware#
# Use inside your app is perfectly OK----------------------------------------#
#----------U may add a word to your documentation if U wish------------------#
REM USE AT YOUR OWN RISK !!
REM MISTAKES MADE WHILE USING A NON VDS DLL MAY INVITE A VDS/SYSTEM CRASH.
REM SAVE YOUR WORK BEFORE RUNNING/DEBUGGING THIS SCRIPT.
REM AS SUCH THIS SCRIPT IS WRITTEN FOR VDS 5.x BUT U CAN EASILY MODIFY FOR 4.X
%w = @WINDIR()
  DIALOG CREATE,@CHR(32)@CHR(32)Open/close CD tray(s),445,625,161,100,CLASS CDWIN,smallcap,nomin,snap
REM SNAP STYLE SHOULD BE REMOVED BY VDS 4.X USERS
  DIALOG ADD,STYLE,STYLE1,Verdana,12,B,WHITE,BLACK
  DIALOG ADD,LIST,LIST2,10,10,60,80,,STYLE1,DBLCLICK
  DIALOG ADD,BUTTON,BUTTON1,10,82,66,34,Open
  DIALOG ADD,BUTTON,BUTTON2,54,82,66,34,Close
  DIALOG ADD,TASKICON,TaskIcon,%w\explorer.exe,Open/close CD tray
REM I HAVE PROVIDED THIS ICON SINCE IT EXISTS ON ALL COMPUTERS
REM CHANGE IT TO WHATEVER U WANT !
  DIALOG SHOW
  window hide,#CDWIN
  %%taskclick = 1
LOADLIB USER32
REM SET THESE VARIABLES TO ZERO TO PREVENT THEM FIRING NONSENSE ON LAUNCHING
  %M = @lib(user32,GetAsyncKeyState,int:,$11)
  %N = @lib(user32,GetAsyncKeyState,int:,$10)
  %M = 0
  %N = 0
 

LIST CREATE,1
LIST LOADTEXT,1
"A
"B
"C
"D
"E
"F
"G
"H
"I
"J
"K
"L
"M
"N
"O
"P
"Q
"R
"S
"T
"U
"V
"W
"X
"Y
"Z
%C = 0

:GETVALIDCDDRIVES
IF @equal(%C,@count(1))
 goto SET
 end
List seek,1,%C
%%drive = @volinfo(@item(1),T)
 IF @EQUAL(CD-ROM,%%drive)
 LIST ADD,LIST2,@item(1)
end
%C = @succ(%C)
goto GETVALIDCDDRIVES

:SET
REM THIS IS TO SET THE DEFAULT - FIRST- CD DRIVE AS ACTIVE
%C = @sendmsg(@win(~LIST2),$0201,0,0)
%C = @sendmsg(@win(~LIST2),$0202,0,0)
goto EVLOOP
     
:EVLOOP
wait event,0.08
goto @event()

:TIMER
REM KEEP CHECKING IN A LOOP WHETHER cTRL/SHIFT KEY WAS PRESSED
REM ALTHOUGH IT IS POSSIBLE TO DO AWAY WITH THIS THE KEY PRESS EVENTS
REM IN BETWWEN MAY CAUSE WRONG FIRING OF EVENTS
REM THIS LOOP WILL RESET ALL BUT THE LAST KEY PRESS EVENT
REM IF U HAVE A BETTER IDEA LET ME KNOW
  %M = @lib(user32,GetAsyncKeyState,int:,$11)
  %N = @lib(user32,GetAsyncKeyState,int:,$10)
    goto EVLOOP

:TaskIconCLICK
   if @equal(@click(b),RIGHT)
     dialog popup,Hide|Show|-|Exit
     else
     goto Check
     end
    goto EVLOOP
   
:check
REM CheckIF USER SHIFT OR CTRL CLICKED
REM CTRL CLICK - SO OPEN THE DEFAULT CD DOOR
REM VDS 4.X USERS MAY USE HOTKEY/KEY STATE DLLS HERE TO GET
REM SOMEWHAT SIMILAR FUNCTIONALITY.
IF @NOT(@equal(%M,0))
 goto BUTTON1BUTTON
 end
REM SHIFT CLICK - SO CLOSE THE DEFAULT CD DOOR
IF @NOT(@equal(%N,0))
 goto BUTTON2BUTTON
 end
REM USER HAS SIMPLY CLICKED -NO CTRL/SHIFT CLICK SO
REM CHECK THE WINDOW STATUS USING A VARIABLE AND TOGGLE WINDOW ACCORDINGLY
IF @EQUAL(%%taskclick,0)
 %%taskclick = 1
 goto hideMenu
  ELSE
 %%taskclick = 0
 goto ShowMENU
 END

:HideMENU
window hide,#CDWIN
goto EVLOOP

:ShowMENU
REM THIS DLL FUNCTION SETS THE Z ORDER OF THE WINDOW TO TOP - NOT ONTOP
REM THIS HELPS TO BRING THE WINDOW UP EVEN IF OBSCURE BY OTHER WINDOWS
REM VDS 4.X USERS MAY REMOVE THIS FOR COMPATABILTY
%H = @strdel(@WINEXISTS(#CDWIN),1,1)
if %H
 %H = @lib(user32,SetForegroundWindow,BOOL:,%H)
   else
    ERROR -1
  end
  END
window normal,#CDWIN
goto EVLOOP


:LIST2DBLCLICK
%%taskclick = 1
window hide,#CDWIN
REM HERE AGAIN IF USERS HOLDS SHIFT AND DOUBLE CLICKS CD TRAY WILL CLOSE !
IF @NOT(@equal(%N,0))
 goto BUTTON2BUTTON
 end
%%drive = @item(LIST2)
%I = @MCI(Open %%drive: Alias Drive%%drive Type CDAudio)
%I = @MCI(Set Drive%%drive  Door Open)
REM THIS IS TO SET THE DEFAULT - FIRST- CD DRIVE AS ACTIVE
REM IF U WANT INSTEAD TO KEEP THE LAST ACCESSED DRIVE AS DEFAULT
REM FOR THE NEXT USE REMOVE THESE TWO LINES FROM EACH OF THE BUTTONS AND BELOW
%C = @sendmsg(@win(~LIST2),$0201,0,0)
%C = @sendmsg(@win(~LIST2),$0202,0,0)
goto EVLOOP

:BUTTON1BUTTON
%%taskclick = 1
window hide,#CDWIN
%%drive = @item(LIST2)
%I = @MCI(Open %%drive: Alias Drive%%drive Type CDAudio)
%I = @MCI(Set Drive%%drive  Door Open)
REM THIS IS TO SET THE DEFAULT - FIRST- CD DRIVE AS ACTIVE
%C = @sendmsg(@win(~LIST2),$0201,0,0)
%C = @sendmsg(@win(~LIST2),$0202,0,0)
goto EVLOOP

:BUTTON2BUTTON
%%taskclick = 1
window hide,#CDWIN
%%drive = @item(LIST2)
%I = @MCI(Open %%drive: Alias Drive%%drive Type CDAudio)
%I = @MCI(Set Drive%%drive  Door Closed)
REM THIS IS TO SET THE DEFAULT - FIRST- CD DRIVE AS ACTIVE
%C = @sendmsg(@win(~LIST2),$0201,0,0)
%C = @sendmsg(@win(~LIST2),$0202,0,0)
goto EVLOOP

:close
window hide,#CDWIN
goto Evloop

:EXITMENU
REM DONT FORGET TO UNLOAD THE USER32.DLL WE CALLED
FREELIB USER32
Exit

_____________________________________________________________________________________

_________________
Regards
- CodeScript
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1054
Location: India

PostPosted: Fri Jul 11, 2003 5:20 pm    Post subject: Reply with quote

I forgot to mention about hotkey stuff:
To open default (first) CD tray hold down Ctrl and Left click tray icon.
To close default CD tray hold down Shift and Left click tray icon.
To close a tray hold down shift and double click the drive letter in list.

_________________
Regards
- CodeScript
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Advanced VDS 5 Source Code All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum




Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group