Object.RegisterHotkey
Does it work?
Thursday, July 21, 2005 by MountainDragon | Discussion: DesktopX
Reply #2 Thursday, July 21, 2005 2:13 PM
Reply #3 Thursday, July 21, 2005 3:47 PM
Reply #4 Thursday, July 21, 2005 3:56 PM
I did a search and I came across this site: http://www.freevbcode.com/ShowCode.asp?ID=2650
I adapted the code to go into VBScript:
Const hKeyShift = &H00000001
Const hKeyControl = &H00000002
Const hKeyAlt = &H00000004
Const hKeyExtended = &H00000008
Const hKeyF = &H46
'Called when the script is executed
Sub Object_OnScriptEnter
Object.RegisterHotkey 1, MakeLong(hKeyF, hKeyControl)
Script.MsgBox "HotkeyStart"
End Sub
'Called when the script is terminated
Sub Object_OnScriptExit
Object.UnregisterHotkey 1
End Sub
Sub Object_OnHotkey(id)
Script.MsgBox "Hello World!" & vbCrLf & id
End Sub
Public Function MakeLong(ByVal LoWord, ByVal HiWord)
MakeLong = ((HiWord * &H10000) + LoWord)
End Function
But with not results...
I'll try to grab hold of someone on IRC tomorrow.Reply #5 Thursday, July 21, 2005 5:31 PM
| I get the feeling that the documents assume some C knowledge... |
The thing is, I do have C knowledge (20 years
)As near as I get from the doc that Alberto (or whomever) wrote, it's a WORD argument (2 bytes) with the flag in the hi-order byte and the key value in the lo-order byte.
So, you should be able to just send &H0431 (for Alt-1) or whatever. But this did not work as expected.
I did notice that the object would seem to fail on it's initialization depending on what I sent to the function. I only noticed this because it's supposed to position itself on script entry, and sometimes it didn't.
Alberto, are you there?
Reply #6 Friday, July 22, 2005 2:18 PM
When I try your &H0431 nothing seem to excecute after that.
Reply #7 Friday, July 22, 2005 4:59 PM
| When I try your &H0431 nothing seem to excecute after that. |
Yeah, same result here. Very strange. I asked Green Reaper about it and he hadn't tried it, so I emailed tech support and have yet to hear back.
Reply #8 Saturday, July 23, 2005 9:46 AM
Reply #9 Monday, July 25, 2005 3:27 PM
Reply #10 Monday, July 25, 2005 3:46 PM
Reply #11 Tuesday, July 26, 2005 12:23 PM
Reply #12 Wednesday, July 27, 2005 1:03 PM
Sub Object_OnScriptEnter
Widget.AddPreference("hotkey")
Widget.preference("hotkey").Type = "hotkey"
Widget.preference("hotkey").caption = "ZOrder hotkey"
Widget.preference("hotkey").description = "You can use this hotkey to trigger the RSS Reader on top of all other windows"
SetHotkey
End Sub
Sub Widget_OnPreferencesChange
SetHotkey
End Sub
Sub SetHotkey
Object.RegisterHotkey 1, Widget.Preference("hotkey").Value
End Sub
Sub Object_OnHotkey(id)
Widget.OnTop
End Sub
I asked him for an example of a hardcoded hotkey as I can imagine I might have use for it.
Reply #13 Wednesday, July 27, 2005 1:56 PM
'Called when the script is executed
Sub Object_OnScriptEnter
End Sub
'Called when the script is terminated
Sub Object_OnScriptExit
Object.UnregisterHotkey(1)
End Sub
Dim h
Sub Object_OnLButtonUp(x,y,dragged)
If Not dragged Then
Set form=Desktopx.CreateForm
form.AddPreference("Hotkey")
form.Preference("Hotkey").Type="hotkey"
form.Preference("Hotkey").Caption="Hotkey:"
form.Preference("Hotkey").Value=h
If( form.Prompt ) Then
h=form.Preference("Hotkey").Value
MsgBox("Setting hotkey")
Object.RegisterHotkey 1,h
End If
End If
End Sub
Sub Object_OnHotkey(id)
MsgBox("Hit")
End Sub
Who did you talk to? I guess tech support must be out to lunch on this one.
Reply #14 Wednesday, July 27, 2005 3:11 PM
I could get your code to work if I replaced Object.RegisterHotkey 1,h with Object.RegisterHotkey 1, form.Preference("Hotkey").Value
I have no idea why that should matter.
Reply #15 Wednesday, July 27, 2005 3:50 PM
Reply #16 Wednesday, July 27, 2005 3:57 PM
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 Thursday, July 21, 2005 1:53 PM