AutoHotkey Community

It is currently May 26th, 2012, 3:17 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 152 posts ]  Go to page Previous  1 ... 3, 4, 5, 6, 7, 8, 9 ... 11  Next
Author Message
 Post subject:
PostPosted: April 6th, 2008, 4:32 pm 
Offline

Joined: April 1st, 2008, 4:37 pm
Posts: 24
Location: Netherlands
kyvaith wrote:
Nope... it doesn't work

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

What script are you running exactly when you get this popup?

I don't really know how this DLL file is connected to all this, but maybe this can help you:

http://pcsupport.about.com/od/findbyerr ... c71dll.htm


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

Joined: April 6th, 2008, 2:46 pm
Posts: 8
I double clicked on Apple Wireless Keyboard.ahk and I've get a box with title: FnMapper: AutoHotkey.exe File not found saying the same what title - there is no MFC71.dll library :?

edit:

I think your new script accessing different things from windows api, that doesn't exist in RemoteControl.ahk... Mayby you could modified RemoteControl.ahk by removing all we doesn't need and adding procedure mapping fn key to control key and ejc key to delete key? It would be great.. ;)


edit2:

Ok it works :D

Now, what could I do to remap fn to control and ejc to del? I need only this function - no winamp controls, no real ejc function. Could you help me?


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

Joined: April 1st, 2008, 4:37 pm
Posts: 24
Location: Netherlands
kyvaith wrote:
Ok it works :D

Good news! This is with the Apple Wireless Keyboard.ahk right?

kyvaith wrote:
Now, what could I do to remap fn to control and ejc to del? I need only this function - no winamp controls, no real ejc function. Could you help me?

I stripped down the file to just the things you need. Copy the code below, and save it to a file. Make sure to place the file in the same directory as the DLL. Close all other scripts that are running, and then run this one.

Code:
;
; AutoHotkey Version: 1.x
; Language.........: English
; Platform.........: NT/XP/Vista
; Authors..........: Veil, Leon
; Full guide.......: http://brrp.mine.nu/fnkey/
;
; Script Function..: Remapping the Fn key
;
; Based on.........: DLLCall: Support for Human Interface devices
; By...............: Micha
; URL..............: http://www.autohotkey.com/forum/viewtopic.php?t=6367
;
; Use..............: Spread the word! Just be sure to credit the writer of the dll
;                               file and the   original config, and the authors of this file.
;

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
;#NoTrayIcon


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; DLL registration and readout of keys
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Set screen title, to set the HWND
Gui, Show, x0 y0 h0 w0, FnMapper

; Variable for the modifier key, define it here, just to be sure
fnPressed := 0

; Set the homepath to the relevant dll file
HomePath=AutohotkeyRemoteControl.dll

; Load the dll
hModule := DllCall("LoadLibrary", "str", HomePath)

; On specific message from the dll, goto this function
OnMessage(0x00FF, "InputMsg")

; Register at the dll in order to receive events
EditUsage := 1
EditUsagePage := 12
HWND := WinExist("FnMapper")
nRC := DllCall("AutohotkeyRemoteControl\RegisterDevice", INT, EditUsage, INT, EditUsagePage, INT, HWND, "Cdecl UInt")
WinHide, FnMapper


; This function is called, when a WM_INPUT-msg from a device is received
InputMsg(wParam, lParam, msg, hwnd)
{
  DeviceNr = -1
  nRC := DllCall("AutohotkeyRemoteControl\GetWM_INPUTDataType", UINT, wParam, UINT, lParam, "INT *", DeviceNr, "Cdecl UInt")
  if (errorlevel <> 0) || (nRC == 0xFFFFFFFF)
  {
     MsgBox GetWM_INPUTHIDData fehlgeschlagen. Errorcode: %errorlevel%
     goto cleanup
  }
  ;Tooltip, %DeviceNr%
  ifequal, nRC, 2
  {
    ProcessHIDData(wParam, lParam)
  }
  else
  {
     MsgBox, Error - no HID data
  }
}
Return

ProcessHIDData(wParam, lParam)
{
   ; Make sure this variable retains its value outside this function
   global fnPressed
   
  DataSize = 5000
   VarSetCapacity(RawData, %DataSize%, 0)
   RawData = 1
  nHandle := DllCall("AutohotkeyRemoteControl\GetWM_INPUTHIDData", UINT, wParam, UINT, lParam, "UINT *" , DataSize, "UINT", &RawData, "Cdecl UInt")

  ; Get the ID of the device
  ; Use the line below to check where an event was sent from, when using this code for a new HID device
  ; DeviceNumber := DllCall("AutohotkeyRemoteControl\GetNumberFromHandle", UINT, nHandle, "Cdecl UInt")

  ;FirstValue := NumGet(RawData, 0,"UChar") ; something to do with the bits, not really relevant here
  KeyStatus := NumGet(RawData, 1, "UChar")
 
  ; MsgBox, Keystatus: %KeyStatus%
 
  ; Filter the correct bit, so that it corresponds to the key in question
  ; Add another Transform for a new key
 
  ; Filter bit 5 (Fn key)
  Transform, FnValue, BitAnd, 16, KeyStatus
 
  ; Filter bit 4 (Eject key)
  Transform, EjectValue, BitAnd, 8, KeyStatus
   
  if (FnValue = 16) {
      Send, {Ctrl down}
  } else {
      Send, {Ctrl up}
  }
 
  if (EjectValue = 8) {
      Send, {Delete}
  }
 
} ; END: ProcessHIDData

; If there was an error retrieving the HID data, cleanup
cleanup:
DllCall("FreeLibrary", "UInt", hModule)  ; It is best to unload the DLL after using it (or before the script exits).



ExitApp


So run this, and see if it works. The parts that are relevant for you are:

Code:
  if (FnValue = 16) {
      Send, {Ctrl down}
  } else {
      Send, {Ctrl up}
  }
 
  if (EjectValue = 8) {
      Send, {Delete}
  }


Last edited by Veil on June 3rd, 2008, 4:11 pm, edited 2 times in total.

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

Joined: April 6th, 2008, 2:46 pm
Posts: 8
My genius :D

almost... this new delete button is probably not keyboard class key, because it doesn't deleting by pressing and holding for a longer time.. i can delete letters by selective clicking key...

I've tried adding Return on the end of value but it's not this... It should read keyboard status in loop to read hold key i think

edit:

I tried to find answer in script that you submitted three posts ago for me and... It works there with fn+backspace - it's deleting by holding combination of keys, but you declared new function for key Backspace there (if fn is pressed use backspace like delete if not use normally like backspace). It could work here too, but You used a $Backspace value that doesn't exist for Eject key i think... Any ideas? :wink:

edit2:

One more thing.. script don't recognizing new control button and new delete button pressed at one... so I can't make ctrl+alt+delete.... old ctrl+ regular alt + new delete work...

edit3:

I tried everything... but doesn't work repeating on del key.. I tried loop but this deleting for ever on one del click...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 8th, 2008, 2:20 pm 
Offline

Joined: April 6th, 2008, 2:46 pm
Posts: 8
Anyone? :cry: :oops:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 9th, 2008, 3:21 am 
Offline

Joined: April 1st, 2008, 4:37 pm
Posts: 24
Location: Netherlands
Just build on what's already there.

kyvaith wrote:
I tried to find answer in script that you submitted three posts ago for me and... It works there with fn+backspace - it's deleting by holding combination of keys, but you declared new function for key Backspace there (if fn is pressed use backspace like delete if not use normally like backspace). It could work here too, but You used a $Backspace value that doesn't exist for Eject key i think... Any ideas? :wink:

Yes, you probably need to use a loop, or a SetTimer. So:

Code:
if (EjectValue = 8) {
    PressedDelete := 1
} else {
    PressedDelete := 0
}

Now you know that this value is set correctly, depending on which key is pressed. Now *outside* this function, which retrieves the HID data, do something with this value. Loop delete, until PressedDelete = 0, or something in that direction.

kyvaith wrote:
One more thing.. script don't recognizing new control button and new delete button pressed at one... so I can't make ctrl+alt+delete.... old ctrl+ regular alt + new delete work...

You already know when and if the Fn *and* Eject keys are pressed. So you can add to the script:

Code:
if (EjectValue = 8 && FnValue=16) {
   CtrlDelPressed := 1
} else {
   CtrlDelPressed := 0
}

Then, when pressing Alt, do something depending on the value CtrlDelPressed. Check the documentation for "GetKeyState". This is the same thing, except since they're not keys that AHK detects by default, you set their state using this trick.


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

Joined: April 6th, 2008, 2:46 pm
Posts: 8
Hi again...

Well,I have bad news :cry:

I couldn't get this to work... I thinking about this by few days, but I'm not programist, and I couldn't find method...
I now, that this is to much, because You are here only to show the way how it's works, but maybe You could make it for me? ;/ It would be great.
If this forum supports any help points I'll give You some. :D


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 19th, 2008, 2:32 pm 
Offline

Joined: April 6th, 2008, 2:46 pm
Posts: 8
I still believe, that someone could help me. :cry: Please - it's important for me.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 10th, 2008, 8:14 am 
I've recently started using AHK, and I'm picking things up fairly easy, but I think I'm having some trouble. Firstly, thanks for the script -- I'm trying to remap the MCE button on my MCE remote.

To make things simple, let's say I want to open up Notepad with it; I can do that fine. However, once Notepad is open and active, I want the MCE button to no longer do anything -- I don't want to "accidentally" run another instance of Notepad.

Does anyone know how to do this?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 29th, 2008, 11:46 am 
Offline

Joined: May 28th, 2008, 10:10 pm
Posts: 3
Location: NL
Veil wrote:
kyvaith wrote:
Ok it works :D

Good news! This is with the Apple Wireless Keyboard.ahk right?

kyvaith wrote:
Now, what could I do to remap fn to control and ejc to del? I need only this function - no winamp controls, no real ejc function. Could you help me?

I stripped down the file to just the things you need. Copy the code below, and save it to a file. Make sure to place the file in the same directory as the DLL. Close all other scripts that are running, and then run this one.

Code:
;
; AutoHotkey Version: 1.x
; Language.........: English
; Platform.........: NT/XP/Vista
; Author...........: Thomas Veil, Leon Schoorl
; Full guide.......: http://brrp.mine.nu/fnkey/
;
; Script Function..: Remapping the Fn key
;
; Based on.........: DLLCall: Support for Human Interface devices
; By...............: Micha
; URL..............: http://www.autohotkey.com/forum/viewtopic.php?t=6367
;
; Use..............: Spread the word! Just be sure to credit the writer of the dll
;                               file and the   original config, and the authors of this file.
;

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
;#NoTrayIcon


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; DLL registration and readout of keys
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Set screen title, to set the HWND
Gui, Show, x0 y0 h0 w0, FnMapper

; Variable for the modifier key, define it here, just to be sure
fnPressed := 0

; Set the homepath to the relevant dll file
HomePath=AutohotkeyRemoteControl.dll

; Load the dll
hModule := DllCall("LoadLibrary", "str", HomePath)

; On specific message from the dll, goto this function
OnMessage(0x00FF, "InputMsg")

; Register at the dll in order to receive events
EditUsage := 1
EditUsagePage := 12
HWND := WinExist("FnMapper")
nRC := DllCall("AutohotkeyRemoteControl\RegisterDevice", INT, EditUsage, INT, EditUsagePage, INT, HWND, "Cdecl UInt")
WinHide, FnMapper


; This function is called, when a WM_INPUT-msg from a device is received
InputMsg(wParam, lParam, msg, hwnd)
{
  DeviceNr = -1
  nRC := DllCall("AutohotkeyRemoteControl\GetWM_INPUTDataType", UINT, wParam, UINT, lParam, "INT *", DeviceNr, "Cdecl UInt")
  if (errorlevel <> 0) || (nRC == 0xFFFFFFFF)
  {
     MsgBox GetWM_INPUTHIDData fehlgeschlagen. Errorcode: %errorlevel%
     goto cleanup
  }
  ;Tooltip, %DeviceNr%
  ifequal, nRC, 2
  {
    ProcessHIDData(wParam, lParam)
  }
  else
  {
     MsgBox, Error - no HID data
  }
}
Return

ProcessHIDData(wParam, lParam)
{
   ; Make sure this variable retains its value outside this function
   global fnPressed
   
  DataSize = 5000
   VarSetCapacity(RawData, %DataSize%, 0)
   RawData = 1
  nHandle := DllCall("AutohotkeyRemoteControl\GetWM_INPUTHIDData", UINT, wParam, UINT, lParam, "UINT *" , DataSize, "UINT", &RawData, "Cdecl UInt")

  ; Get the ID of the device
  ; Use the line below to check where an event was sent from, when using this code for a new HID device
  ; DeviceNumber := DllCall("AutohotkeyRemoteControl\GetNumberFromHandle", UINT, nHandle, "Cdecl UInt")

  ;FirstValue := NumGet(RawData, 0,"UChar") ; something to do with the bits, not really relevant here
  KeyStatus := NumGet(RawData, 1, "UChar")
 
  ; MsgBox, Keystatus: %KeyStatus%
 
  ; Filter the correct bit, so that it corresponds to the key in question
  ; Add another Transform for a new key
 
  ; Filter bit 5 (Fn key)
  Transform, FnValue, BitAnd, 16, KeyStatus
 
  ; Filter bit 4 (Eject key)
  Transform, EjectValue, BitAnd, 8, KeyStatus
   
  if (FnValue = 16) {
      Send, {Ctrl down}
  } else {
      Send, {Ctrl up}
  }
 
  if (EjectValue = 8) {
      Send, {Delete}
  }
 
} ; END: ProcessHIDData

; If there was an error retrieving the HID data, cleanup
cleanup:
DllCall("FreeLibrary", "UInt", hModule)  ; It is best to unload the DLL after using it (or before the script exits).



ExitApp


So run this, and see if it works. The parts that are relevant for you are:

Code:
  if (FnValue = 16) {
      Send, {Ctrl down}
  } else {
      Send, {Ctrl up}
  }
 
  if (EjectValue = 8) {
      Send, {Delete}
  }

Hi,
Thanks for this script. It works, but it doesn't allow you to keep the key pressed (held down). I.e. in a second script I've remapped ctrl+right to page_down, but when pressing Fn+right, page down is pressed once. I cannot scroll to the very bottom of the page by one keypress. Instead, I do have to release Fn + right_arrow keys and press them again to do a 'page down' again.

So what I'd like to see is when pressing Fn, it will be held down until I release it. Should that be possible??


Report this post
Top
 Profile  
Reply with quote  
PostPosted: June 1st, 2008, 9:18 pm 
Offline

Joined: December 20th, 2007, 2:50 pm
Posts: 41
Location: United States of America
Micha,

Thank you for your excellent work on the "DLLCall: Support for Human Interface devices". I am studying it now in an effort to understand it, so that I can begin using it.

While doing so, I wanted to be sure I had your latest code, and went to your page:

http://www.autohotkey.net/~Micha/HIDsupport/Autohotkey.html

There I found the date code at the bottom -- 27:08:08 -- which appears to need a correction. I assume you mean August 8, 2007, rather than 2008, and that this is, indeed, the latest version.

I hope that Chris can add to AutoHotkey support for multiple input devices, such as multiple mice, multiple keyboards, and multiple keypads in the near future. Of course, there is always more to do than anyone can do, and we are all so grateful for what AutoHotkey is already offering.

My goal is to use two mice simultaneously. The first mouse would work as a regular mouse. The second mouse would serve as an inexpensive source of some additional programmable buttons for an Assistive Technology application. But I must somehow block the pass-through of the second mouse's normal signals to WinXP so that only the substituted hotkeys are executed. I see that there is some discussion of this type of issue on the Forum, and I am hoping to find a solution.

Again, my appreciation for your good work.

Regards,

Ron1


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 2nd, 2008, 7:05 pm 
Offline

Joined: November 15th, 2005, 11:15 am
Posts: 537
Location: Germany
Hi, Ron1
thanks for your kind words.
I've corrected the date. I really meant 2007 :-)

For your problem with 2 mice I have no idea how to achive this. If you plug in 2 mice, you can use both with windows.
You want to deavticate the movements of the second mouse but the buttons should be used by your script.
I'm not sure if this is possible at all

Ciao
Micha


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 8th, 2008, 3:29 pm 
I've looked over the instructions and guides for mapping special keys using this driver. And there are two questions/issues I have with the procedure:


1. When using the Register Tool, how do you choose the right device, Useage and Useage Page? Do you just randomly start choosing devices and randomly type different numbers into the Useage and Useage Page fields until it works?

2. What happens with all the attempts you make registering trial and errors? Are you making changes to your system that aren't going to be undone? Or are they undone once you exit the script? Or can you do something afterwards to delete all the ones you tried except for the final combination that worked?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 8th, 2008, 5:02 pm 
Offline

Joined: November 15th, 2005, 11:15 am
Posts: 537
Location: Germany
Hi Lizzy,
Quote:
1. When using the Register Tool, how do you choose the right device, Useage and Useage Page?

Mouse (2,1) and keyboard (6,1) have fix values. For HID-Devices I'm calling the API of GetRawInputDeviceInfo which filles an struct with a lot of infos of the device. The values for Usage and UsagePage are retrieved by this call.


Quote:
2. What happens with all the attempts you make registering trial and errors? Are you making changes to your system that aren't going to be undone? Or are they undone once you exit the script? Or can you do something afterwards to delete all the ones you tried except for the final combination that worked?

If you are registering all devices, you'll receive all input messages.
I've found the API call RegisterRawInputDevices but I haven't found an UN-RegisterRawInputDevices. A member wrote that you can use RegisterRawInputDevices with the parameter RIDEV_REMOVE to cancel receiving the messages but I haven't implemented or tested that yet.
You have to provide a window which receives the messages (I've used the ahk-window) If you exit the script the window is destroyed and no more messages are received but it's possible that the system still tries to send the message but cannot find the window any more.

My dll is just a wrapper for API-calls with structs with was complicated and errorprone with ahk. Now you could use helperscripts from other members to create the struct and calling the api directly.
I still like to use dlls to hide complicated things.
I'm very busy at the moment so I think I cannot implement or test the RIDEV_REMOVE flag this year. If you want to you can call the api directly. Have a look at the MSDN documentation for RegisterRawInputDevices.
Ciao
Micha


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 8th, 2008, 9:00 pm 
Micha wrote:

Quote:

2. What happens with all the attempts you make registering trial and errors? Are you making changes to your system that aren't going to be undone? Or are they undone once you exit the script? Or can you do something afterwards to delete all the ones you tried except for the final combination that worked?




If you are registering all devices, you'll receive all input messages.
I've found the API call RegisterRawInputDevices but I haven't found an UN-RegisterRawInputDevices. A member wrote that you can use RegisterRawInputDevices with the parameter RIDEV_REMOVE to cancel receiving the messages but I haven't implemented or tested that yet.
You have to provide a window which receives the messages (I've used the ahk-window) If you exit the script the window is destroyed and no more messages are received but it's possible that the system still tries to send the message but cannot find the window any more.




I'm still unclear what the scope of the changes will be. If I run the register tool, register a bunch of stuff through trial and error to find what I need, and reboot - will the OS be in the exact same state and configuration it was before I ever ran the tool? Or will it have been changed?


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Cerberus, Google Feedfetcher, oldbrother and 15 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