[AHK]一键直达定制键盘

105 篇文章 5 订阅
14 篇文章 3 订阅

先上效果图:

以下代码关键是第33行X:\AHK\PNG\1064846.png 的 png文件,需要放到本地目录,请自行下载下面键盘帽图片。

 

	Gui, MenuBtns:Font, s11 
	Gui, MenuBtns:Show , w800 h600, 打板王
	Menu, MyMenu, Add, 添加功能, MenuHandler
	Menu, MyMenu, Add, 删除功能, MenuHandler
	Menu, MyMenu, Add, 查看功能, MenuHandler  ; 在子菜单下添加另一个菜单项.
	; ------------------------------------------------------------------------------
	; Settings
	IniFile := "cfg.ini"
	BtnCount := 24       ; total number of buttons
	BtnsPerColumn := 6   ; buttons per column
	columns:=4			;24/6
	BtnW := 100          ; button width
	BtnH := 100           ; button height
	横向间距:=5
	纵向间距:=5
	LMargin:=10
	TMargin:=10
	setmode:=0

	; ------------------------------------------------------------------------------
	map:={1:"ESC",2:"数量1",3:"数量2",4:"数量3",5:"-",6:"金额/股数", 7:"账户切换",8:"快捷1",9:"快捷2",10:"快捷3",11:"+",12:"撤卖", 13:"融资账户",14:"快捷4",15:"快捷5",16:"快捷6",17:"买",18:"撤买", 19:"账户通",20:"资金联",21:"预卖",22:"预买",23:"卖",24:"批量下单"}


	Loop, %columns% {		

		y := a_index = 1 ? (TMargin, z := 0) : (y +(BtnH+纵向间距), z +=BtnsPerColumn)  ;TMargin=10是整个输出区域离上边的距离
		Loop, %BtnsPerColumn% {		
			i := A_index
				key:=z+i
			Gui, MenuBtns:add, button, % "HwndBtnH" key " vBtn" key " gSet x" LMargin+(i-1)*(BtnW+横向间距) " y" y " w" BtnW " h" BtnH cRed , %  map[key] ;"`n-------`n`n" Function  ;LMargin=10是整个输出区域离左边的距离
			hwndValue:="BtnH" key
			
			GuiButtonIcon(%hwndValue%, "X:\AHK\PNG\1064846.png", 0, "w120 h120 r0 t20")


		}
	}
	 
	GuiEscape:
	GuiClose:
	Esc::
	  ExitApp
	MenuHandler:
	MsgBox You selected %A_ThisMenuItem% from the menu %A_ThisMenu%.
	return 

	MenuBtnsGuiContextMenu:
	{

		Menu, MyMenu, Show

	return
	}
	; ------------------------------------------------------------------------------
	;~ #z::setmode:=!setmode
	; ------------------------------------------------------------------------------
	Set:
	BtnNumber := SubStr(A_GuiControl, 4)
	if (setmode)
	{
	   GuiControlGet, BtnCaption, , %A_GuiControl%
	   Split := StrSplit(BtnCaption, "`n", " ")
	   GuiControl, SetBtns:, NewName, % Split[1]
	   GuiControl, SetBtns:, NewFunction, % Split[2]
	   Gui, +Disabled
	   Gui, SetBtns:Show, w200 h100, %BtnNumber%
	}
	else
	{
		Menu, MyMenu, Show

	}
	Return

	GuiButtonIcon(Handle, File, Index := 1, Options := "")
	{
		RegExMatch(Options, "i)w\K\d+", W), (W="") ? W := 16 :
		RegExMatch(Options, "i)h\K\d+", H), (H="") ? H := 16 :
		RegExMatch(Options, "i)s\K\d+", S), S ? W := H := S :
		RegExMatch(Options, "i)l\K\d+", L), (L="") ? L := 0 :
		RegExMatch(Options, "i)t\K\d+", T), (T="") ? T := 0 :
		RegExMatch(Options, "i)r\K\d+", R), (R="") ? R := 0 :
		RegExMatch(Options, "i)b\K\d+", B), (B="") ? B := 0 :
		RegExMatch(Options, "i)a\K\d+", A), (A="") ? A := 4 :
		Psz := A_PtrSize = "" ? 4 : A_PtrSize, DW := "UInt", Ptr := A_PtrSize = "" ? DW : "Ptr"
		VarSetCapacity( button_il, 20 + Psz, 0 )
		NumPut( normal_il := DllCall( "ImageList_Create", DW, W, DW, H, DW, 0x21, DW, 1, DW, 1 ), button_il, 0, Ptr )	; Width & Height
		NumPut( L, button_il, 0 + Psz, DW )		; Left Margin
		NumPut( T, button_il, 4 + Psz, DW )		; Top Margin
		NumPut( R, button_il, 8 + Psz, DW )		; Right Margin
		NumPut( B, button_il, 12 + Psz, DW )	; Bottom Margin	
		NumPut( A, button_il, 16 + Psz, DW )	; Alignment
		SendMessage, BCM_SETIMAGELIST := 5634, 0, &button_il,, AHK_ID %Handle%
		return IL_Add( normal_il, File, Index )
	}

有需要定制自己专属键盘的,欢迎骚扰本人,50软妹币一个功能点。

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值