autohotkey 记录

编程入门 行业动态 更新时间:2024-10-26 04:24:26

<a href=https://www.elefans.com/category/jswz/34/1695534.html style=autohotkey 记录"/>

autohotkey 记录

/
记录

/

.htm

/

/
中文社区

#z::Run ""  ; Win+Z
#n::Run "mspaint"  ; Win+n^!n::  ; Ctrl+Alt+N
{if WinExist("Untitled - Notepad")WinActivateelseRun "Notepad"
}

22

Run "notepad.exe"
if WinWait("无标题 - 记事本", , 3){    WinMinimize ; Use the window found by WinWait.MsgBox "WinWait not timed out."}
else{MsgBox "WinWait timed out."
}

xshell 子窗口关闭

v2

Run "xshell.exe"
if WinWait("Xshell 5 (Free for Home/School)", , 6){    ; WinMinimize ; Use the window found by WinWait.MsgBox "WinWait not timed out."SetTimer CheckForMsgBox, 100 CheckForMsgBox(){If WinExist("会话") {Send "{Enter}" SetTimer CheckForMsgBox,0             }}
}
else{MsgBox "WinWait timed out."
}

通达信自动下载 盘后数据 AHK V2

Run "C:\\new_tdx\\TdxW.exe"
if WinWait("通达信金融终端V7.48", , 6){    ; WinMinimize ; Use the window found by WinWait.;MsgBox "WinWait not timed out."ControlChooseIndex(2,"SysTabControl321")Sleep 1500;ControlClick "Button1"Click 530, 262Sleep 2500If WinExist("通达信信息") {WinClose ;}    If WinExist("数据维护工具V3.90 [通达信金融终端]") {WinClose ;}  	Sleep 500;PostMessage 0x111, 33233, 0,, "ahk_class TdxW_MainFrame_Class"PostMessage 0x111, 9279, 0,, "ahk_class TdxW_MainFrame_Class"Sleep 2500If WinExist("盘后数据下载") {;ControlClick "Button1", "盘后数据下载"			Click 23, 75Sleep 500ControlClick "Button9", "盘后数据下载";Sleep 9500;WinClose ;} 	}
else{MsgBox "WinWait timed out."
}

辅助工具:

;AHK v1.1 x64/x32 compatible update by jeeswg of:
;Get Info from Context Menu - Scripts and Functions - AutoHotkey Community
;/;
; AutoHotkey Version: 1.x
; Language:       English
; Platform:       Win9x/NT
; Author:         micha
;
; Script Function:
;	Demonstrates how to retrieve infos from a context/ popup menu
;/*
This is the struct we are using.
typedef struct tagMENUITEMINFO {UINT    cbSize;UINT    fMask;UINT    fType;UINT    fState;UINT    wID;HMENU   hSubMenu;HBITMAP hbmpChecked;HBITMAP hbmpUnchecked;ULONG_PTR dwItemData;LPTSTR  dwTypeData;UINT    cch;HBITMAP hbmpItem;
} MENUITEMINFO, *LPMENUITEMINFO;*/
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
#Persistent
RunAsAdmin() 
SetTimer, Demo, 500
return
Demo:
;constants
MFS_ENABLED = 0
MFS_CHECKED = 8
MFS_DEFAULT = 0x1000
MFS_DISABLED = 2
MFS_GRAYED = 1
MFS_HILITE = 0x80
;MFS_UNCHECKED = 0
;MFS_UNHILITE = 0
;Get mouse position and handle to wnd under the mouse cursor
MouseGetPos, MouseScreenX, MouseScreenY, MouseWindowUID, MouseControlID
WinGet,ControlHwnd, ID,ahk_id %MouseWindowUID%
;Get count of menu items
ContextMenCnt := GetContextMenuCount(ControlHwnd)
if ContextMenCnt < 1
{Tooltip,return
}
TooltipText =
;Read info for each menu item
loop, %ContextMenCnt%
{IsEnabled := GetContextMenuState(ControlHwnd, a_index-1){CurrentText =;~ if IsEnabled = 0;~ CurrentText = %CurrentText% Enabled;~ if (IsEnabled & MFS_CHECKED);~ CurrentText = %CurrentText% Checked;~ if (IsEnabled & MFS_DEFAULT);~ CurrentText = %CurrentText% Default;~ if (IsEnabled & MFS_DISABLED);~ CurrentText = %CurrentText% Disabled;~ if (IsEnabled & MFS_GRAYED);~ CurrentText = %CurrentText% Grayed;~ if (IsEnabled & MFS_HILITE);~ CurrentText = %CurrentText% Highlight;~ TooltipText = %TooltipText%%a_index%:%CurrentText%`nif (IsEnabled & MFS_HILITE){CurrentText := GetContextMenuID(ControlHwnd, a_index-1) . A_Tab . GetContextMenuText(ControlHwnd, a_index-1)TooltipText := CurrentText    }}
}
;~ TextText =
;~ loop, %ContextMenCnt%
;~ {;~ StrSize := GetContextMenuText(ControlHwnd, a_index-1);~ nID := GetContextMenuID(ControlHwnd, a_index-1);~ TextText = %TextText%%a_index%:%StrSize%-ID=%nID%`n
;~ }
CoordMode, Tooltip, Screen
Tooltip, %TooltipText%---`n%TextText%, 0, 0
return
/***************************************************************
* returns the count of menu items
***************************************************************
*/
GetContextMenuCount(hWnd)
{WinGetClass, WindowClass, ahk_id %hWnd%;All popups should have the window class #32768if WindowClass <> #32768{return 0}; Retrieve menu handle from windowSendMessage, 0x01E1, , , , ahk_id %hWnd%;Errorlevel is set by SendMessage. It contains the handle to the menuhMenu := errorlevelmenuitemcount:=DllCall("GetMenuItemCount", Ptr,hMenu)Return, menuitemcount
}
/***************************************************************
* returns the state of a menu entry
***************************************************************
*/
GetContextMenuState(hWnd, Position)
{WinGetClass, WindowClass, ahk_id %hWnd%if WindowClass <> #32768{return -1}SendMessage, 0x01E1, , , , ahk_id %hWnd%;Errorlevel is set by SendMessage. It contains the handle to the menuhMenu := errorlevel;We need to allocate a structVarSetCapacity(MenuItemInfo, 60, 0);Set Size of Struct to the first memberNumPut(A_PtrSize=8?80:48, MenuItemInfo, 0, "UInt");Get only Flags from dllcall GetMenuItemInfo MIIM_TYPE = 1NumPut(1, MenuItemInfo, 4, "UInt");GetMenuItemInfo: Handle to Menu, Index of Position, 0=Menu identifier / 1=IndexInfoRes := DllCall("user32.dll\GetMenuItemInfo", Ptr,hMenu, UInt,Position, Int,1, Ptr,&MenuItemInfo)InfoResError := errorlevelLastErrorRes := DllCall("GetLastError", UInt)if InfoResError <> 0return -1if LastErrorRes != 0return -1;Get Flag from structGetMenuItemInfoRes := NumGet(MenuItemInfo, 12, "UInt")/*IsEnabled = 1if GetMenuItemInfoRes > 0IsEnabled = 0return IsEnabled*/return GetMenuItemInfoRes
}
/***************************************************************
* returns the ID of a menu entry
***************************************************************
*/
GetContextMenuID(hWnd, Position)
{WinGetClass, WindowClass, ahk_id %hWnd%if WindowClass <> #32768{return -1}SendMessage, 0x01E1, , , , ahk_id %hWnd%;Errorlevel is set by SendMessage. It contains the handle to the menuhMenu := errorlevel;UINT GetMenuItemID(          HMENU hMenu,    int nPos);InfoRes := DllCall("user32.dll\GetMenuItemID", Ptr,hMenu, Int,Position, UInt)InfoResError := errorlevelLastErrorRes := DllCall("GetLastError", UInt)if InfoResError <> 0return -1if LastErrorRes != 0return -1return InfoRes
}
/***************************************************************
* returns the text of a menu entry (standard windows context menus only!!!)
***************************************************************
*/
GetContextMenuText(hWnd, Position)
{WinGetClass, WindowClass, ahk_id %hWnd%if WindowClass <> #32768{return -1}SendMessage, 0x01E1, , , , ahk_id %hWnd%;Errorlevel is set by SendMessage. It contains the handle to the menuhMenu := errorlevel;We need to allocate a structVarSetCapacity(MenuItemInfo, 200, 0);Set Size of Struct (48) to the first memberNumPut(A_PtrSize=8?80:48, MenuItemInfo, 0, "UInt");Retrieve string MIIM_STRING = 0x40 = 64 (/ MIIM_TYPE = 0x10 = 16)NumPut(64, MenuItemInfo, 4, "UInt");Set type - Get only size of string we need to allocate;NumPut(0, MenuItemInfo, 8, "UInt");GetMenuItemInfo: Handle to Menu, Index of Position, 0=Menu identifier / 1=IndexInfoRes := DllCall("user32.dll\GetMenuItemInfo", Ptr,hMenu, UInt,Position, Int,1, Ptr,&MenuItemInfo)if InfoRes = 0return -1InfoResError := errorlevelLastErrorRes := DllCall("GetLastError", UInt)if InfoResError <> 0return -1if LastErrorRes <> 0return -1;Get size of string from structGetMenuItemInfoRes := NumGet(MenuItemInfo, A_PtrSize=8?64:40, "UInt");If menu is empty returnIf GetMenuItemInfoRes = 0return "{Empty String}";+1 should be enough, we'll use 2GetMenuItemInfoRes += 2;Set capacity of string that will be filled by windowsVarSetCapacity(PopupText, GetMenuItemInfoRes, 0);Set Size plus 0 terminator + security ;-)NumPut(GetMenuItemInfoRes, MenuItemInfo, A_PtrSize=8?64:40, "UInt")NumPut(&PopupText, MenuItemInfo, A_PtrSize=8?56:36, "Ptr")InfoRes := DllCall("user32.dll\GetMenuItemInfo", Ptr,hMenu, UInt,Position, Int,1, Ptr,&MenuItemInfo)if InfoRes = 0return -1InfoResError := errorlevelLastErrorRes := DllCall("GetLastError", UInt)if InfoResError <> 0return -1if LastErrorRes <> 0return -1return PopupText
}
;PrintScreen::reload
RunAsAdmin() {full_command_line := DllCall("GetCommandLine", "str")if not (A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)")){try{if A_IsCompiledRun *RunAs "%A_ScriptFullPath%" /restartelseRun *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"}ExitApp}
}

更多推荐

autohotkey 记录

本文发布于:2024-02-12 18:01:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1688825.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:autohotkey

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!