Logitech K700 Fn re-mapping Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Eden
Posts: 2
Joined: 14 Nov 2018, 09:02

Logitech K700 Fn re-mapping

14 Nov 2018, 14:06

Logitch K700 is the best KB, esp. in size, responsiveness, quietness, durability, battery lifetime and most important: no driver or re-pairing for multi-OS user!
-----
Referring to :
https://autohotkey.com/board/topic/7434 ... l-keypres/

Did anyone try that, I cannot go through...
Don't know if it still works with the current AutoHotkey version?

at least, the gui line is not working or responding...
(PS: I did put the 2 files in the same folder(i.e. AHKHID.ahk and AutohotkeyRemoteControl.dll)
------- more specifically ----------------
e.g. this 2 line does showup anything:

Code: Select all

;Create GUI to receive messages
Gui, +LastFound
hGui := WinExist()
Last edited by Eden on 18 Nov 2018, 04:52, edited 4 times in total.
Eden
Posts: 2
Joined: 14 Nov 2018, 09:02

Re: Logitech K700 Fn remapping  Topic is solved

18 Nov 2018, 04:34

Finally I solve these myself. Yes need to use previous version(v1) of AutoHotKey.
Let me note my learning here:
This method uses Micha's DLL & werdna219 & davieboynj 's scripts
  • Download the v1.0 of AHK;
  • use TheGood's scripts:
    1. Example 1 and most important example 2 to detect the unique (Usage & UsegPage) for K700, thus the script only remaps K700, no intervention with native (laptop) keyboard esp. for its hotkeys.
    2. Also to mention using exampe_2, each time a new HID registration need script restart, then press Fn as trigger to verify the registration (Usage & UsegPage), note the feedback code ( if they are same as the K700 script)
  • Micha's dll needs to be in the same directory of K700.ahk (not yet use TheGood's non-dll version)
Further actions:
1. For volume mute and mic mute (succeed);
2. brightness change (still learning)
3 .

Many THANKS to all these experts and enthusiasts here! :thumbup: :bravo:

Code: Select all

; AutoHotkey Version: 1.x
; Language:       English
; Platform:       Windows 7
; Author:        werdna219 & davieboynj 
;  //autohotkey.com/board/topic/74343-google-tv-revue-keyboard-k700-script-full-funtional-keypres/?p=524041
; Script Function:
;   Template AutoHotkey script.
;
; #include BrightnessSetter.ahk ; if you saved the class as its own file
;Path to AutohotkeyRemoteControl.dll
HomePath=AutohotkeyRemoteControl.dll
;HomePath=release\AutohotkeyRemoteControl.dll
;Load the dll
hModule := DllCall("LoadLibrary", "str", HomePath)  ; Avoids the need for DllCall() in 
OnMessage(0x00FF, "InputMsg")
DetectHiddenWindows, on
;SetTimer,UPDATEDSCRIPT,1000 

;Register my device K700 only, native KB no effect
; Both EditUsage & EditUsagePage values can be detected using "AutoHotkeyRemoteControlDLL.ahk"
; Check if Fn responsive on K700, follwing values were determined :
EditUsage = 1
EditUsagePage = 12
Gui, Show, x0 y0 h0 w0, Autohotkey HID-Support 
;HWND := WinActive("F:\myprg\Win\Autohotkeyremote\AutohotkeyRemoteControl\RemoteControl.ahk")
HWND := WinExist("Autohotkey HID-Support")
nRC := DllCall("AutohotkeyRemoteControl\RegisterDevice", INT, EditUsage, INT, EditUsagePage, INT, HWND, "Cdecl UInt")
if (errorlevel <> 0) || (nRC == -1)
{
   MsgBox RegisterDevice fehlgeschlagen. Errorcode: %errorlevel%
   Gosub cleanup
}

Winhide, Autohotkey HID-Support
return

InputMsg(wParam, lParam, msg, hwnd)
{  
  DataSize = 5000
   VarSetCapacity(RawData, %DataSize%)
 ;  MsgBox eingetroffen %wParam% %lParam% %msg% %HWND%
   ;Write something into the var, so the script won't be aborted :
  ;(g_script.ScriptError("This DllCall requires a prior VarSetCapacity. The program is now unstable and will exit.");)
   RawData = 1
  nRC := DllCall("AutohotkeyRemoteControl\GetWM_INPUTHIDData", UINT, wParam, UINT, lParam, "UINT *" , DataSize, "UINT", &RawData, "Cdecl UInt")    
  if (errorlevel <> 0) || (nRC == -1) 
  {
     MsgBox GetWM_INPUTHIDData fehlgeschlagen. Errorcode: %errorlevel%
     Gosub cleanup
  }     
    loop, %DataSize%
  {
    ;Zahl := ExtractInteger(RawData, a_index-1,false,1)
    Zahl := NumGet(RawData, a_index-1,"UChar")
    Zahl := Dez2Hex(Zahl)    
; msgbox Vals = %Vals%   Zahl =%Zahl% 
    Vals = %Vals%%Zahl%     
  }  
  
; ======================================             
  ifequal, Vals, 03B0000000, gosub play
  ifequal, Vals, 03B4000000, gosub prev
  ifequal, Vals, 03B3000000, gosub next
  ifequal, Vals, 03B1000000, gosub pause
  ifequal, Vals, 03F3010000, gosub AVR
  ifequal, Vals, 03FC010000, gosub STB
  ifequal, Vals, 03FE010000, gosub TV
  ifequal, Vals, 03EA000000, gosub Volume_Down
  ifequal, Vals, 03E9000000, gosub volume_up
  ifequal, Vals, 0389000000, gosub googleTV
  ifequal, Vals, 038D000000, gosub guide
  ifequal, Vals, 039a000000, gosub dvr
  ifequal, Vals, 039C000000, gosub channel_up
  ifequal, Vals, 039D000000, gosub channel_down

  ifequal, Vals, 0323020000, gosub home
  ifequal, Vals, 032A020000, gosub favorite
  ifequal, Vals, 03F1010000, gosub maximize

  ifequal, Vals, 03F0010000, gosub function
  ifequal, Vals, 03F001B600, gosub function_prev
  ifequal, Vals, 03F001B500, gosub function_next
  ifequal, Vals, 03F001B000, gosub function_play
  ifequal, Vals, 03F001B700, gosub function_pause
  ifequal, Vals, 03F0012300, gosub function_home
  ifequal, Vals, 03F001B200, gosub function_favorite
  ifequal, Vals, 03F001f100, gosub function_maximize
; Fn 1 ~ 10 
  ifequal, Vals, 03F0011e00, gosub function_1
  ifequal, Vals, 03F0011f00, gosub function_2
  ifequal, Vals, 03F0012000, gosub function_3
  ifequal, Vals, 03F0012100, gosub function_4
  ifequal, Vals, 03F001F500, gosub function_5
  ifequal, Vals, 03F001F400, gosub function_6
  ifequal, Vals, 03F001F700, gosub function_7
  ifequal, Vals, 03F001F600, gosub function_8
  ifequal, Vals, 03F001EF00, gosub function_9
  ifequal, Vals, 03F001FF00, gosub function_0
  ifequal, Vals, 03F0012E00, gosub function_-
  ifequal, Vals, 03F0012D00, gosub function_=

  ;ifequal, Vals, 0300000000, gosub pressup
  ;Mute is at the bottom of this code 
}

return
donothing:
return

;/////////////////////////////////////////////////// 
play:
   IfWinActive, ahk_class eHome Render Window
   {
        gosub donothing
        return
   }

   ;else
   send {media_play}
return
;////////////////////////////////////////////////////

;/////////////////////////////////////////////////// 
prev:
   IfWinActive, ahk_class eHome Render Window
   {
        gosub donothing
       return
   }

   ;else
   send {media_prev} 
return
;/////////////////////////////////////////////////// 

;/////////////////////////////////////////////////// 
next:
   IfWinActive, ahk_class eHome Render Window
   {
        gosub donothing
        return
   }

   ;else
   send {media_Next}
return
;/////////////////////////////////////////////////// 

;/////////////////////////////////////////////////// 
stop:
   IfWinActive, ahk_class eHome Render Window
   {
        gosub donothing
        return
   }

   ;else
   send {media_stop}
return
;/////////////////////////////////////////////////// 

;/////////////////////////////////////////////////// 
pause:
   IfWinActive, ahk_class eHome Render Window
   {
        gosub donothing
        return
   }

   ;else
   send {media_pause}
return
;/////////////////////////////////////////////////// 

AVR:
run %windir%\ehome\ehshell.exe /playslideshowwithmusic /nostartupanimation /directmedia:general
return

STB:
DllCall("PowrProf\SetSuspendState", "int", 0, "int", 0, "int", 0)
return

TV:
; run, taskkill /im ehshell.exe,,hide
return



Volume_Down:
Send {volume_down}
return

Volume_up:
send {volume_up}
return

googleTV:   ; change to mute mic
; run %windir%\ehome\ehshell.exe “/mcesuperbar://tv?live=true” /nostartupanimation /directmedia:general
; https://autohotkey.com/boards/viewtopic.php?t=15509
SoundSet, +1, MASTER, mute,7 ; 7 is the mic id number use the code in above URL to detect id 
SoundGet, master_mute, , mute, 7
return

guide:   ; t.b. brightness  down
;	BrightnessSetter.SetBrightness(-10)
return

DVR:  	; t.b. brightness up
; run %windir%\ehome\ehshell.exe /directmedia:tv /nostartupanimation /directmedia:general
;	BrightnessSetter.SetBrightness(+10)
return

;  Ch+ changes to PgUp
channel_Up:
send {PgUp}
return

; Ch- changes to PgDn
channel_Down:
send {PgDn}
return

function:
return



home:
return

favorite:
run %windir%\ehome\ehshell.exe /nostartupanimation /directmedia:general
return
 
maximize:
  WinGet MX, MinMax, A
   If MX
        WinRestore A
   Else WinMaximize A
return



function_prev:
send {media_prev}
return

function_next:
send {media_next}
return

function_play:
send {media_play}
return

function_pause:
send {media_stop}
return

function_home:
send ^r
return

function_favorite:
run, taskkill /im ehshell.exe,,hide
return

function_maximize:
  WinGet MX, MinMax, A
   If MX
        WinRestore A
   Else WinMaximize A
return

function_1:
send {F1}
return

function_2:
send {F2}
return

function_3:
send {F3}
return

function_4:
send {F4}
return

function_5:
send {F5}
return

function_6:
send {F6}
return

function_7:
send {F7}
return

function_8:
send {F8}
return

function_9:
send {F9}
return

function_0:
send {F10}
return

function_-:
send {F11}
return

function_=:
send {F12}
return

cleanup:
DllCall("FreeLibrary", "UInt", hModule)  ; It is best to unload the DLL after using it (or before the script exits).
ExitApp


UPDATEDSCRIPT: 
FileGetAttrib,attribs,%A_ScriptFullPath% 
IfInString,attribs,A 
{ 
   FileSetAttrib,-A,%A_ScriptFullPath% 
   SplashTextOn,,,Updated script, 
   Sleep,500 
   Reload 
} 
Return 

SendDVDKey(Key)
{
  IfWinNotExist , InterVideo WinDVD 7
  {
    return 
  }
  Winactivate, InterVideo WinDVD 7
  Send, %Key%
}


Dez2Hex(Number)
{
    format = %A_FormatInteger%    ; save original integer format
    SetFormat Integer, Hex        ; for converting bytes to hex
    Number += 0
    SetFormat Integer, %format%   ; restore original format
    StringTrimLeft, Number, Number, 2
    Stringlen := StrLen(Number)
    if Stringlen < 2
    Number = 0%Number%
    return Number
}   

; volume_mute::RButton
LWin::Alt
*Tab::AltTab
Browser_Home::AppsKey
;Media_fastfwd::AppsKey
;Media_rewind::AppsKey


Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, drani and 207 guests