DesktopX advice on vbscript
Cannot activate script on mouse down
Monday, April 25, 2005 by spewface | Discussion: Beginners
Sub Object_OnStateChange(state)
If state = "mouse down" Then
set WshShell = Wscript.Createobject("Wscript.shell")
WshShell.AppActivate "player"
Wscript.Sleep 100
WshShell.sendkeys "{pgdn}"
Wscript.Sleep 100
end if
end sub
Without the if state = line it will work as I pass over the button
but I really need it to work on mouse down.
I want to use it to run the k/b shortcuts on a dvd player.
button is a layer with three states: Mouse away mouse over mouse down
thanks
Reply #2 Tuesday, April 26, 2005 7:44 AM
| Without the if state = line it will work as I pass over the button but I really need it to work on mouse down. |
Doesn't the Wscript. object give you an error? I tried that my self, but it doesn't seem to be an object accessible in DX scripting.
Reply #3 Tuesday, April 26, 2005 7:47 AM
Sub Object_OnLButtonUp(x, y, dragged)
If Not dragged Then
'Your code here
End if
End Sub
Reply #4 Tuesday, April 26, 2005 4:22 PM
And you are correct (Sorry) I should have removed the wscript as it does give an error. Without it I do get funtionality as I originally described. Sorry I posted my "pure" VBscript.
I think I owe you (thomassen) a beer as Object_OnLButtonUp(x,y) has resolved this issue for me. Thanks again.
Just a note that I read a DX tutorial that mentioned that Sleep can cause DesktopX to hang. It recommended using timers instead. I am not sure if this is true but I will keep it in mind just in case.
Reply #5 Tuesday, April 26, 2005 4:44 PM
If you go for the timer solution, I think this should work:
Sub Object_OnLButtonUp(x, y, dragged)
If Not dragged Then
Set WshShell = Wscript.Createobject("Wscript.shell")
WshShell.AppActivate "player"
Object.SetTimer 123 100
End If
End Sub
Sub Object_OnTimer123
WshShell.sendkeys "{pgdn}"
Object.KillTimer 123
End Sub
| I think I owe you (thomassen) a beer |
You know what, yesterday I thought about how nice it would be to work for beer...

Please login to comment and/or vote for this skin.
Welcome Guest! Please take the time to register with us.
There are many great features available to you once you register, including:
- Richer content, access to many features that are disabled for guests like commenting on the forums and downloading skins.
- Access to a great community, with a massive database of many, many areas of interest.
- Access to contests & subscription offers like exclusive emails.
- It's simple, and FREE!







Reply #1 Tuesday, April 26, 2005 7:41 AM
Sub Object_OnLButtonDown(x, y)
set WshShell = Wscript.Createobject("Wscript.shell")
WshShell.AppActivate "player"
Wscript.Sleep 100
WshShell.sendkeys "{pgdn}"
Wscript.Sleep 100
End Sub
Doesn't this Wscript.Createobject("Wscript.shell") give you an error? Does to me. I have to use just Createobject("Wscript.shell")