AutoHotkey Community

It is currently May 25th, 2012, 4:55 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 13 posts ] 
Author Message
PostPosted: May 11th, 2007, 5:29 pm 
Offline

Joined: March 6th, 2007, 4:35 pm
Posts: 64
Location: Columbus, OH, USA
I know you can just do this with windows settings, but is there a way to stop auto-run and auto-play from auto-running with autohotkey?

For instance, I want to run a script on another person's computer before I put in a CD. Windows Explorer is set to automatically open to the CD drive. I don't want that to happen.

No idea where to start on this one... any help would be appreciated.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 11th, 2007, 6:49 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8647
Location: Salem, MA
do you have control over what's on the CD? you can create an autorun.inf in the root of it, and configure it to not do anything.

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 11th, 2007, 7:05 pm 
Offline

Joined: March 6th, 2007, 4:35 pm
Posts: 64
Location: Columbus, OH, USA
No, unfortunately there is no control of the CD content, otherwise that would be a great way to do it...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 12th, 2007, 1:02 pm 
Offline

Joined: December 1st, 2006, 9:27 am
Posts: 460
Give this a try. It stops the autorun by pressing "Shift" for ten seconds when it detects the CD insertion. Based on the code here. There is probably a better way, but this works.
Code:
#Persistent
OnMessage(0x219, "notify_change")
Return

notify_change(wParam, lParam, msg, hwnd)
{
   ;MsgBox, %wParam% %lParam% %msg% %hwnd%
   if wParam = 32768
   {   ;msgbox, Disc Inserted
      Send,{Shift down}
      SetTimer,tipper,100
      SetTimer,killshift,10000
   }
}

tipper:
   ToolTip,Preventing Autorun
Return

killshift:
   SetTimer,tipper,Off
   SetTimer,killshift,Off
   Send,{Shift up}
   ToolTip
Return

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 12th, 2007, 6:35 pm 
Offline

Joined: March 6th, 2007, 4:35 pm
Posts: 64
Location: Columbus, OH, USA
@Micahs - That was brilliant! I remember reading that "shift" key trick when inserting a CD, but of course, I never would have remembered it when I needed it!

It would be still be nice to know if there is a "proper" way of doing this, but Micahs saved the day, thanks!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 13th, 2007, 3:56 am 
Offline

Joined: December 1st, 2006, 9:27 am
Posts: 460
I did some checking and there is a better way to do this - using the "QueryCancelAutoPlay" message, but it requires your script to have the focus for it to work. If your script is running in the background it won't work.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 13th, 2007, 9:44 pm 
Offline

Joined: May 13th, 2007, 5:40 pm
Posts: 47
Regedit HKEY_LOCAL_MACHINE> SYSTEM> CurrentControlSet>Services> Cdrom and change the AutoRun value from 1 to 0.

Image

This probably isnt whatcha need, but figured Id post it up none the less.

Cheers


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 14th, 2007, 2:03 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8775
Code:
#Persistent
Gui +AlwaysOnTop
SetFormat, Integer, Hex

lpStr  := "QueryCancelAutoPlay"
MsgNo  := DllCall( "RegisterWindowMessage", UInt, &lpStr )
; MsgNo will be a message identifier in the range 0xC000 through 0xFFFF

OnMessage( MsgNo, "QCAP" )

Gui, Add, Text, w150 h25 +0x201 +Border     , Awaiting : %MsgNo%
Gui, Add, Text, w150 h25 +0x201 +Border vMsg

Gui, Show, , Auto-Play Cancellation
Return

QCAP( wParam, lParam, msg, hwnd ) {
  GuiControl,, Msg, Received : %Msg%
  Return True
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 14th, 2007, 7:06 pm 
Offline

Joined: March 6th, 2007, 4:35 pm
Posts: 64
Location: Columbus, OH, USA
@Skan-
Thanks, I knew you would be around with the answer! That is great stuff.

--

I am trying to make sense of it all still, and I think most of it I understand... However, it appears when I get rid of the GUI, it now longer stops auto-run, and the Explorer window opens.

Is there a way to do this without the GUI? I must be missing something...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 14th, 2007, 9:12 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8775
elchapin wrote:
Is there a way to do this without the GUI? I must be missing something...


No! Not with QueryCancelAutoPlay! Maybe Micahs method or we have to meddle with the registry, AFAIK.

Why not use a GUI ? You can make it so small that it will never be noticed.

Code:
#Persistent
Gui -Caption +AlwaysOnTop

lpStr  := "QueryCancelAutoPlay"
MsgNo  := DllCall( "RegisterWindowMessage", UInt, &lpStr )
OnMessage( MsgNo, "QCAP" )
OnMessage(0x219, "Notify_Change")

Return

Notify_Change(wParam, lParam, msg, hwnd) {
IfEqual, wParam, 32768, Gui, Show, x0 y0 w1 h1
}

QCAP( wParam, lParam, msg, hwnd ) {
  Gui, Hide
  Return True
}


In that code, I would use an appropriate icon to fully fit into the GUI.

:)


Report this post
Top
 Profile  
Reply with quote  
 Post subject: thanks, skan!
PostPosted: May 14th, 2007, 10:06 pm 
Offline

Joined: March 6th, 2007, 4:35 pm
Posts: 64
Location: Columbus, OH, USA
@Skan- That's a good tip to just make the GUI small, or just let the GUI stay visible... I did like that little layout of yours anyway. Cool.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: autohotkey autorun
PostPosted: November 27th, 2010, 10:32 am 
hallo guys,
i'm programming simple scripts with autohotkey.
does anyone know how to autorun a .ahk file?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 28th, 2010, 2:03 am 
Offline

Joined: December 1st, 2006, 9:27 am
Posts: 460
Hey there and welcome! In the future, it's probably better to start a new thread instead of resurrecting an old one for a new question.

That said, try something like creating a shortcut to autohotkey.exe and adding the path to your ahk file after it.

Image

You could put that shortcut in your startup folder.
HTH

_________________
Image


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: 0x150||ISO, Cerberus, patgenn123, poserpro and 32 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