 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
olle Guest
|
Posted: Fri Aug 31, 2007 8:01 am Post subject: |
|
|
Hello,
Stumbled in from Google and found this thread. I am new to AHK so please have patience
I found that Michas dll does exactly what I want -- read the codes which my MCE Remote send.
So far so good. My first task was to try to remap the green startbutton on the remote. The dll catches the code but then the key is sent to the OS and Media Center launches right after my ahk-script caught the key.
I would like to use the green startbutton like this:
If MS media center is running, pass the key to media center
If MS media center is not running, do not pass the key to the OS (I want to launch another application, not media center).
Is this possible at all?
/olle |
|
| Back to top |
|
 |
Micha
Joined: 15 Nov 2005 Posts: 437 Location: Germany
|
Posted: Fri Aug 31, 2007 10:36 pm Post subject: |
|
|
Hi olle,
I can catch the key "volume on/off" of my remote control, but windows enables/ disables the volume after I "catched" the key with my dll.
So I've tried the following script:
| Code: | #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
#InstallKeybdHook
#Persistent |
Start the script and double click on the green "H" in the tray area. The window of Autohotkey is being displayed.
Now select "View / Key history and script info"
Please press the green button on your remote control and press "F5" in the autohotkey window.
If lines like
| Code: | 74 03F d 0.19 F5
74 03F u 0.22 F5
AD 120 h d 1.47 D
AD 120 a u 0.27 D
74 03F u 0.22 F5
|
are displayed you can catch your green key with autohotkey directly
You can try
| Code: | | sc120:: MsgBox, Volume on-off |
where 120 after sc is the value displayed in the autohotkey window between the "F5" keys.
Please post, if your keys can be detected by autohotkey or not.
Ciao
Micha |
|
| Back to top |
|
 |
olle Guest
|
Posted: Sat Sep 01, 2007 8:46 am Post subject: |
|
|
Sorry if I was unclear, but AHK does not detect keys from my MCE remote other than "uinteresting keys" like "#" and so on.
(when running your suggested testscript I pressed green button which started media center, used MS Remote keyboard to shutdown via ALT-F4, after a refresh not a single key/mouse moevement was captured by AHK)
Your excellent dll is what I can see the only path to go, the question is how to surpress the message (keypress) once AHK (via your dll) catches it.
/olle |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2558 Location: Australia, Qld
|
Posted: Mon Sep 17, 2007 3:14 pm Post subject: |
|
|
Micha, I think I've discovered how to deregister a device: RIDEV_REMOVE. At first, calling RegisterRawInputDevices() with the RIDEV_REMOVE flag set in the RAWINPUTDEVICE structure wasn't working, but I found that once I set hwndTarget to NULL (I was setting it to the script's hwnd), it seems to work.
| Quote: | | Remember also that you can't DEregister a device! |
Here's an excerpt from the RawInput script I'm working on: | Code: | VarSetCapacity(dev, 12, 0)
NumPut(UsagePage, dev, 0, "UShort")
NumPut(Usage, dev, 2, "UShort")
NumPut(Flags, dev, 4)
if !(Flags & 1) ; RIDEV_REMOVE (doesn't work if hwnd != NULL)
NumPut(Script_Hwnd, dev, 8)
ret := DllCall("RegisterRawInputDevices"
, "uint", &dev ; pRawInputDevices (pointer to an array of RAWINPUTDEVICE)
, "uint", 1 ; uiNumDevices
, "uint", 12) ; cbSize (size of a RAWINPUTDEVICE structure) | where 'Flags' = 0x1 (RIDEV_REMOVE) to unregister a device.
MSDN says: | Quote: | RIDEV_REMOVE
If set, this removes the top level collection from the inclusion list. This tells the operating system to stop reading from a device which matches the top level collection. |
|
|
| Back to top |
|
 |
DoXer
Joined: 11 Jan 2005 Posts: 12
|
Posted: Tue Dec 11, 2007 2:11 pm Post subject: |
|
|
Hello,
I hope I get help here.
I'm not so good in programming, so I have problems to understand the samplescript.
What I want:
I have a Logitech Mouse RX250 with a mousewheel you can push left and right. I don't want to install the big Logitech driversoftware to use the two buttons. Autohotkey doesn't recognize the buttons, but with this remote-dll it reconize it. I have tested it with the script AutoHotkeyRemoteControlDLL.ahk an I received the following information:
Usage: 2
Usagepage: 1
When I press the wheel to the left:
BtnFlag:2048
ButtonData: 65416
When I press the wheel to the right:
BtnFlag:2048
ButtonData: 120
But how is the autohotkey-skript to send for example a msgbox for pressing right an another msgbox for pressing left.
Thanx in advance.
DoXer |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2558 Location: Australia, Qld
|
Posted: Wed Dec 12, 2007 1:15 am Post subject: |
|
|
I assume you're on Vista? IIRC, you don't get those messages on XP or lower. Vista also supports wheel left/right via the mouse hook and WM_MOUSEHWHEEL message:
| Code: | #NoEnv
#Persistent
DllCall("SetWindowsHookEx"
, "int", 14 ; WH_MOUSE_LL
, "uint", RegisterCallback("WheelHorzHook")
, "uint", 0
, "uint", 0)
return
WheelHorzHook(nCode, wParam, lParam)
{
Critical
if (wParam = 0x020E) ; WM_MOUSEHWHEEL (Vista-only)
{
if (delta := NumGet(lParam+0,10,"Short"))
{
if (delta<0) {
SetTimer, WheelLeft, -1
return true
} else {
SetTimer, WheelRight, -1
return true
}
}
}
return DllCall("CallNextHookEx", "uint", 0, "int", nCode, "uint", wParam, "uint", lParam)
}
WheelLeft:
MsgBox WheelLeft
return
WheelRight:
MsgBox WheelRight
return | The timers are used because taking too long in the mouse hook can make the mouse unresponsive. |
|
| Back to top |
|
 |
DoXer
Joined: 11 Jan 2005 Posts: 12
|
Posted: Wed Dec 12, 2007 6:08 am Post subject: |
|
|
| Great, it works. Thanx. |
|
| Back to top |
|
 |
fmate14
Joined: 28 Oct 2007 Posts: 48 Location: Hungary, Érd
|
Posted: Sat Dec 15, 2007 11:00 am Post subject: How does it work? (Why not) |
|
|
| lexikos wrote: | | I assume you're on Vista? IIRC, you don't get those messages on XP or lower. Vista also supports wheel left/right via the mouse hook and WM_MOUSEHWHEEL message |
I have an A4 tech WOP-49 mouse, I use the A4 tech's driver to Left/Right Wheel funcionality.
I have Vista, but this script say nothing. (I tested it without driver, too.)
And the original HID script detect nothing, too. So… It receives a message from the mouse, but all numbers (except the device) are 0. The other buttons works well.
(Sorry my english) |
|
| Back to top |
|
 |
kyvaith
Joined: 06 Apr 2008 Posts: 8
|
Posted: Sun Apr 06, 2008 2:55 pm Post subject: Apple Wireless Keyboard and Vista 64 - Fn and ejc key |
|
|
Hey...
I've get you great stuff from first page of this toppic and I fired up the AutoHotkeyRemoteControlDLL.ahk script. I click on 1: HID and by default 1 and 12 settings i clicked Register and Fn key on my apple wireless keyboard... and script crashed ;( When i'm starting RemoteControl.ahk from your pack and pressing fn key it show me the popup box with 1110 number, and when i'm pressing ejc key it shows box with 1108, so Autohotkey see my invisible for windows keys.
I wanna to remap fn key to control button and ejc key to delete button. Anybody can help me with it?
THX
Kyvaith |
|
| Back to top |
|
 |
Veil
Joined: 01 Apr 2008 Posts: 22 Location: Netherlands
|
Posted: Sun Apr 06, 2008 3:04 pm Post subject: Re: Apple Wireless Keyboard and Vista 64 - Fn and ejc key |
|
|
| kyvaith wrote: | I wanna to remap fn key to control button and ejc key to delete button. Anybody can help me with it? |
Hi,
I wrote a full guide about exactly this a few days ago. You can find it at:
http://brrp.mine.nu/fnkey/
Good luck! |
|
| Back to top |
|
 |
Guest
|
Posted: Sun Apr 06, 2008 3:08 pm Post subject: Re: Apple Wireless Keyboard and Vista 64 - Fn and ejc key |
|
|
| Yes, I seen it, but It doesn't work - script crashing down on fn key registering, like I've wrote at the begining... |
|
| Back to top |
|
 |
Veil
Joined: 01 Apr 2008 Posts: 22 Location: Netherlands
|
Posted: Sun Apr 06, 2008 3:39 pm Post subject: Re: Apple Wireless Keyboard and Vista 64 - Fn and ejc key |
|
|
| Anonymous wrote: | | Yes, I seen it, but It doesn't work - script crashing down on fn key registering, like I've wrote at the begining... |
What OS are you using? I know it works in Windows XP, maybe it's acting different in other versions.
In any case, it doesn't really matter. You only need "AutoHotkeyRemoteControlDLL.ahk" to find the correct settings for your keyboard. In case of the Apple Wireless Keyboard it's 1 and 12. The fact that you do receive a response from the keys using the other script, means that the DLL file recognizes your keys and that's all that matters.
Take a look at step 2: http://brrp.mine.nu/fnkey/#step2
Download the script, and enable the message box which gives back the KeyStatus. If it does that, the rest will work as well. |
|
| Back to top |
|
 |
kyvaith
Joined: 06 Apr 2008 Posts: 8
|
Posted: Sun Apr 06, 2008 3:57 pm Post subject: |
|
|
| Quote: | | What OS are you using? |
My first Post subject: Apple Wireless Keyboard and Vista 64 - Fn and ejc key
You wrote
| Quote: | | You only need "AutoHotkeyRemoteControlDLL.ahk" to find the correct settings for your keyboard. In case of the Apple Wireless Keyboard it's 1 and 12. The fact that you do receive a response from the keys using the other script, means that the DLL file recognizes your keys and that's all that matters. |
But I think you didn't read what I wrote:
| Quote: | | (..)script crashing down on fn key registering, like I've wrote at the begining |
| Quote: | | I click on 1: HID and by default 1 and 12 settings i clicked Register and Fn key on my apple wireless keyboard... and script crashed |
So, if
| Quote: | | You only need "AutoHotkeyRemoteControlDLL.ahk" to find the correct settings for your keyboard |
I think that correct settings are in RemoteControl.ahk if it responding by dialog box with numbers.
So could you tell me how can I modified this file to
| Quote: | | (..)remap fn key to control button and ejc key to delete button. | in place of this bialog box?
Yes, I know that my English is terrible - sorry for that.  |
|
| Back to top |
|
 |
Veil
Joined: 01 Apr 2008 Posts: 22 Location: Netherlands
|
Posted: Sun Apr 06, 2008 4:18 pm Post subject: |
|
|
| kyvaith wrote: | | My first Post subject: Apple Wireless Keyboard and Vista 64 - Fn and ejc key | Ah, my bad!
| kyvaith wrote: | But I think you didn't read what I wrote:
| kyvaith wrote: | | (..)script crashing down on fn key registering, like I've wrote at the begining |
| This script/application is just to find the right settings for your keyboard. It might crash, but that probably has something to do with how it was written, and the fact that it's not optimized for Windows Vista.
You don't need this script per se to find the settings. You can also edit them manually in the config file as described in step 2, to see if it's working. Since you're using the Apple Wireless Keyboard, you already know the correct values, so you don't have to worry about the crashes of this program.
| kyvaith wrote: | | I think that correct settings are in RemoteControl.ahk if it responding by dialog box with numbers. | Correct. If you open the .ahk file in an editor, you see they also use the values Usage=1 and UsagePage=12 by default.
| kyvaith wrote: | So could you tell me how can I modified this file to
| Quote: | | (..)remap fn key to control button and ejc key to delete button. | in place of this bialog box? | Because you're using the exact same keyboard that I'm typing on right now, my scripts should be working for you as well.
I uploaded the configuration files I use at this moment: AppleWirelessKeyboard.zip
Unzip these files to a folder, and double click "Apple Wireless Keyboard.ahk". Then, check to see if Fn+Backspace=Delete, Fn+F10=Mute/Unmute, etc.
I'm pretty sure this will work. Open the configuration to see which hotkeys I included. Check the AutoHotKey manual for information about how you create hotkeys, and how functions work. This way you can alter the configuration so that it works the way you'd like it to. |
|
| Back to top |
|
 |
kyvaith
Joined: 06 Apr 2008 Posts: 8
|
Posted: Sun Apr 06, 2008 4:29 pm Post subject: |
|
|
Nope... it doesn't work
I have error popup saying that there is no mfc71.dll library.. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|