切换到宽版
爱科技/爱创意/爱折腾/爱极致;技术知识分享平台,点击进入新版数码之家网站
  • 2390阅读
  • 5回复

[电脑]罗技K700键盘autohotkey 的代码 [复制链接]

上一主题 下一主题
离线jj_m
 
发帖
10
M币
927
专家
0
粉丝
2
只看楼主 倒序阅读 我要置顶 楼主  发表于: 2018-03-20

罗技K700键盘的代码,之前论坛有朋友提供了。但是大家都没有M币下载不了。现在把script发出来,供大家学习。把下面的代码复制到一个文本文件,修改文件后缀为ahk,用autohotkey启动。

; AutoHotkey Version: 1.x
; Language:       English
; Platform:       Windows 7
; Author:        Werdna219
;
; Script Function:
;   Template AutoHotkey script.
;
;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
EditUsage = 136
EditUsagePage = 65468
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
}
;Register another device
EditUsage = 1
EditUsagePage = 12
nRC := DllCall("AutohotkeyRemoteControl\RegisterDevice", INT, EditUsage, INT, EditUsagePage, INT, HWND, "Cdecl UInt")
Winhide, Autohotkey HID-Support
start := 0
step := 15
loop
{
  if (fn_down=1)
  {
     if (start=0)
     {
       MouseGetPos, xx, yy
       start := 1      
     }  
     else
     {
       MouseGetPos, _x, _y
       loop
       {
         curr := (_y - yy) // step
         if (curr < 0)
         {
           ;SystemCursor(0)
           send {wheelup}
           sleep 5
           _y := _y + step
           ;pos--
         }  
         else
         if (curr > 0)
         {
           ;SystemCursor(0)
           send {wheeldown}
           sleep 5
           _y := _y - step
           ;pos++
         }
         if (curr = 0)
           break
       }
       loop
       {
         curr := (_x - xx) // step
         if (curr < 0)
         {
           ;SystemCursor(0)
           send {wheelleft}
           sleep 5
           _x := _x + step
           ;pos--
         }  
         else
         if (curr > 0)
         {
           ;SystemCursor(0)
           send {wheelright}
           sleep 5
           _x := _x - step
           ;pos++
         }
         if (curr = 0)
           break
       }
       MouseMove, _x, _y, 0
     }
  }
  else
  if (start = 1)
  {
    start := 0
    SystemCursor(1)
    MouseMove, xx, yy, 0
  }
  sleep 25
}
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)    
    Vals = %Vals%%Zahl%    
  }  
  ;msgbox %vals%
  
  ;return
                
  ifequal, Vals, 03B0000000, gosub play
  ifequal, Vals, 03B4000000, gosub prev
  ifequal, Vals, 03B3000000, gosub next
  ifequal, Vals, 03B1000000, gosub pause
  ifequal, Vals, 03F1010000, gosub unkonwn
  ifequal, Vals, 032A020000, gosub star
  ;默认就可以用
  ;ifequal, Vals, 0324020000, gosub arrow
  ;ifequal, Vals, 0323020000, gosub house
  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, 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, 03F101F100, gosub function_unkonwn
  
  ifequal, Vals, 03F0011e00, gosub function_f1
  ifequal, Vals, 03F0011f00, gosub function_f2
  ifequal, Vals, 03F0012000, gosub function_f3
  ifequal, Vals, 03F0012100, gosub function_f4
  ifequal, Vals, 03F001f500, gosub function_f5
  ifequal, Vals, 03F001f400, gosub function_f6
  ifequal, Vals, 03F001f700, gosub function_f7
  ifequal, Vals, 03F001f600, gosub function_f8
  ifequal, Vals, 03F001ef00, gosub function_f9
  ifequal, Vals, 03F001ff00, gosub function_f10
  ifequal, Vals, 03F0012e00, gosub function_f11
  ifequal, Vals, 03F0012d00, gosub function_f12

  ifequal, Vals, 0300000000, gosub function_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_pause}
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
;///////////////////////////////////////////////////
;///////////////////////////////////////////////////
pause:
   IfWinActive, ahk_class eHome Render Window
   {
        gosub donothing
        return
   }
   ;else
   send {media_play_pause}
return
;///////////////////////////////////////////////////
unkonwn:
Run calc.EXE
return
star:
return
AVR:
Msgbox AVR
return
;Send Computer into standby
STB:
DllCall("PowrProf\SetSuspendState", "int", 0, "int", 0, "int", 0)
return
TV:
Msgbox TV
return
Volume_Down:
Send {volume_down}
return
Volume_up:
send {volume_up}
return
googleTV:
Msgbox googleTV
return
guide:
Msgbox Guide
return
dvr:
Msgbox DVR
return
channel_Up:
return
channel_Down:
return
function:
fn_down := 1
return
function_pressup:
fn_down := 0
return

function_prev:
send {media_prev}
return
function_next:
send {media_next}
return
function_play:
send {media_play_pause}
return
function_pause:
send {medai_play_pause}
return
function_unkonwn:
return
function_f1:
send {f1}
return
function_f2:
send {f2}
return
function_f3:
send {f3}
return
function_f4:
send {f4}
return
function_f5:
send {f5}
return
function_f6:
send {f6}
return
function_f7:
send {f7}
return
function_f8:
send {f8}
return
function_f9:
send {f9}
return
function_f10:
send {f10}
return
function_f11:
send {f11}
return
function_f12:
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
}  
SystemCursor(OnOff=1) ; INIT = "I","Init"; OFF = 0,"Off"; TOGGLE = -1,"T","Toggle"; ON = others
{
static AndMask, XorMask, $, h_cursor
,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 ; system cursors
, b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13 ; blank cursors
, h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11,h12,h13 ; handles of default cursors
if (OnOff = "Init" or OnOff = "I" or $ = "") ; init when requested or at first call
{
$ = h ; active default cursors
VarSetCapacity( h_cursor,4444, 1 )
VarSetCapacity( AndMask, 32*4, 0xFF )
VarSetCapacity( XorMask, 32*4, 0 )
system_cursors = 32512,32513,32514,32515,32516,32642,32643,32644,32645,32646,32648,32649,32650
StringSplit c, system_cursors, `,
Loop %c0%
{
h_cursor := DllCall( "LoadCursor", "uint",0, "uint",c%A_Index% )
h%A_Index% := DllCall( "CopyImage", "uint",h_cursor, "uint",2, "int",0, "int",0, "uint",0 )
b%A_Index% := DllCall("CreateCursor","uint",0, "int",0, "int",0
, "int",32, "int",32, "uint",&AndMask, "uint",&XorMask )
}
}
if (OnOff = 0 or OnOff = "Off" or $ = "h" and (OnOff < 0 or OnOff = "Toggle" or OnOff = "T"))
$ = b ; use blank cursors
else
$ = h ; use the saved cursors
Loop %c0%
{
h_cursor := DllCall( "CopyImage", "uint",%$%%A_Index%, "uint",2, "int",0, "int",0, "uint",0 )
DllCall( "SetSystemCursor", "uint",h_cursor, "uint",c%A_Index% )
}
}
离线lili1983007

发帖
858
M币
79
专家
2
粉丝
5
只看该作者 1楼 发表于: 2018-03-20
请登录后查看
离线kanecon

发帖
7154
M币
10797
专家
3
粉丝
56
只看该作者 2楼 发表于: 2018-03-20
请登录后查看
离线jj_m
发帖
10
M币
927
专家
0
粉丝
2
只看该作者 3楼 发表于: 2018-03-21
回 kanecon 的帖子
请登录后查看
离线rick948

发帖
4
M币
866
专家
0
粉丝
1
只看该作者 4楼 发表于: 2019-04-06
请登录后查看
离线rick948

发帖
4
M币
866
专家
0
粉丝
1
只看该作者 5楼 发表于: 2019-04-06
回 jj_m 的帖子
请登录后查看
快速回复
限80 字节
温馨提示:欢迎交流讨论,请勿发布纯表情、纯引用等灌水帖子;以免被删除
 
上一个 下一个