[AHK]获取通达信软件上的股票代码

PC上的股票交易软件的自动止损、自动下单等功能比较弱,不如期货交易软件。

自力更生,程序员都是自己打造工具。

根据IPO模型(Input 输入,Process处理,Output输出),为了方便自动化首先要获取当前交易软件上浏览的股票代码。

截图再OCR显然太麻烦,通过Winspy工具查看下交易软件自带功能的消息号(33780),大家记住这个号码!

下面在用AutoHotkey作为变成语言,发送这个消息号来获取当前浏览的股票代码。

;脚本功能:获取通达信软件上的股票代码
;测试环境:招商证券、中银国际提供的官方通达信客户端
;作者微信:sunwind1576157
;发布时间:2020年2月6日
;最新版本:https://blog.csdn.net/liuyukuan/article/details/104195901
;验证方式:在交易软件中按 热键 win+z#z::
SendMessage,0x111,33780,0,,ahk_class TdxW_MainFrame_Class
MsgBox %Clipboard%
return

效果如下,简单一条SenMessage语句解决!后续可以利用这个代码去记录、去自动化下单、或者联动到其它交易软件中。

如有需求,可以联系我微信交流,欢迎打赏!

 

有朋友索要查看消息的ahk工具,代码如下(2021年2月25日更新,只显示当前鼠标下面菜单项的消息号):

用法:下面代码存成独立ahk脚本,运行之。在想要查看消息的程序内,调出该软件的相关菜单,把鼠标移动到某个菜单项上,查看屏幕左上角的tooltip。

;AHK v1.1 x64/x32 compatible update by jeeswg of:
;Get Info from Context Menu - Scripts and Functions - AutoHotkey Community
;https://autohotkey.com/board/topic/19754-get-info-from-context-menu/;
; 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}
}

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://xiahunao.cn/news/351715.html

如若内容造成侵权/违法违规/事实不符,请联系瞎胡闹网进行投诉反馈,一经查实,立即删除!

相关文章

(十)服务器K8S集群部署SpringBoot项目实战

1.准备springboot项目 可以在 https://start.spring.io/网站准备一个项目&#xff0c;这里作为k8s的学习所以springboot项目中准备一个简单的访问接口即可。 2.服务器环境准备 安装Jdk 1.更新系统软件包&#xff1a; sudo yum update2.安装 OpenJDK 11&#xff1a; sudo…

毕业三年,自学软件测试到就业,我用了4个月

我转行的经历 17年毕业&#xff0c;普通专科&#xff0c;通信专业。 当初选择这个专业是因为有一个校企合作&#xff0c;承诺学生毕业之后给学生安排就业&#xff0c;在学校里面混了三年之后&#xff0c;学校也是履行了当初安排就业的承诺&#xff0c;给我“发配”到了上海&a…

Python数据攻略-DataFrame的数据计算和整理

大家好&#xff0c;我是Mr数据杨。今天&#xff0c;我们要踏上一场探索Python的旅程&#xff0c;途中我们将讲解算术运算、NumPy和SciPy函数的应用、DataFrame的排序、过滤、统计和遍历等技巧。想象一下如果《三国演义》中的诸葛亮有了Python的帮助&#xff0c;他将如何更有效地…

海睿思分享 | 企业如何加强采购风险控制

企业运营的主要流程&#xff0c;不会因为企业人员规模或者业务规模大小的差异&#xff0c;而出现巨大的差异。千万亿市值的上市公司、不足百人的新兴公司&#xff0c;面对的经营风险本质上不会有明显的区别。今天我们一起分享企业经营管理中常见的风险应对策略。 对于企业而言…

Treadlocal源码实例详解

我们都知道treadlocal维护变量时候&#xff0c;可以为每个线程维护一个独立的副本&#xff0c;改变的是自己线程的数据。 ThreadLocal公用方法有四个&#xff1a;get&#xff0c;set&#xff0c;remove&#xff0c;intiValue 既然threadLocalMap是局部变量&#xff0c;所以他存…

C++学习之旅 - new运算符

C中利用new操作符在堆区开辟数据 堆中开辟的数据由程序员手动开辟&#xff0c;手动释放&#xff0c;释放利用操作符delete 语法new 数据类型 #include <iostream>using namespace std;int *func(){int* p new int(10);return p; }int main() {int* p func();cout <&…

传奇开服教程完整版GOM引擎超详细的单机架设图文教程(小白一看就会)

准备工具 1.传奇版本和补丁2.热血传奇客户端3.DBC20004.绿盟GOM登录器 服务端安装步骤&#xff1a; 1.把下载好的传奇版本解压在你电脑的D盘 2.补丁文件夹直接解压到你的传奇客户端根目录 3.解压好DBC2000开始安装&#xff0c;安装完成后关闭DBC程序 4.打开控制面板&#xff0…

深入理解Linux虚拟内存管理(四)

系列文章目录 Linux 内核设计与实现 深入理解 Linux 内核&#xff08;一&#xff09; 深入理解 Linux 内核&#xff08;二&#xff09; Linux 设备驱动程序&#xff08;一&#xff09; Linux 设备驱动程序&#xff08;二&#xff09; Linux 设备驱动程序&#xff08;三&#xf…

锐捷AC的部署实例

进行锐捷AC部署时&#xff0c;遇到了一些问题&#xff0c;遂记录下来&#xff0c;如若大家在项目过程中遇到类似问题可以对照解决。 写在前面&#xff08;锐捷AC的基础配置&#xff09; ac-controller //配置AC的capwap源地址信息&#xff0c;国家码等…

Nginx配置域名证书

Nginx配置域名证书 1、证书存放路径 2、nginx.conf文件中增加以下配置&#xff0c;注意路径不一样&#xff0c;访问地址目录不一样 server {listen 443 ssl http2;server_name jistest.vwatj.ap.vwg;ssl_certificate D:/home/XXX/ssl/2023/XXX.cer; ssl_certificate_key D…

在线配资平台哪家正规?排名在前的有哪些平台?

在线配资平台哪家正规&#xff1f;排名在前的有哪些平台&#xff1f; 比如有永华证券、联华证券、财盛证券、中信证券、东方证券等等这些平台。也是排名比较靠前的&#xff01; 选择平台需要投资者仔细研究不同的在线配资平台的投资风格、费用、客户服务等因素&#xff0c;并根…

《辉煌优配》科技股强势引领A股反弹 沪深两市日成交额再超万亿元

受美联储再度加息扰动&#xff0c;昨日早盘沪深两市指数低开&#xff0c;随后科技股强势拉升&#xff0c;带动商场回暖。到收盘&#xff0c;上证综指报3286.65点&#xff0c;上涨0.64%&#xff1b;深证成指报11605.29点&#xff0c;上涨0.94%&#xff1b;创业板指报2361.41点&a…

A股管家股票自动交易软件系统,功能完善强大

2013年的时候&#xff0c;有个广东的朋友说再用这款A股管家股票自动系统&#xff0c;我当时比较惊讶&#xff0c;以前想过要是有一款股票自动交易软件能偶尔代替我一下就好了&#xff0c;虽然是职业股民&#xff0c;但也经常遇到太忙的时候&#xff0c;实在没时间。然后就在朋友…

亚马逊云科技出海日,让数字经济出海扩展到更多行业和领域

数字化浪潮之下&#xff0c;中国企业的全球化步伐明显提速。从“借帆出海”到“生而全球化”&#xff0c;中国企业实现了从传统制造业“中国产品”出口&#xff0c;向创新“中国技术”和先导“中国品牌”的逐步升级。 作为全球云计算的开创者与引领者&#xff0c;亚马逊云科技…

JDK11+mybatis-plus+shardingsphere分库分表

1、引入jar dynamic-datasource-spring-boot-starter&#xff1a;2.5.6 sharding-jdbc-spring-boot-starter&#xff1a;4.1.1 <dependency><groupId>com.baomidou</groupId><artifactId>dynamic-datasource-spring-boot-starter</artifactId>&…

【单目标优化算法】沙猫群优化算法(Matlab代码实现)

&#x1f4a5; &#x1f4a5; &#x1f49e; &#x1f49e; 欢迎来到本博客 ❤️ ❤️ &#x1f4a5; &#x1f4a5; &#x1f3c6; 博主优势&#xff1a; &#x1f31e; &#x1f31e; &#x1f31e;博客内容尽量做到思维缜密&#xff0c;逻辑清晰&#xff0c;为了方便读者。 …

华为路由器 NAT 配置

拓扑图 静态 NAT 静态地址转换是指外部网络和内部网络之间的地址映射关系由配置确定&#xff0c;该方式适用于内部网络与外部网络之间存在固定访问需求的组网环境。静态地址转换支持双向互访&#xff1a;内网用户可以主动访问外网&#xff0c;外网用户也可以主动访问内网。 一…

Java 冒泡排序法

冒泡排序法是交换排序法的一种 思想&#xff1a; /** * 冒泡法排序 * 比较相邻的元素。如果第一个比第二个小&#xff0c;就交换他们两个。 * 对每一对相邻元素作同样的工作&#xff0c;从开始第一对到结尾的最后一对。在这一点&#xff0c;最后的元素应该会是最小的数。 * 针…

冒泡排序法定向冒泡排序法的Python实现

冒泡排序法 冒泡排序法&#xff1a;每轮对相邻的两者进行比较&#xff0c;若顺序不对&#xff0c;则进行位置互换&#xff0c;每轮都将使每轮的 最后一位是该轮的大数。 比如在数列&#xff1a;[71, 1, 14, 78, 75, 38, 10, 49, 40, 95] 第一轮交换&#xff1a;71>1 > […

Java:冒泡排序法

冒泡排序法是最基本的排序法之一&#xff0c;冒泡排序法的运行机制是通过循环遍历元素并调整相邻元素顺序来实现的一种简单排序方法。冒泡排序的实质是相邻两个元素比较&#xff0c;然后按照升序或降序调换位置。 下为降序冒泡排序的代码: public class Training {public sta…