Jannick Posted November 2, 2005 Share Posted November 2, 2005 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 More sharing options...
CyberSlug Posted November 2, 2005 Share Posted November 2, 2005 ;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 More sharing options...
BigDod Posted November 2, 2005 Share Posted November 2, 2005 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,JannickI cant find any other way exceptSend("{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 More sharing options...
Jannick Posted November 2, 2005 Author Share Posted November 2, 2005 whoo, thx for the fast answers the shiftdown does the trick. Thankx!!! I was working with the lshift but this is much better. ;-) Link to comment Share on other sites More sharing options...
LxP Posted November 3, 2005 Share Posted November 3, 2005 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. expandcollapse popupOption 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 More sharing options...
Rick Posted March 2, 2006 Share Posted March 2, 2006 (edited) I seek the same answer as to the original question. Has anyone managed to do it without using keystrokes?? Edited March 2, 2006 by Rick Who needs puzzles when we have AutoIt!! Link to comment Share on other sites More sharing options...
seandisanti Posted March 3, 2006 Share Posted March 3, 2006 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 Link to comment Share on other sites More sharing options...
Rick Posted March 3, 2006 Share Posted March 3, 2006 (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 March 3, 2006 by Rick Who needs puzzles when we have AutoIt!! Link to comment Share on other sites More sharing options...
Rick Posted March 3, 2006 Share Posted March 3, 2006 any help would be appreciated Who needs puzzles when we have AutoIt!! Link to comment Share on other sites More sharing options...
seandisanti Posted March 3, 2006 Share Posted March 3, 2006 any help would be appreciatedCS posted the necessary keys and code in the second post on this thread... Link to comment Share on other sites More sharing options...
Rick Posted March 3, 2006 Share Posted March 3, 2006 (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 March 3, 2006 by Rick Who needs puzzles when we have AutoIt!! Link to comment Share on other sites More sharing options...
Rick Posted March 3, 2006 Share Posted March 3, 2006 thanks Larry, youre a star Who needs puzzles when we have AutoIt!! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now