AutoHotkey Community

It is currently May 27th, 2012, 8:01 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Customised Autorun?
PostPosted: December 17th, 2006, 9:12 pm 
Offline

Joined: November 16th, 2006, 3:40 pm
Posts: 10
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 17th, 2006, 9:55 pm 
Offline

Joined: April 28th, 2004, 1:12 pm
Posts: 349
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 19th, 2006, 2:19 am 
Offline

Joined: November 16th, 2006, 3:40 pm
Posts: 10
Thank you, but for some reason this script does nothing on my laptop.

Any ideas?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 19th, 2006, 2:34 am 
Offline

Joined: April 28th, 2004, 1:12 pm
Posts: 349
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 19th, 2006, 12:07 pm 
Offline

Joined: April 28th, 2004, 1:12 pm
Posts: 349
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 19th, 2006, 12:33 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
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

:)

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 19th, 2007, 11:47 pm 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
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
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 20th, 2007, 3:14 am 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Dear toralf, :)

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


Here: http://www.autohotkey.com/forum/viewtop ... 8203#98203

Regards, :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 20th, 2007, 11:10 am 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
Thanks a lot Skan. Absolutely what I was looking for. Should have done a search, sorry.

_________________
Ciao
toralf
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Thank you
PostPosted: October 20th, 2008, 8:08 pm 
Offline

Joined: October 20th, 2008, 7:54 pm
Posts: 7
Location: Illinois
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


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], bobbysoon, BrandonHotkey, just me and 76 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group