Sign in to follow this  
Followers 0
Jannick

Disable autoplay by pressing shift or...?

12 posts in this topic

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

Share this post


Link to post
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!

Share this post


Link to post
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.



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

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

Share this post


Link to post
Share on other sites

whoo, thx for the fast answers

the shiftdown does the trick. Thankx!!! I was working with the lshift but this is much better.

;-)

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I seek the same answer as to the original question.

Has anyone managed to do it without using keystrokes??

Edited by Rick

Who needs puzzles when we have AutoIt!!

Share this post


Link to post
Share on other sites

I seek the same answer as to the original question.

Has anyone managed to do it without using keystrokes??

registry is definitely the way to go IMHO

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

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!!

Share this post


Link to post
Share on other sites

any help would be appreciated


Who needs puzzles when we have AutoIt!!

Share this post


Link to post
Share on other sites

any help would be appreciated

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

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

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!!

Share this post


Link to post
Share on other sites

thanks Larry, youre a star


Who needs puzzles when we have AutoIt!!

Share this post


Link to post
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
Sign in to follow this  
Followers 0