Autohotkey for The Green Button?

Post Reply
User avatar
makryger

Posts: 2132
Joined: Sun Jun 05, 2011 2:01 pm
Location: Illinois

HTPC Specs: Show details
5+ Yrs TGB Veteran Staff

Autohotkey for The Green Button?

#1

Post by makryger » Tue Jan 31, 2012 10:26 pm

I just starting to use autohotkey to make some tasks (like turning the tv and audio on and off) a bit smarter, and one of the things I'd like to do is assign the green button to a slightly different function. Is this possible? I tried using the key logger included in AHK, but it didn't log anything when I pressed the green button.
My Channel Logos XL: Get your Guide looking good! ~~~~ TunerSalad: Increase the 4-tuner limit in 7MC

User avatar
STC

Posts: 6808
Joined: Mon Jun 06, 2011 4:58 pm
Location:

HTPC Specs: Show details
5+ Yrs TGB Veteran Staff

#2

Post by STC » Wed Feb 01, 2012 1:04 am

I use AHK quite a bit M, but not sure about the green button. Does the green button correspond to a combo key function?
By the Community, for the Community. 100% Commercial Free.

Want decent guide data back? Check out EPG123

User avatar
makryger

Posts: 2132
Joined: Sun Jun 05, 2011 2:01 pm
Location: Illinois

HTPC Specs: Show details
5+ Yrs TGB Veteran Staff

#3

Post by makryger » Wed Feb 01, 2012 1:09 am

It does, but I need to go in the other direction- I want to assign the physical button to a different key combination, rather than assign the button function to something new.
My Channel Logos XL: Get your Guide looking good! ~~~~ TunerSalad: Increase the 4-tuner limit in 7MC

User avatar
STC

Posts: 6808
Joined: Mon Jun 06, 2011 4:58 pm
Location:

HTPC Specs: Show details
5+ Yrs TGB Veteran Staff

#4

Post by STC » Wed Feb 01, 2012 1:44 am

Eek!

Image
By the Community, for the Community. 100% Commercial Free.

Want decent guide data back? Check out EPG123

User avatar
STC

Posts: 6808
Joined: Mon Jun 06, 2011 4:58 pm
Location:

HTPC Specs: Show details
5+ Yrs TGB Veteran Staff

#5

Post by STC » Wed Feb 01, 2012 1:46 am

Okay, now i've got my head around that, I don't think that would be a AHK function direct. You'd need something a layer above AHK to jig the IR db code(?)
By the Community, for the Community. 100% Commercial Free.

Want decent guide data back? Check out EPG123

crawfish

Posts: 465
Joined: Fri Jan 13, 2012 5:16 am
Location:

HTPC Specs: Show details

#6

Post by crawfish » Wed Feb 01, 2012 1:53 am

I use the ReportMappingTable registry hack to map Windows+Alt+Enter (global Windows shortcut for starting Media Center) to the physical green button, which otherwise generates an HID event instead of a normal keypress. Then in my autohotkey script, I have:

Code: Select all

; Start Media Center
#!Enter::
	IfWinExist, ahk_class iTunes
	{
		WinActivate
		Send !{F4} ; Exit program
	}
	IfWinExist, ahk_class XBMC
	{
		WinActivate
		Send !{F4} ; Exit program
	}
	Send #!{Enter}
	return
You can map any key combination to the green button you want; it doesn't have to be Win+Alt+Enter.

Aside: Among many other things, I map the "DVD Audio" remote button to Win+Shift+Alt+Enter in ReportMappingTable to launch XBMC. As I don't actually have a remote with that button, I program a JP1 remote with it and a handful of other missing buttons, and then I use that remote to teach it to a button on my Sony RM-VL610. My autohotkey script contains:

Code: Select all

; Start XBMC
; Win+Alt+Enter is the shortcut for GreenButton; I use Win+Alt+Shift+Enter for XBMC
#!+Enter::
	IfWinExist, ahk_class iTunes
	{
		WinActivate
		Send !{F4} ; Exit program
	}
	IfWinExist, ahk_class eHome Render Window
	{
		WinActivate
		Send !{F4} ; Exit program
	}
	IfWinNotExist, ahk_class XBMC ;If XBMC is shutdown
	{
		Run "C:\Program Files (x86)\XBMC\XBMC.exe"
		WinWait,XBMC,,5
		If ErrorLevel
		{
			MsgBox, XBMC Startup timed out.
			return
		}
	}
	else
	{
		WinActivate
		WinMaximize
		WinShow
	}
	return
There are several fairly useless remote buttons Windows defines that I usurp in this way. It all works seamlessly, and I can include these learned buttons in remote macros that turn equipment off and on, select the proper inputs, etc.
Last edited by crawfish on Thu Nov 01, 2012 2:38 am, edited 1 time in total.

crawfish

Posts: 465
Joined: Fri Jan 13, 2012 5:16 am
Location:

HTPC Specs: Show details

#7

Post by crawfish » Wed Feb 01, 2012 1:58 am

Posting to the forum lost all the indenting in my AHK script. Oh well. (ETA: Edited to format as "code" on 10/31.)

Also, exiting iTunes is nice because iTunes can interfere with the operation of the remote, grabbing some buttons for itself despite not having the focus. It's possible to disable iTunes processing of multimedia keys by fiddling with iTunes' AppCommandMessageProcessingEnabled property using VBS, but it just isn't reliable. Exiting iTunes is the way to go. And obviously you don't want MC running while XBMC is running or vice versa.
Last edited by crawfish on Thu Nov 01, 2012 2:39 am, edited 1 time in total.

User avatar
STC

Posts: 6808
Joined: Mon Jun 06, 2011 4:58 pm
Location:

HTPC Specs: Show details
5+ Yrs TGB Veteran Staff

#8

Post by STC » Wed Feb 01, 2012 2:39 am

That looks promising...

I use the star key on the remote to perform a specific function through AHK without it interfering with other functions.
By the Community, for the Community. 100% Commercial Free.

Want decent guide data back? Check out EPG123

crawfish

Posts: 465
Joined: Fri Jan 13, 2012 5:16 am
Location:

HTPC Specs: Show details

#9

Post by crawfish » Wed Feb 01, 2012 3:22 am

Yeah, * (Shift+8), # (Shift+3), and Clear (Esc) are the easy ones. You can override those in AHK without messing with ReportMappingTable in the registry, and I've never missed their intended functions. They do need to be inside a block like this of course:

#IfWinActive ahk_class eHome Render Window
...
#IfWinActive

User avatar
makryger

Posts: 2132
Joined: Sun Jun 05, 2011 2:01 pm
Location: Illinois

HTPC Specs: Show details
5+ Yrs TGB Veteran Staff

#10

Post by makryger » Wed Feb 01, 2012 3:28 am

Thanks crawfish- your response would be the right one, if not for the fact that I use a gyration remote, which doesn't seem to jive with this hack, from my additional reading.

I may just have to use a *... not quite as seemless as I would have hoped, but better than nothing.
My Channel Logos XL: Get your Guide looking good! ~~~~ TunerSalad: Increase the 4-tuner limit in 7MC

User avatar
STC

Posts: 6808
Joined: Mon Jun 06, 2011 4:58 pm
Location:

HTPC Specs: Show details
5+ Yrs TGB Veteran Staff

#11

Post by STC » Wed Feb 01, 2012 3:31 am

makryger wrote:Thanks crawfish- your response would be the right one
Wha? Are we in class? :D
By the Community, for the Community. 100% Commercial Free.

Want decent guide data back? Check out EPG123

crawfish

Posts: 465
Joined: Fri Jan 13, 2012 5:16 am
Location:

HTPC Specs: Show details

#12

Post by crawfish » Wed Feb 01, 2012 4:33 am

Have you checked out AHKHID?

http://www.autohotkey.com/forum/topic41397.html

It might help you with the Gyration.

Post Reply