Jump to content

Disable autoplay by pressing shift or...?


Jannick
 Share

Recommended Posts

It doesn't seem easy but im trying to create a script that disables the autoplayfunction (temporarily) on win2000,winxp home and pro. I don't want to restart the pc. I know it should be possible because there are applications that can do this (like tweak xp from m$)

After comparing registers (before and after disable) i was thinking of the most obvious. Keep pressing shift while inserting the cd/dvd.

I found an autoitsetoption (SendKeyDelay and SendKeyDownDelay) but im not able to keep the shift key pressed all the time. Anyone?

If anyone has a more ellegant method, i would gladly hear about it.

tnx,

Jannick

Link to comment
Share on other sites

;If you have Admin priviliges, you can update the registry key

; but it might require ProcessClose("explorer.exe") in order for the change to take effect

;Disable AutoPlay:

RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer","NoDriveTypeAutoRun","REG_DWORD",0xB1)

;Enable AutoPlay:

RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer","NoDriveTypeAutoRun","REG_DWORD",0x91)

;Might also work

$cd_drive = "E:" ;change as needed; you could use the DriveGetType function to find the CD drive letter.....

Send("{ShiftDown}")

Do

sleep(10)

Until DriveStatus($cd_drive) = "READY"

Send("{ShiftDown}")

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

It doesn't seem easy but im trying to create a script that disables the autoplayfunction (temporarily) on win2000,winxp home and pro. I don't want to restart the pc. I know it should be possible because there are applications that can do this (like tweak xp from m$)

After comparing registers (before and after disable) i was thinking of the most obvious. Keep pressing shift while inserting the cd/dvd.

I found an autoitsetoption (SendKeyDelay and SendKeyDownDelay) but im not able to keep the shift key pressed all the time. Anyone?

If anyone has a more ellegant method, i would gladly hear about it.

tnx,

Jannick

I cant find any other way except

Send("{SHIFTDOWN}")
Sleep(2000); adjustable
Send("{SHIFTUP}")

Sorry i did not come up with anything better.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

Welcome to the forums!

Might anyone be interested in converting this VB code? It demonstrates how to temporarily disable AutoRun without sending keys or modifying the registry.

Option Explicit

Private Declare Function RegisterWindowMessage _
   Lib "user32" Alias "RegisterWindowMessageA" _
   (ByVal lpString As String) As Long
Private Const RegMsg As String = _
   "QueryCancelAutoPlay"

Private m_RegMsg As Long

Private Sub Check1_Click()
   With Check1  'Style = 1 - Graphical
   If .Value = vbChecked Then
      .Caption = "Release to Allow AutoPlay"
   Else
      .Caption = "Depress to Suppress AutoPlay"
   End If
   End With
End Sub

Private Sub Form_Load()
   Check1.Value = vbChecked
   ' Determine custom message value, and 
   ' hook message stream of this form.
   m_RegMsg = RegisterWindowMessage(RegMsg)
   Call HookWindow(Me.hWnd, Me)
End Sub

Private Sub Form_Unload(Cancel As Integer)
   Call UnhookWindow(Me.hWnd)
End Sub

Friend Function WindowProc(hWnd As Long, _
   msg As Long, wp As Long, lp As Long) As Long
   Dim Result As Long
   Select Case msg
      Case m_RegMsg ' QueryCancelAutoPlay
         ' TRUE: cancel AutoRun 
         ' *must* be 1, not -1!
         ' FALSE: allow AutoRun
         Result = Check1.Value

      Case Else
         ' Pass along to default window procedure.
         Result = InvokeWindowProc( _
            hWnd, msg, wp, lp)
   End Select
   ' Return desired result code to Windows.
   WindowProc = Result
End Function
Link to comment
Share on other sites

  • 3 months later...

Well thats obvious! doh!! So has anyone found where Windows writes what to where when "Take No action" is ticked if Blank cd , so we can do it in AutoIt, do stuff, then put it back to what it was????

ie: i can figure out how to build the values of the registry entries, but i need to know what value names are written where.

Edited by Rick

Who needs puzzles when we have AutoIt!!

Link to comment
Share on other sites

CS posted the necessary keys and code in the second post on this thread...

well yes, alas not all, if you try it you'll see that explorer needs to be crashed out or the pc restarted, there must be a better way

Edited by Rick

Who needs puzzles when we have AutoIt!!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...