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}
}

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

  1. 如何在通达信软件上随意画图_[原创]谁能修改下画图工具啊?

    共11 条记录, 每页显示 10 条, 页签: [1] [2] 标题:[原创]谁能修改下画图工具啊? 1楼 xxx3345 发表于:2013/11/8 17:54:00 1,我对通达信画图工具的要求是 ...

  2. 分享通达信软件L2接口获取数据的执行过程

    在股票交易市场领域当中,通达信软件L2接口获取股票数据,用户根据得到的股票数据信息,做出合理的交易决策,让股票交易活动顺利进行. 通达信软件L2接口提供数据支撑,有了这些股票数据,经过了分析才能真实反 ...

  3. 【AHK】给通达信软件增加F1买入,F2卖出 交易热键(基于中银国际客户端测试)

    通达信金融终端网上交易软件 快捷键分为四种 数字键:比如1,61,81,10,91等 点系列键:比如.101,.201,.301.... .909等 功能键:比如F1,F2... 空格键,减号键,TA ...

  4. 通达信软件接口如何更新股票价格指数?

    股票价格是股票市场信息的重要组成部分,股票价格是股票价格的一个重要指标. 通达信软件接口除了可以完成股票价格指数以外,还包括股票的股票代码和简称,股票的开盘价和开盘指数,收盘价和收盘价,股票的每日最高 ...

  5. 2015快捷键在哪里设置_炒股软件的选择通达信软件的基本设置

    新入市的股民,通常会纠结于该使用哪个炒股软件?要不要买L2或更高级的服务?我刚入市的时候,也纠结于前一个问题(刚入市时L2一年1000左右,不纠结,直接不买).大智慧.同花顺.通达信.东方财富各有各的 ...

  6. 通达信软件接口是什么?能看得到五档报价吗?

    一般的看盘软件,无论是手机版还是电脑版只能看到买卖五档数据,那么通达信软件接口也能看的到五档报价,接下来小编就用一个表格给大家展示一下通达信软件接口获取五档报价说明! 签名 void GetQuote ...

  7. 通达信软件开发自定义接口的功能

    通达信软件开发自定义接口的功能,自定义数据是通达信提供给大家的可扩展数据接口. 这种数据类型带来了日期序列数据和字符串数据,极大地扩展了通达信本身的数据结构. 尤其是字符串功能,相当给力,可以在通达信 ...

  8. 通达信软件L2接口要进行测试的原因是什么?

    通达信软件L2接口要进行测试的原因是什么?我所以选择接口测试作为我第一专栏的写作方向,主要是因为凭借多年的工作经验,接口测试的投入产出比相对较高,在业务上有很大的价值. 很多年前,当我第一次进入移动互 ...

  9. 证券接口通达信软件PC版有多少种形态?

    有很多投资者对于证券接口通达信软件PC版的形态还是太了解的,通达信软件PC版,有以下两种形态: 第一种形态是官方版,第二种形态是券商定制版,那么券商为了嵌入自己的经纪.资管.咨询等业务,一般都有通达信 ...

  10. python编写选股公式_Python通过通达信选股,用通达信软件,如何向里面输入选股函数...

    Q1:用通达信软件,如何向里面输入选股函数 在软件的左上角,点击"功能--专家系统--公式管理--条件选股公式--再点击右边的新建,就可以输入选股函数了. Q2:通达信如何使用选股公式 公式 ...

最新文章

  1. img标签使用默认图片的一种方式
  2. redis java 性能_Redis 性能优化
  3. Silverlight3实现按路径运动[原创]
  4. 查询语句中select from where group by having order by的执行顺序
  5. python我想对你说_python学习第3天-----字典、解构
  6. 字符串操作截取后面的字符串_对字符串的5个必知的熊猫操作
  7. C#LeetCode刷题之#409-最长回文串(Longest Palindrome)
  8. Spring Boot配置文件application.properties
  9. gridreport如何设置打印3次_pdfFactory如何设置限制打印和浏览文档权限
  10. node.js学习笔记5——核心模块1
  11. 淘宝手淘搜索怎么做?大神导航,一个神奇的网站,从此开启大神之路!
  12. 查看系统使用率命令 vmstat 输出详解!
  13. 过去式和现在完成时区别
  14. origin将柱状图和折线图画一起
  15. 【华为OD机试真题 JS】统计射击比赛成绩
  16. Desmos-可能是迄今为止最好用的免费Web端数学图像绘制工具
  17. 点线面平面设计的概念是什么,分享点线结合构成设计图
  18. pydicom 安装与使用
  19. android app 清理缓存图片,支付宝APP怎么清理缓存 支付宝安卓版缓存清理方法
  20. 沈阳市计算机学校辛亮,2017-2018学年度(下)听评课总结.doc

热门文章

  1. 21年美赛F题-DEA模型和逻辑回归模型
  2. 微信开发者平台学习笔记
  3. java自行车销售系统_基于 javaee 自行车租赁系统,源码分享
  4. linux命令中文手册,Linux命令在线中文手册
  5. Swift:快速上手攻略
  6. OpenWrt 路由器过滤广告的N种方法
  7. 伺服驱动器cn1引脚定义_关于三菱驱动器CN1端口的接线-专业自动化论坛-中国工控网论坛...
  8. 安装cmsv7的具体方法
  9. singleTask
  10. 2021全国化妆品产业区域研究报告