intercepting power event - Gyration Remote power button

If you have a question or need help, this is the place to be.

intercepting power event - Gyration Remote power button

Postby Beholder » Mon Apr 27, 2009 9:58 am

hey guys,

currently I am using AutoHotkey to intercept a computer standby and instead do my own action (Alt+F4 keypress). I am doing this because HID of the Gyration Remote's dongle doesn't send any keypress when the power button is pressed on the remote, instead it just invokes a power event.

For full reference, here is the AHK script I am using:
Code: Select all
;Autohotkey script "Set standby button to ALT+F4"
;=================================================================================

OnMessage(0x218, "WM_POWERBROADCAST")

WM_POWERBROADCAST(wParam, lParam)
{
   If wParam=0
   {
      Send, !{F4}
      Return  0x424D5144
   }
   Else Return
}


I was just wondering, is there a way to do this in EG only? I can see the "System.QuerySuspend" and "System.QuerySuspendFailed" events after the button keypress in the EG's event log. The most important part in AHK script however seems to be the "Return 0x424D5144" (otherwise the power event is not stopped) and I have no idea how to do this in EG.
Beholder
 
Posts: 24
Joined: Sat Apr 18, 2009 3:39 pm

Re: intercepting power event - Gyration Remote power button

Postby thejulianath20 » Fri Jan 15, 2010 10:09 pm

Bump this. Why does the power button on my Gyration Remote with Windows 7 now shut everything down with my PC?!!!!
thejulianath20
 
Posts: 4
Joined: Fri Jan 15, 2010 10:06 pm

Re: intercepting power event - Gyration Remote power button

Postby Beholder » Fri Jan 15, 2010 11:11 pm

Hi,

In XP, if you don't want to shut down PC with Gytation Remote stand-by button, you will have to intercept the button when it is pressed. Use autohotkey to do that, if you need it. The stand-by button must be set in Windows to "stand by" not to power off the computer. So set it in control panel to do just that.

If it still doesn't work for you, it might be a Win7 issue and I can't help you there.

The by-product of using this autohotkey script to do that is that stand-by will not work when activated by keyboard or by mouse in the shutdown dialog. I circumvented this by catching the keyboard sleep key with EventGhost and with EventGhost commands turning off the autohotkey temporarily and initiating stand-by mode.
But then (while it was working perfectly) I disabled the keyboard sleep key altogether, since my child loved to press it in the worst possible moments. Really like I was saving something to disk and he pressed it, stuff like that.
Beholder
 
Posts: 24
Joined: Sat Apr 18, 2009 3:39 pm

Re: intercepting power event - Gyration Remote power button

Postby Melloware » Sun Feb 14, 2010 3:12 pm

Try just disabling the HID Service in Control Panel->Admin->Services and also try disabling ehtray.exe.

Disable ehtray.exe permanently
Using process monitor, I found that ehtray.exe was running, but it is only loaded into memory when a key is pressed and then goes away. (Still not sure what lauches it)

I found going into c:\windows\ehome and renaming ehtray.exe to something else (first you have to take ownership of the file using properties->security->advanced) that it will not respond to the Power button by default any more.
-----------------------------------
Melloware Inc.
EventPhone iPhone Application
Intelliremote - HTPC Remote Application
-----------------------------------
User avatar
Melloware
Plugin Developer
 
Posts: 86
Joined: Mon May 12, 2008 6:18 pm

Re: intercepting power event - Gyration Remote power button

Postby thejulianath20 » Mon Feb 15, 2010 3:36 am

Figured it out! It is in the Control Panel. It is the power options. Choose what the power buttons do... "Do Nothing" and then all is back to normal with my power button on my Gyration Remote. It now closes apps and programs that are in focus, instead of putting the whole computer to sleep. :D :) :lol:
thejulianath20
 
Posts: 4
Joined: Fri Jan 15, 2010 10:06 pm

Re: intercepting power event - Gyration Remote power button

Postby Beholder » Mon Feb 15, 2010 3:38 am

awesome
Beholder
 
Posts: 24
Joined: Sat Apr 18, 2009 3:39 pm

Re: intercepting power event - Gyration Remote power button

Postby fredoman » Thu Mar 04, 2010 10:50 pm

I'm a new EventGhost and Gyration User (Windows 7, 32 bit) and I tried to make this Power button work like described here, unfortunately without success.

The Power button works well to put Windows to sleep, but I did not succeed to intercept this event with Beholders AHK script: I installed autohotkey, then created and executed the script. When pressing the power button Windows still goes to sleep and no keyboard event is logged in EventGhost (Keyboard plugin loaded). Maybe the sleep event is not not the same in Windows 7?

thejulianath20, you reported success to use the Gyration power button to shutdown programs in W7, could you please describe exactly how you managed to do this? Thanks in advance!
fredoman
 
Posts: 4
Joined: Thu Mar 04, 2010 10:35 pm

Re: intercepting power event - Gyration Remote power button

Postby Beholder » Thu Mar 04, 2010 11:35 pm

It is in the Control Panel. It is the power options. Choose what the power buttons do... "Do Nothing"
Beholder
 
Posts: 24
Joined: Sat Apr 18, 2009 3:39 pm

Re: intercepting power event - Gyration Remote power button

Postby fredoman » Sat Mar 06, 2010 2:58 pm

Yes, I tried this already. When I change the option to "Do Nothing", I does exactly this : Nothing. No event is created by AHK, nothing logged by EventGhost.
fredoman
 
Posts: 4
Joined: Thu Mar 04, 2010 10:35 pm

Re: intercepting power event - Gyration Remote power button

Postby Beholder » Sat Mar 06, 2010 9:14 pm

Well, in such a case this might be something with the way AHK works.. Make sure you put the above code snippet as the 1st thing of your AHK script, before any hotkey definitions, etc.
After the AHK script has been loaded, it begins executing at the top line, continuing until a Return, Exit, hotkey/hotstring label, or the physical end of the script is encountered (whichever comes first). This top portion of the script is referred to as the auto-execute section. Any lines you want to execute immediately when the AHK script starts should appear here, at the top of the script, prior to the first hotkey, hotstring, or Return.


Another thing is that script will probably actually work only when you set power options for sleep button to be "stand-by".

Next thing you can try is to make autohotkey post some message on the screen when it intercepts the power event: it seems like it fails to send a alt+f4 key combination. That way you will know that the event is properly intercepted (as indicated by EG). Use for example:*
tooltip, event itercepted ok!!

(*and then watch your mouse cursor as you press the power button on the remote)
Beholder
 
Posts: 24
Joined: Sat Apr 18, 2009 3:39 pm

Re: intercepting power event - Gyration Remote power button

Postby fredoman » Sat Mar 13, 2010 10:11 pm

Thanks Beholder for your kind help !
I retested without success a modified script (hope it is OK, I have no experience with AHK scripts yet) that should show a message box when the power button is pressed :
Code: Select all
OnMessage(0x218, "WM_POWERBROADCAST")

WM_POWERBROADCAST(wParam, lParam)
{
   If wParam=0
   {
      MsgBox, PowerButton pressed !
      Return  0x424D5144
   }
   Else
   {
   MsgBox, PowerButton pressed !
   Return
   }
}


Results : if the sleep button is configured as sleep or hibernate, the computer does sleep/hibernate. When the button is configured as "Do nothing" then nothing happens. In neither of the three cases I saw a message box pop up.

I read in this thread on the AHK forum that that in Windows Vista it is probably impossible to interrupt the hibernation event with the 0x424D5144 message. I guess it is the same problem with Windows 7. Looks like I am stuck, should have stayed with XP :wink:

Edit: I found out after some more reading (e.g. here) that in fact Vista does not deliver the PBT_APMQUERYSUSPEND event (and therefore the event can't be blocked by BROADCAST_QUERY_DENY= 0x424D5144). The only remaining way to influence suspend/hibernate/sleep behavior is SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED), but this function will only reset the idle timer and thus prevent the system from going to sleep due to an idle timeout. It does not help to block a power button event. :cry:
fredoman
 
Posts: 4
Joined: Thu Mar 04, 2010 10:35 pm

Re: intercepting power event - Gyration Remote power button

Postby PanteraGSTK » Tue Mar 23, 2010 3:51 pm

I just wanted to let you guys know that you need to add all of the HID devices that EG sees. In doing this you will find that the power button on the gyration remote is mapped to Button.1. It took me forever to figure this out. I now can map it to any function I want.
PanteraGSTK
 
Posts: 21
Joined: Fri Feb 19, 2010 1:30 am

Re: intercepting power event - Gyration Remote power button

Postby Beholder » Tue Mar 23, 2010 5:08 pm

Unbelievable!! PanteraGSTK is right!!!!!!!!

In XP SP2 I have the remote button1 active when I turn off sleep mode (in power options > advanced > when I press sleep button > do nothing) then add the generic HID plugin and choose the 5th of the seven Gyration devices (I now have #1, #7 and #5 active).
And now I can configure the damn button without any autohotkey tweaks!

GREAT FIND, PANTERA, GYRATION REMOTE HAS JUST STEPPED UP A NOTCH IN USABILITY!! think about Win7 users!!

I am curious, how did you actually figure this out?
Beholder
 
Posts: 24
Joined: Sat Apr 18, 2009 3:39 pm

Re: intercepting power event - Gyration Remote power button

Postby PanteraGSTK » Thu Mar 25, 2010 4:02 pm

Beholder wrote:Unbelievable!! PanteraGSTK is right!!!!!!!!

In XP SP2 I have the remote button1 active when I turn off sleep mode (in power options > advanced > when I press sleep button > do nothing) then add the generic HID plugin and choose the 5th of the seven Gyration devices (I now have #1, #7 and #5 active).
And now I can configure the damn button without any autohotkey tweaks!

GREAT FIND, PANTERA, GYRATION REMOTE HAS JUST STEPPED UP A NOTCH IN USABILITY!! think about Win7 users!!

I am curious, how did you actually figure this out?


Thanks... I Figured it out by massive ammounts of trial and error. I KNEW that the power button had to be able to be used I just couldn't figure out how. I told windows to "do nothing" when I pushed the power button and sleep button to eliminate that frustration. Then I just added all of the hid devices that popped up and started pushing buttons. Eventually I figured out that button 1 was the power button.

Also, on my remote all buttons are usable in EG except the bottom buttons (eg. input, and others that escape me). I even think the dvd menu button is active.

Glad I could help. I love this remote now that I know it inside and out.
PanteraGSTK
 
Posts: 21
Joined: Fri Feb 19, 2010 1:30 am

Re: intercepting power event - Gyration Remote power button

Postby Beholder » Thu Mar 25, 2010 4:39 pm

yes, I have set up dvd button to switch my X-Fi Normalizer (SVM) on and off. The three other buttons will never work, I tried some hacks but failed.

I also wonder if the numeric input of letters (like a mobile) works for someone, because I couldn't get it to work. Seems like it would work only for some special apps, like the interface of Win MCE.

A really advanced application of EventGhost for this remote is an on-screen menu which can actually run apps, etc. I have set it up and it works very well in XP.
Beholder
 
Posts: 24
Joined: Sat Apr 18, 2009 3:39 pm

Next

Return to General Support

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Google Adsense [Bot] and 6 guests