Log In
Sign Up and Get Started Blogging!
JoeUser is completely free to use! By Signing Up on JoeUser, you can create your own blog and participate on the blogs of others!
The High Redoubt
Object.RegisterHotkey
Does it work?
Published on July 21, 2005 By
MountainDragon
In
DesktopX
Has anyone had success using the Object.RegisterHotkey method? If so, could you post an example snippet? I can't seem to get it to work.
Article Tags
desktopx
Popular Articles in this Category
Keep an Eye Out!
Popular Articles from MountainDragon
MSN Screensaver Beta
Comments (Page 1)
2 Pages
1
2
Next
1
thomassen
on Jul 21, 2005
It's not
Object_RegisterHotkey
, it's
Object.RegisterHotkey
. Then use the subroutine
Sub Object_OnHotkey(id)
to catch the hotkeys.
2
MountainDragon
on Jul 21, 2005
Thomas - Yeah, I know - I did use Object.RegisterHotkey in the code. Have you gotten it to work, then?
3
thomassen
on Jul 21, 2005
hmm... nope... not really. I don't unserstand how the hotkeyValue is suppose to be formatted. I tried
Object.RegisterHotkey 1, &H46 And &H00000002
, &H46 beeing the hex virtual code for F and &H00000002 beeing the Control modifier. But it doesn't work. I don't get it. I get the feeling that the documents assume some C knowledge...
4
thomassen
on Jul 21, 2005
loworder-byte, highorder-byte. HIWORD, LOWORD. ... ? All to confusing.
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.
5
MountainDragon
on Jul 21, 2005
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?
6
thomassen
on Jul 22, 2005
I tried to see if it only worked if the object where complied as a widget, but I got no result there either.
When I try your &H0431 nothing seem to excecute after that.
7
MountainDragon
on Jul 22, 2005
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.
8
thomassen
on Jul 23, 2005
Will you post back here when you hear from them. This has made me curious. It'll be my weekend mystery.
9
thomassen
on Jul 25, 2005
Well, I'm stuck. Have you managed to work something out?
10
MountainDragon
on Jul 25, 2005
Thomas - I've sent two emails, and heard nothing back. I suspect, with the number of errors I'm seeing accessing the site, that they are a bit busy. That shouldn't involve Alberto, though, should it?
11
thomassen
on Jul 26, 2005
hmm... Dunno if Alberto do siterepairs. I haven't seen him on IRC until today just he disappeared before I could ask him.
12
thomassen
on Jul 27, 2005
I just got an example of how to use RegisterHotkey. Not sure if it's what you are looking for.
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.
13
MountainDragon
on Jul 27, 2005
Thomas - based on the example, but modified because I want to use it in a theme, not a widget, this is what I tried, and the hotkey still does not seem to function:
'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.
14
thomassen
on Jul 27, 2005
I got hold of Alberto on IRC. He showed me a sneakpeak of the Neowin gadget sourcecode. I addapted it to the code I posted. It worked as an widget to me.
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.
15
thomassen
on Jul 27, 2005
Could it be... because the value is stored in this hiword and loword that the bits get misinterpreted when converted into a variable then back again to the RegisterHotkey?
2 Pages
1
2
Next
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.
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!
Sign Up Now!
Meta
Views
» 9483
Comments
»
16
Category
»
DesktopX
Comment
Recent Article Comments
Modding Ara: History Untold
LightStar Design Windowblind...
DeskScapes 11: The Dream Mak...
Which A.I. Software Are You ...
ChatGPT 4o vs. o1 vs. o1 Pro...
What's the Last Book You Rea...
A day in the Life of Odditie...
Let's start a New Jammin Thr...
Let's see your political mem...
Safe and free software downl...
Sponsored Links