AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Customised Autorun?

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
geoff



Joined: 16 Nov 2006
Posts: 10

PostPosted: Sun Dec 17, 2006 9:12 pm    Post subject: Customised Autorun? Reply with quote

Hello all,

I am wondering if this is possible.

I want a script that will detect when a CD is inserted into the drive, and once it detects, automatically run a command line parameter (in this case, I want it to automatically copy the whole CD to the HD). The script sleeps until I eject the CD and put a new one in and then it repeats the process.

Is this possible?
Back to top
View user's profile Send private message
Jon



Joined: 28 Apr 2004
Posts: 350

PostPosted: Sun Dec 17, 2006 9:55 pm    Post subject: Reply with quote

Here is a starting point for you-

Code:
OnMessage(0x219, "notify_change")
Return

notify_change(wParam, lParam, msg, hwnd)
{
;MsgBox, %wParam% %lParam% %msg% %hwnd%

if wParam = 32768
  msgbox, CD Inserted

}


It displays a message box when a CD is inserted.
Back to top
View user's profile Send private message Send e-mail
geoff



Joined: 16 Nov 2006
Posts: 10

PostPosted: Tue Dec 19, 2006 2:19 am    Post subject: Reply with quote

Thank you, but for some reason this script does nothing on my laptop.

Any ideas?
Back to top
View user's profile Send private message
Jon



Joined: 28 Apr 2004
Posts: 350

PostPosted: Tue Dec 19, 2006 2:34 am    Post subject: Reply with quote

salvius wrote:
Thank you, but for some reason this script does nothing on my laptop.

Any ideas?


I tried it on several computers and the only time it never worked was on a DVD drive (although I'm not sure if the drive was functioning correctly).

Try un-commenting the MsgBox line and then when you put a CD in check what the wParam is. Then change the IF statement accordingly.
Back to top
View user's profile Send private message Send e-mail
Jon



Joined: 28 Apr 2004
Posts: 350

PostPosted: Tue Dec 19, 2006 12:07 pm    Post subject: Reply with quote

If you are still having trouble, here is another method-

Code:
detect:

DriveGet, FS, FileSystem, D:

If FS = CDFS   ;If the FileSystem of the D Drive is that of a CD
{
  msgbox, CD In Drive
}

loop
{
DriveGet, FS, FileSystem, D:

  If FS = CDFS
    sleep, 5000
  else
  {
   sleep, 5000
   goto, detect
  }
}


It is a modification of theCD autorun script that I wrote ages ago.
Back to top
View user's profile Send private message Send e-mail
SKAN



Joined: 26 Dec 2005
Posts: 7184

PostPosted: Tue Dec 19, 2006 12:33 pm    Post subject: Reply with quote

Jon wrote:
I tried it on several computers and the only time it never worked was on a DVD drive (although I'm not sure if the drive was functioning correctly).


FYI: Your code works fine with my DVD-Writer -> detects DVD / CD

Smile
_________________
Suresh Kumar A N
Back to top
View user's profile Send private message
toralf



Joined: 31 Jan 2005
Posts: 3906
Location: Bremen, Germany

PostPosted: Thu Apr 19, 2007 11:47 pm    Post subject: Reply with quote

Jons script works on my laptop with a DVD Writer too.

How can I get the drive letter from the Message parameters?
Quote:
CD Inserted
wParam := 32768
lParam := 8977408
msg := 0x219
hwnd := 0x40652
The message 0x219 is actually WM_DEVICECHANGE
_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
SKAN



Joined: 26 Dec 2005
Posts: 7184

PostPosted: Fri Apr 20, 2007 3:14 am    Post subject: Reply with quote

Dear toralf, Smile

Quote:
How can I get the drive letter from the Message parameters?


Here: http://www.autohotkey.com/forum/viewtopic.php?p=98203#98203

Regards, Smile
Back to top
View user's profile Send private message
toralf



Joined: 31 Jan 2005
Posts: 3906
Location: Bremen, Germany

PostPosted: Fri Apr 20, 2007 11:10 am    Post subject: Reply with quote

Thanks a lot Skan. Absolutely what I was looking for. Should have done a search, sorry.
_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
openextremeconsole



Joined: 20 Oct 2008
Posts: 7
Location: Illinois

PostPosted: Mon Oct 20, 2008 8:08 pm    Post subject: Thank you Reply with quote

This is what I was looking for.

Only instead of messaging me that there is a CD in the drive, I'll modify it to launch another script, one that checks if the disc in the drive is a game in my database. If it is AND it's uninstalled, then it will launch a script that auto-installs the game and then launches it. If it IS already installed, it just launches the game. And now the PC acts like a console.

Couple this functionality with a media center and a PVR, and I have the ultimate HTPC, including PC gaming at the insertion of a disc.

openextreme.crashandthefury.com

Any of you brilliant coders want a challenge, head over there, see what we're up to, and post in the forums any ideas you have to make things more efficient or even to add functionality I haven't thought of yet.

BTW, the message box DOES come up, but so does an explorer window to show me the files on the disc. Anyway to suppress than in XP SP2?
_________________
openextreme.crashandthefury.com
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group