朴实无华且枯燥的ahk模板生成工具

以前看过一个社区上发的网页上的,可以自己填写参数生成ahk语句的工具,但是那个玩意等于还要泥自己去spy里面搞坐标啊,窗口名字啊之类的东西,感觉只是完成了第一步,第二步没有完成等于

所以我自己搞了个工具来根据你鼠标的位置和窗口来生成对应的代码

对标的就是那个网页般的工具,那个工具其实偶尔还有访问问题…

命令这次只是简单的写了一下,涵盖了一些比较常用的和用到坐标和窗口名字的,其他的下次看看有没有更好的方法来展现

 

之前做过一个生成模板代码的工具,使用了几个月发现还是有些不太爽的问题,于是今天重新做了一个

效果大概是这样的

朴实无华且枯燥的ahk模板生成工具

和之前的工具最大的区别是不用一句句生成了,一口气根据信息生成所有的模板,几乎涵盖了常用的所有简单的内置命令,如果想要加入别的,自己加上就可以了.

分享一下源码

c:=s:=a:=0
#NoTrayIcon 									;不显示托盘图标
#Persistent ;~让脚本持久运行
#SingleInstance,Force ;~运行替换旧实例


; Gui dev:Add, Edit ,xs-4 w500 h300 Hwndhedit vedit1,%Content%
; Gui dev:submit, NoHide
; return

#k:: Gosub GetCode



GetCode:
xpos:=ypos:=Title:=class:=ProcessName:=xScreen:=yScreen:=""
    ;gui主体部分
    Gui dev:Destroy
    ; gui dev:+AlwaysOnTop
    Gui dev:Add, Text, w-2 h-2 section,
    ; Gui dev:add, DropDownList,x+5 w120 vwhat ,截图找点|复制选中|复制滚动
    For k,v in ["Help","Copy","保存"]
        Gui dev:Add, Button, x+5 w50 g%v%,%v%
    
    ;获取必要的信息
    CoordMode,Mouse, Window
    MouseGetPos, xpos, ypos
    WinGetTitle, Title, A
    WinGet,ProcessName,ProcessName ,A
    WinGetClass, class, A
    CoordMode,Mouse, Screen
    MouseGetPos, xScreen, yScreen


;常用代码模板
Content:=""
Content=
(
;标题: Title
;进程名: ahk_exe %ProcessName% 类名:ahk_class %class%
;win坐标: x %xpos%   y %ypos% 
;屏幕坐标: x%xScreen%  y %yScreen% 


;点击屏幕坐标
ClickPosition(%xScreen%, %yScreen%, 1, 0, "Screen", true)
;等待窗口
winwait, %Title% ahk_exe %ProcessName% ahk_class %class%
;control点击对应坐标
ControlClick,x%xpos% y%ypos%,%Title% ahk_exe %ProcessName%
;向窗口发送按键
ControlSend,, ^{enter},%Title% ahk_exe %ProcessName%
;win坐标点击这个点
Click,%xpos%,%ypos%
;激活窗口
WinActivate,%Title% ahk_exe %ProcessName%
;仅该窗口适用
#IfWinActive, ahk_exe %ProcessName%

#IfWinActive
;添加这个窗口到组
GroupAdd,组名,ahk_exe %ProcessName%
;根据屏幕坐标生成ttp
CoordMode, ToolTip, Screen
#Persistent
ToolTip, test,%xScreen%, %yScreen%
SetTimer, RemoveToolTip, -3000
return
RemoveToolTip:
ToolTip
return
)
Gui dev:Add, Edit ,xs-4 w700 h500 Hwndhedit vedit1,%Content%
Clipboard:="" , Clipboard:=Content
Gui dev:Show, ,常用代码模板
Return

Copy:
    GuiControlGet,test,,edit1
    Clipboard:=test
    ClipWait,1,1
Return

Help:
    MsgBox,
    (
        快捷键按下就可以生成代码,之后复制自己想要的就可以了
    )

Return


保存:
    GuiControlGet,test,,edit1
    Clipboard:=test
    ClipWait,1,1
    FileSelectFolder, OutputVar,, 3
    FileAppend,%Clipboard%,%OutputVar%\%A_Now%.ahk,UTF-8-RAW
    ; MsgBox,%OutputVar% . "\test.txt"
Return
; 多点命令生成:
; switch what
; {
; case "截图找点":
;     c+=1
;     if (c=1)
;     {
;         x1:=xpos
;         y1:=ypos
;         MsgBox,,Select the Second point,The First point is %x1% `, %y1%,1
;     }
;     if (c=2)
;     {
;         x2:=xpos
;         y2:=ypos
;         w:=x2-x1
;         h:=y2-y1
;         c:=0
;         Content=
;         (
;             ImagePutClipboard([ %x1%,%y1%,%w%,%h%])	
;         )
;         ; ScreenCapture(%x1% "|" %y1% "|" %w% "|" %h%, 1, , "Clipboard")
;         MsgBox,,Paste,The Second point is %x2% `, %y2% and w is %w% `, h is %h%,1
;     }

; case "复制选中":
;     s+=1
;     if (s=1)
;     {
;         x1:=xpos
;         y1:=ypos
;         MsgBox,,Select the Second point,The First point is %x1% `, %y1%,1
;     }
;     if (s=2)
;     {
;         x2:=xpos
;         y2:=ypos
;         s:=0
;         Content=
;         (
;             CopySelect(%x1%,%y1%,%x2%,%y2%,OutputVar)
;         )
;         MsgBox,,Paste,The Second point is %x2% `, %y2%,1
;     }

; case "复制滚动":	
;     a+=1
;     if (a=1)
;     {
;         x1:=xpos
;         y1:=ypos
;         MsgBox,,Select the Second point,The First point is %x1% `, %y1%,1
;     }

;     if (a=2)
;     {
;         x2:=xpos
;         y2:=ypos
;         MsgBox,,Select the Third point,The Second point is %x2% `, %y2%,1
;     }
;     if (a=3)
;     {
;         x3:=xpos
;         y3:=ypos
;         a:=0
;         Content=
;         (
;             CopyScrollArea(%x1%,%y1%,%x2%,%x3%,%y3%)
;         )
;         MsgBox,,Paste,The Third point is %x3% `, %y3%,1
;     }
; }
; AppendEdit(hedit, Content)

; Return
AppendEdit(hEdit, text)
	{
		text .= A_Space
		SendMessage, 0xB1, -2, -1,, ahk_id %hEdit% ; EM_SETSEL
		SendMessage, 0xC2, 0, &text,, ahk_id %hEdit% ; EM_REPLACESEL
		SendMessage, 0x115, 7, 0,, ahk_id %hEdit% ; WM_VSCROLL
	}

给TA捐赠
共{{data.count}}人
人已捐赠
其他

gui显示序号的工具

2022-8-11 5:53:44

其他函数教程

AHK演奏——Music库

2022-8-11 21:11:57

3 条回复 A文章作者 M管理员
  1. AHK中文社区
    1河许人给您打赏了¥2
个人中心
购物车
优惠劵
有新私信 私信列表
搜索