Page 1 of 1
Disabling of CD autorun. TEMPORARY. [Resolved]
Posted: Sun Sep 02, 2007 7:35 am
by Michael Korolev
Shit, I have this problem.
It is necessary, that at insert of a CD there was no autorun window. But don't disable it from registry, that requires system restart. I need to disable autorun temporarily, while my program is running...
At first I thought, that by PostMessage_() I have to send SHIFT pressing to Explorer. Stupid. After Googling I found that this event is processed by OS, not by explorer just

.
Where I need to send this message? Or there is another way?
Posted: Sun Sep 02, 2007 9:03 am
by Trond
Posted: Sun Sep 02, 2007 12:20 pm
by Michael Korolev
WTF? And how I can translate it to PB? What a stupid programming language... Dear Bill Gates, it was necesary to do it so difficult to understand???
Posted: Sun Sep 02, 2007 1:46 pm
by bingo
http://msdn2.microsoft.com/en-us/library/aa969329.aspx
Code: Select all
Global QueryCancelAutoPlay.l
Procedure.l WindowCallback(hwnd,message,wparam,lparam)
result.l=#PB_ProcessPureBasicEvents
Select message
Case QueryCancelAutoPlay
Debug "block autoplay ..."
result=1
EndSelect
ProcedureReturn result
EndProcedure
If OpenWindow(0, 0, 0, 222, 200, "ButtonGadgets", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
StickyWindow(0,1)
QueryCancelAutoPlay = RegisterWindowMessage_("QueryCancelAutoPlay")
ButtonGadget(0, 10, 10, 200, 20, "Standard Button")
ButtonGadget(1, 10, 40, 200, 20, "Left Button", #PB_Button_Left)
ButtonGadget(2, 10, 70, 200, 20, "Right Button", #PB_Button_Right)
ButtonGadget(3, 10,100, 200, 60, "Multiline Button (längerer Text wird automatisch umgebrochen)", #PB_Button_MultiLine)
ButtonGadget(4, 10,170, 200, 20, "Toggle Button", #PB_Button_Toggle)
SetWindowCallback(@WindowCallback())
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf

Disabling of CD autorun. TEMPORARY. [Resolved]
Posted: Sun Sep 02, 2007 7:47 pm
by Michael Korolev
Thanks guys, all works correct.
Posted: Mon Sep 03, 2007 4:07 pm
by Michael Korolev
Hmm.. that way works not always
More exact way:
Code: Select all
keybd_event_(#VK_SHIFT,0,0,0)
Delay(10000)
keybd_event_(#VK_SHIFT,0,#KEYEVENTF_KEYUP,0)
Works great

Posted: Mon Sep 03, 2007 10:18 pm
by eJan
I was playing with..
Code: Select all
Global QueryCancelAutoPlay.l
Procedure.l WindowCallback(hwnd, message, wparam, lparam)
result.l = #PB_ProcessPureBasicEvents
Select message
Case QueryCancelAutoPlay
;Debug "block autoplay ..."
AddGadgetItem(0, 1, "QueryCancelAutoPlay Processed")
result = 1
EndSelect
ProcedureReturn result
EndProcedure
If OpenWindow(0, 0, 0, 220, 200, "QueryCancelAutoPlay", #PB_Window_MinimizeGadget|#PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
StickyWindow(0, 1)
QueryCancelAutoPlay = RegisterWindowMessage_("QueryCancelAutoPlay")
EditorGadget(0, 5, 5, 210, 190, #PB_Editor_ReadOnly)
AddGadgetItem(0, 0, "QueryCancelAutoPlay Waiting...")
SetWindowCallback(@WindowCallback())
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Yes it work 100%, MSDN: Your application's window must be in the foreground to receive this message.
Posted: Sun Apr 12, 2009 6:31 am
by PB
> MSDN: Your application's window must be in the foreground to receive this message
That is such a pain in the butt. There MUST be a way to do it without the
app's window having the focus. But, I sure can't find a way. Damn MS.

Posted: Wed Apr 15, 2009 12:56 am
by Sparkie
PB wrote: There MUST be a way to do it without the app's window having the focus.
http://msdn.microsoft.com/en-us/library ... S.85).aspx