分享鼠标编辑辅助

; Generated by AutoGUI 2.6.2
#SingleInstance Force
#NoEnv
; #NoTrayIcon
SetTitleMatchMode,2
SetWorkingDir %A_ScriptDir%
SetBatchLines -1
DetectHiddenWindows,on
CoordMode ,Mouse
CoordMode,Menu
; #Include %A_ScriptDir%\Toolbar.ahk
Hotkey,IfWinActive
Hotkey,RButton,显示
Hotkey,#esc,GuiClose
; Hotkey,IfWinActive,ahk_class AutoHotkeyGUI
Hotkey,RButton up,滑动点击
; Gui New, -DPIScale -Caption -0x40000000 -E0x100 -0x800000 
; Gui Show, w58 h80, Window
hToolbar := CreateToolbar()
ToolTip,鼠标辅助已启动,A_ScreenWidth/2,A_ScreenHeight/2
SetTimer,Hide辅助,-2000
Return

显示:
  if(longpress())
{
    MouseGetPos, M_X, M_Y, M_Win      ;作用窗口id
    ; MsgBox,% M_win
    M_Y1:=M_Y
    M_X1:=M_X
    M_Y:=M_Y-130
    M_X:=M_X-80
    ; MsgBox,% A_ScriptName
    gui,Font,s20
    Gui , -DPIScale -Caption -0x40000000 -E0x100 -0x800000 +AlwaysOnTop +Owner
    Gui Show, x%M_X% y%M_Y% w160 h180, 鼠标编辑辅助
    hToolbar := CreateToolbar()
    WinGet, s_win, ID , 鼠标编辑辅助 ahk_class AutoHotkeyGUI,   ;弹出选项的id
    SetTimer,Hide辅助,-500       ;这个是选项菜单无条件显示时间
}
  else
    send,{Click ,Right }    ;短按执行右键
Return

滑动点击:
MouseGetPos,h_x,h_y,h_win   ;滑动释放后的id
if (h_win=s_win)
    send,{Click}
; Else
    ; send,{Click %M_X1%,%M_Y1%,Right }
    ; send,{Click ,Right }

Return

Hide辅助:
loop 100
{
    MouseGetPos,hide_x,hide_y,hide_win
    if (hide_win=s_win)
        Sleep 70
    Else
        break
}
    WinHide,鼠标编辑辅助 ahk_class AutoHotkeyGUI
    
    ToolTip
Return
GuiEscape:
GuiClose:
{
    ToolTip,退出鼠标辅助工具
    Sleep,2000
    ExitApp
}

longpress(timeout := 150) { 
  tout := timeout/1000
  key := RegExReplace(A_ThisHotKey,"[\*\~\$\#\+\!\^]")
  KeyWait %key%, T%tout%
  return ErrorLevel
}
 
/* !z::
  if(longpress())
    MsgBox 执行长按
  else
    MsgBox 执行单击
Return 
*/

CreateToolbar() {
    ImageList := IL_Create(7)
    IL_Add(ImageList, "shell32.dll", 139)
    IL_Add(ImageList, "shell32.dll", 75)
    IL_Add(ImageList, "shell32.dll", 75)
    IL_Add(ImageList, "shell32.dll", 75)
    IL_Add(ImageList, "shell32.dll", 75)
    IL_Add(ImageList, "shell32.dll", 77)  
    IL_Add(ImageList, "shell32.dll", 77)      
    IL_Add(ImageList, "shell32.dll", 77)  
    IL_Add(ImageList, "shell32.dll", 77)  
    

    Buttons = 
    (LTrim
        _语音F4_,,wrap
        _?
        -,, WRAP        
        _!,, WRAP
        _,
        -,, WRAP            
        _。,,WRAP
        _\r
        -,, WRAP  
        _H  ,, WRAP        
        _←
        -,,Wrap
        _✘


    )

    Return ToolbarCreate("OnToolbar", Buttons,ImageList, "Flat List ShowText NoDivider Tabstop")
}

OnToolbar(hWnd, Event, Text, Pos, Id) {
    global
    If (Event != "Click") {
        Return
    }

    If (Text == "_?") {
        WinHide,鼠标编辑辅助 ahk_class AutoHotkeyGUI
        WinActivate,ahk_id %M_Win%
        ; WinWaitActive,ahk_id %M_Win%,
        Sleep,50
        Send,{?}
    } Else If (Text == "_!") {
        WinHide,鼠标编辑辅助 ahk_class AutoHotkeyGUI
        WinActivate,ahk_id %M_Win%
        ; WinWaitActive,ahk_id %M_Win%,
        Sleep,50
        Send,{!}
    } Else If (Text == "_语音F4_") {
        WinHide,鼠标编辑辅助 ahk_class AutoHotkeyGUI
        WinActivate,ahk_id %M_Win%
        ; WinWaitActive,ahk_id %M_Win%,
        Sleep,50
        Send,{F4}
                

    } Else If (Text == "_←") {
        WinHide,鼠标编辑辅助 ahk_class AutoHotkeyGUI
        WinActivate,ahk_id %M_Win%
        ; WinWaitActive,ahk_id %M_Win%,
        Sleep,50
        Send,{BackSpace}       

    } Else If (Text == "_\r") {
        WinHide,鼠标编辑辅助 ahk_class AutoHotkeyGUI
        WinActivate,ahk_id %M_Win%
        ; WinWaitActive,ahk_id %M_Win%,
        Sleep,50
        Send,{Enter}       

    } Else If (Text == "_,") {
        WinHide,鼠标编辑辅助 ahk_class AutoHotkeyGUI
        WinActivate,ahk_id %M_Win%
        ; WinWaitActive,ahk_id %M_Win%,
        Sleep,50
        Send,`,       

    } Else If (Text == "_。") {
        WinHide,鼠标编辑辅助 ahk_class AutoHotkeyGUI
        WinActivate,ahk_id %M_Win%
        ; WinWaitActive,ahk_id %M_Win%,
        Sleep,50
        Send,`.       
    } Else If (Text == "_H") {
        WinHide,鼠标编辑辅助 ahk_class AutoHotkeyGUI
        WinActivate,ahk_id %M_Win%
        Winget,PN,ProcessName,ahk_id %M_Win%
        WinGetTitle,wn,ahk_id %M_Win%
        Sleep,50
        ; MsgBox,% M_Win "   " wn
        if (pn="Typora.exe")         ;指定进程执行某个动作
            send,+{Enter}
     
    } Else If (Text == "_✘") {
        WinHide,鼠标编辑辅助 ahk_class AutoHotkeyGUI
        WinActivate,ahk_id %M_Win%
        ; WinWaitActive,ahk_id %M_Win%,
        Sleep,50
        Send,^z      
    }
}

;=============

;=============
ToolbarCreate(Handler, Buttons, ImageList := "", Options := "Flat List ToolTips", Extra := "", Pos := "", Padding := "") {
    Static TOOLTIPS := 0x100, WRAPABLE := 0x200, FLAT := 0x800, LIST := 0x1000, TABSTOP := 0x10000,  BORDER := 0x800000, TEXTONLY := 0
    Static BOTTOM := 0x3, ADJUSTABLE := 0x20, NODIVIDER := 0x40, VERTICAL := 0x80
    Static CHECKED := 1, HIDDEN := 8, WRAP := 32, DISABLED := 0 ; States
    Static CHECK := 2, CHECKGROUP := 6, DROPDOWN := 8, AUTOSIZE := 16, NOPREFIX := 32, SHOWTEXT := 64, WHOLEDROPDOWN := 128 ; Styles

    StrReplace(Options, "SHOWTEXT", "", fShowText, 1)
    fTextOnly := InStr(Options, "TEXTONLY")

    Styles := 0
    Loop Parse, Options, %A_Tab%%A_Space%, %A_Tab%%A_Space% ; Parse toolbar styles
        IfEqual A_LoopField,, Continue
        Else Styles |= A_LoopField + 0 ? A_LoopField : %A_LoopField%

    If (Pos != "") {
        Styles |= 0x4C ; CCS_NORESIZE | CCS_NOPARENTALIGN | CCS_NODIVIDER
    }

    Gui Add, Custom, ClassToolbarWindow32 hWndhWnd g_ToolbarHandler -Tabstop %Pos% %Styles% %Extra%
    _ToolbarStorage(hWnd, Handler)

    TBBUTTON_Size := A_PtrSize == 8 ? 32 : 20
    Buttons := StrSplit(Buttons, "`n")
    cButtons := Buttons.Length()
    VarSetCapacity(TBBUTTONS, TBBUTTON_Size * cButtons , 0)

    Index := 0
    Loop %cButtons% {
        Button := StrSplit(Buttons[A_Index], ",", " `t")

        If (Button[1] == "-") {
            iBitmap := 0
            idCommand := 0
            fsState := 0
            fsStyle := 1 ; BTNS_SEP
            iString := -1
        } Else {
            Index++
            iBitmap := (fTextOnly) ? -1 : (Button[2] != "" ? Button[2] - 1 : Index - 1)
            idCommand := (Button[5]) ? Button[5] : 10000 + Index

            fsState := InStr(Button[3], "DISABLED") ? 0 : 4 ; TBSTATE_ENABLED
            Loop Parse, % Button[3], %A_Tab%%A_Space%, %A_Tab%%A_Space% ; Parse button states
                IfEqual A_LoopField,, Continue
                Else fsState |= %A_LoopField%

            fsStyle := fTextOnly || fShowText ? SHOWTEXT : 0
            Loop Parse, % Button[4], %A_Tab%%A_Space%, %A_Tab%%A_Space% ; Parse button styles
                IfEqual A_LoopField,, Continue
                Else fsStyle |= %A_LoopField%

            iString := &(ButtonText%Index% := Button[1])
        }

        Offset := (A_Index - 1) * TBBUTTON_Size
        NumPut(iBitmap, TBBUTTONS, Offset, "Int")
        NumPut(idCommand, TBBUTTONS, Offset + 4, "Int")
        NumPut(fsState, TBBUTTONS, Offset + 8, "UChar")
        NumPut(fsStyle, TBBUTTONS, Offset + 9, "UChar")
        NumPut(iString, TBBUTTONS, Offset + (A_PtrSize == 8 ? 24 : 16), "Ptr")
    }

    If (Padding != "") {
        SendMessage 0x457, 0, %Padding%,, ahk_id %hWnd% ; TB_SETPADDING
    }

    SendMessage 0x454, 0, 0x9,, ahk_id %hWnd% ; TB_SETEXTENDEDSTYLE (mixed buttons, draw dropdown arrows)
    SendMessage 0x430, 0, %ImageList%,, ahk_id %hWnd% ; TB_SETIMAGELIST
    SendMessage % A_IsUnicode ? 0x444 : 0x414, %cButtons%, % &TBBUTTONS,, ahk_id %hWnd% ; TB_ADDBUTTONS

    If (InStr(Options, "VERTICAL")) {
        VarSetCapacity(SIZE, 8, 0)
        SendMessage 0x453, 0, &SIZE,, ahk_id %hWnd% ; TB_GETMAXSIZE
    } Else {
        SendMessage 0x421, 0, 0,, ahk_id %hWnd% ; TB_AUTOSIZE
    }

    Return hWnd
}

_ToolbarStorage(hWnd, Callback := "") {
    Static o := {}
    Return (o[hWnd] != "") ? o[hWnd] : o[hWnd] := Callback
}

_ToolbarHandler(hWnd) {
    Static n := {-2: "Click", -5: "RightClick", -20: "LDown", -713: "Hot", -710: "DropDown"}
    Local Handler, Code, ButtonId, Pos, Text, Event, RECT, Left, Bottom

    Handler := _ToolbarStorage(hWnd)

    Code := NumGet(A_EventInfo + 0, A_PtrSize * 2, "Int")

    If (Code != -713) {
        ButtonId := NumGet(A_EventInfo + (3 * A_PtrSize))
    } Else {
        ButtonId := NumGet(A_EventInfo, A_PtrSize == 8 ? 28 : 16, "Int") ; NMTBHOTITEM idNew
    }

    SendMessage 0x419, ButtonId,,, ahk_id %hWnd% ; TB_COMMANDTOINDEX
    Pos := ErrorLevel + 1

    VarSetCapacity(Text, 128, 0)
    SendMessage % A_IsUnicode ? 0x44B : 0x42D, ButtonId, &Text,, ahk_id %hWnd% ; TB_GETBUTTONTEXT

    Event := (n[Code] != "") ? n[Code] : Code

    VarSetCapacity(RECT, 16, 0)
    SendMessage 0x433, ButtonId, &RECT,, ahk_id %hWnd% ; TB_GETRECT
    DllCall("MapWindowPoints", "Ptr", hWnd, "Ptr", 0, "Ptr", &RECT, "UInt", 2)
    Left := NumGet(RECT, 0, "Int")
    Bottom := NumGet(RECT, 12, "Int")

    %Handler%(hWnd, Event, Text, Pos, ButtonId, Left, Bottom)
}

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

分享Google后台翻译+划词翻译-改

2021-12-2 15:43:47

其他应用

自定义ahk文件的右键菜单(microbug)

2021-12-2 15:47:03

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索