Sign in to follow this  
Followers 0
buckRogers

Help with _SendMessageA

3 posts in this topic

The following code currently exists:

CODE
;trap changenotify for a change in USB

$WM_DEVICECHANGE = 0x0219

GUICreate("")

GUIRegisterMsg($WM_DEVICECHANGE , "MyFunc")

Func MyFunc($hWndGUI, $MsgID, $WParam, $LParam)

;timer begin

$begin = TimerInit()

$val = ShellExecuteWait( "c:\windows\usbWhat.vbs", "", "C:\Windows", "", @SW_HIDE )

;timer end

$dif = TimerDiff($begin)

MsgBox(0,"Time Difference",$dif / 1000)

EndFunc

While 1

$GuiMsg = GUIGetMsg()

WEnd

This traps a change to the USB device; example: I can plug in a USB printer and it launches usbWhat.vbs. I can also plug in any other USB device and it runs the VBS code.

What happens is that it traps the message but doesn't let it go on. The VBS code is for a USB printer that gets attached. I don't want to handle any other USB device but you plug in a USB drive and the code kicks off but the computer doesn't recognize that the drive is plugged in so it doesn't ready it for use!

In trying to understand this type of code, I read that I need to pass on the changenotify message so that the computer can handle it normally. The problem is that I don't know how to do that. The code above is torn from code used to identify the insertion of a USB drive. I practically stripped it to run the internal VBS code on any USB device that's plugged in.

It would be a success if I can capture the message but also send it along so the computer can process it as normal.

Thanks for any help you can send my way,

buckRogers

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Start over from this code, is it better ?

$WM_DEVICECHANGE = 0x0219
GUICreate("")
GUIRegisterMsg($WM_DEVICECHANGE , "MyFunc")

While 1
    $GuiMsg = GUIGetMsg()
WEnd


Func MyFunc($hWndGUI, $MsgID, $WParam, $LParam)
    TrayTip ("","USB change detected",5)
EndFunc

Read the function help, it SPECIFICALLY says :

Warning: blocking of running user functions which executes window messages with commands such as "Msgbox()" can lead to unexpected behavior, the return to the system should be as fast as possible !!!

Edited by Inverted

Share this post


Link to post
Share on other sites

Start over from this code, is it better ?

$WM_DEVICECHANGE = 0x0219
GUICreate("")
GUIRegisterMsg($WM_DEVICECHANGE , "MyFunc")

While 1
    $GuiMsg = GUIGetMsg()
WEnd


Func MyFunc($hWndGUI, $MsgID, $WParam, $LParam)
    TrayTip ("","USB change detected",5)
EndFunc

Read the function help, it SPECIFICALLY says :

Thanks Inverted! I guess I had to take a step back and look at the code again. Also, I was using a ShellExecuteWait when all I really needed is a ShellExecute. I'm gonna retry and post results.

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