AutoHotkey Community

It is currently May 26th, 2012, 12:55 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 152 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7, 8 ... 11  Next
Author Message
 Post subject:
PostPosted: August 31st, 2007, 8:01 am 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 31st, 2007, 10:36 pm 
Offline

Joined: November 15th, 2005, 11:15 am
Posts: 537
Location: Germany
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 1st, 2007, 8:46 am 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 17th, 2007, 3:14 pm 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7501
Location: Australia
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 11th, 2007, 2:11 pm 
Offline

Joined: January 11th, 2005, 7:27 pm
Posts: 13
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 12th, 2007, 1:15 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7501
Location: Australia
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 12th, 2007, 6:08 am 
Offline

Joined: January 11th, 2005, 7:27 pm
Posts: 13
Great, it works. Thanx.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: December 15th, 2007, 11:00 am 
Offline

Joined: October 28th, 2007, 10:41 am
Posts: 75
Location: Hungary, Érd
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)


Report this post
Top
 Profile  
Reply with quote  
PostPosted: April 6th, 2008, 2:55 pm 
Offline

Joined: April 6th, 2008, 2:46 pm
Posts: 8
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? :cry:

THX
Kyvaith


Report this post
Top
 Profile  
Reply with quote  
PostPosted: April 6th, 2008, 3:04 pm 
Offline

Joined: April 1st, 2008, 4:37 pm
Posts: 24
Location: Netherlands
kyvaith wrote:
I wanna to remap fn key to control button and ejc key to delete button. Anybody can help me with it? :cry:

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!


Report this post
Top
 Profile  
Reply with quote  
PostPosted: April 6th, 2008, 3:08 pm 
Yes, I seen it, but It doesn't work - script crashing down on fn key registering, like I've wrote at the begining...


Report this post
Top
  
Reply with quote  
PostPosted: April 6th, 2008, 3:39 pm 
Offline

Joined: April 1st, 2008, 4:37 pm
Posts: 24
Location: Netherlands
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 6th, 2008, 3:57 pm 
Offline

Joined: April 6th, 2008, 2:46 pm
Posts: 8
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. :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 6th, 2008, 4:18 pm 
Offline

Joined: April 1st, 2008, 4:37 pm
Posts: 24
Location: Netherlands
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 6th, 2008, 4:29 pm 
Offline

Joined: April 6th, 2008, 2:46 pm
Posts: 8
Nope... it doesn't work

I have error popup saying that there is no mfc71.dll library..


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 152 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7, 8 ... 11  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 64 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group