通达信自动交易软件

article/2025/10/1 6:10:28

1、要善用spy++

2、不同的控件主要靠GetDlgCtrlID去区分

3、要获得另一个进程的焦点窗口(GetFocus)需要调用AttachThreadInput

4、尽量少用keybd_event模拟键盘输入,主要是该函数不能保证按键消息一定能被特定进程接收到。取而代之的是SendMessage(hwnd, WM_IME_CHAR, ...)。而模拟回车按下要用PostMessage (hFocus, WM_KEYDOWN, VK_RETURN, 0),SendMessage不知为何不起作用

5、通达信在按下第一个数字键后会弹出键盘精灵,此时焦点窗口会转移到键盘精灵上,要重新调用GetFocus一次

6、GetWindow(hMainWnd, GW_ENABLEDPOPUP)可以获得当前的弹出窗口句柄

7、PostMessage(hPopup, WM_COMMAND, MAKEWPARAM(IDOK, BN_CLICKED), NULL),模拟“确定”键被按下

8、EnumChildWindows函数可以枚举一个窗口的所有子窗口

 

复制代码

class ThreadHandler
{#region P/Invoking and constants definitionconst uint WM_GETTEXT = 0x000D;[DllImport("user32.dll")]static extern IntPtr SetFocus(IntPtr hWnd);[DllImport("user32.dll")]private static extern int GetWindowThreadProcessId(IntPtr hWnd, uint lpdwProcessId = 0);delegate bool EnumThreadDelegate(IntPtr hWnd, IntPtr lParam);[DllImport("user32.dll")]static extern bool EnumThreadWindows(int dwThreadId, EnumThreadDelegate lpfn,IntPtr lParam);[DllImport("user32.dll")]static extern bool AttachThreadInput(int idAttach, int idAttachTo, bool fAttach);[DllImport("kernel32.dll")]static extern int GetCurrentThreadId();[DllImport("user32.dll", CharSet = CharSet.Auto)]static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, int wParam, StringBuilder lParam);#endregionpublic readonly string ProcessName, WindowName;protected readonly int TargetThreadID, CurrentThreadID;protected readonly IntPtr TargetWindowHandle;public ThreadHandler(string processName, string windowName){CurrentThreadID = GetCurrentThreadId();ProcessName = processName;WindowName = windowName;object[] objs = GetWindowThread(processName, windowName);if (objs == null){throw new ArgumentException("Could not find the specified process/window.");}TargetThreadID = (int)objs[0];TargetWindowHandle = (IntPtr)objs[1];}public ThreadHandler(string processName){CurrentThreadID = GetCurrentThreadId();ProcessName = processName;var processes = Process.GetProcessesByName(ProcessName);if (processes.Length == 0){throw new ArgumentException("Could not find the specified process.");}var appProc = processes[0];WindowName = appProc.MainWindowTitle;TargetThreadID = GetWindowThreadProcessId(appProc.MainWindowHandle);TargetWindowHandle = appProc.MainWindowHandle;}public bool AttachThreadInput(){return AttachThreadInput(CurrentThreadID, TargetThreadID, true);}public bool DetachThreadInput(){return AttachThreadInput(CurrentThreadID, TargetThreadID, false);}public void SetFocus(){SetFocus(TargetWindowHandle);}static object[] GetWindowThread(string processName, string windowName){var processes = Process.GetProcessesByName(processName);if (processes.Length > 0){//Fill a list of handlesvar handles = new List<IntPtr>();foreach (ProcessThread thread in processes[0].Threads)EnumThreadWindows(thread.Id,(hWnd, lParam) => { handles.Add(hWnd); return true; }, IntPtr.Zero);//Create a stringbuilder to function as storage unitStringBuilder nameBuffer = new StringBuilder(64);foreach (var hWnd in handles){//And finally compare the caption of the window with the requested namenameBuffer.Clear();SendMessage(hWnd, WM_GETTEXT, nameBuffer.Capacity, nameBuffer);if (nameBuffer.ToString() == windowName){return new object[2] { GetWindowThreadProcessId(hWnd), hWnd };}}}return null;}
}

复制代码

复制代码

static void Main(string[] args){Console.WriteLine("Please input the name of the process to hook: ");string pName = Console.ReadLine();Console.WriteLine("Input the name of a specific window, or leave blank: ");string pWnd = Console.ReadLine();ThreadHandler threadHandler;try{if(!String.IsNullOrWhiteSpace(pWnd))threadHandler = new ThreadHandler(pName, pWnd);elsethreadHandler = new ThreadHandler(pName);}catch{Console.WriteLine("Error: " + pName +" does not seem to be running.");Console.ReadKey();return;}if (!threadHandler.AttachThreadInput()){Console.WriteLine("Error: The application tried to attach its Input Processing Mechanism to " + threadHandler.ProcessName + ", but failed.");Console.ReadKey();return;}Console.WriteLine("Input Processing Mechanism correctly attached to " + threadHandler.ProcessName + ".");threadHandler.SetFocus();InputSimulator.SimulateTextEntry("test"); //InputSimulator is a seemingly famous SendInput wrapper. Replacing this line with the code for a keystroke also doesn't work.Console.ReadLine();Console.WriteLine("Detaching Input Processing Mechanism.");threadHandler.DetachThreadInput();}

复制代码

以上代码尚不能工作,

You should be able to use SetFocus to give focus to the control you are sending the keystrokes to.

SendMessage and PostMessage can also be used to send keystrokes, but it's BAD PRACTICE and should be avoided.

Check out System.Windows.Forms.SendKeys for information on sending keystrokes though the Forms class in .NET.

In a lot of cases, if you don't need the keystrokes themselves, you can just change the text on a window using SendMessage with WM_SETTEXT if this is what you're looking to do.

http://answer.techwikihow.com/334694/sendinput-working-attaching-thread-input-target-process.html


http://chatgpt.dhexx.cn/article/FlGtFsUE.shtml

相关文章

动手搭建深度强化学习的自动股票量化交易系统

基于深度强化学习的股票量化交易 ⭐ ⭐ ⭐ 欢迎点个小小的Star支持&#xff01;⭐ ⭐ ⭐ 开源不易&#xff0c;希望大家多多支持~ 更多实践案例(AI识虫&#xff0c;基于PaddleX实现森林火灾监测&#xff0c;眼疾识别&#xff0c;智能相册分类等)、深度学习资料&#xff0c;请…

postman 数据流请求

备注&#xff1a; Postman version &#xff1a; Version 9.21.3 Windows 版本 1.修改headers 添加或者修改 Content-Type 为application/octet-stream2.Body 部分 选择raw 格式数据 直接复制需要的流数据内容&#xff0c;可以任意3.最后执行请求

数据流图基础

一、结构化分析方法 结构化分析是指20世纪70年代末&#xff0c;由Demarco等人提出的&#xff0c;简称SA方法&#xff0c;是面向数据流进行需求分析的方法&#xff0c;旨在减少分析活动中的错误&#xff0c;建立满足用户需求的系统逻辑模型。 结构化分析的要点是&#xff1a;根…

【软件工程】数据流图 ( 数据流图简介 | 数据流图概念 | 数据流 | 加工 | 数据存储 | 外部实体 | 数据流图分层 | 顶层数据流图 | 中层数据流图 | 底层数据流图 )

文章目录 一、数据流图 ( DFD ) 简介二、数据流图 ( DFD ) 概念符号1、数据流2、加工 ( 核心 )3、数据存储4、外部实体 三、数据流图 ( DFD ) 分层1、分层说明2、顶层数据流图3、中层数据流图4、底层数据流图 一、数据流图 ( DFD ) 简介 数据流图 ( Data Flow Diagram ) : 在 …

数据流图(DFD)的概念

数据流图&#xff08;DFD&#xff09;是描述数据流程的图形工具&#xff0c;数据流图从数据传递和加工的角度&#xff0c;以图形的方式刻画数据流从输入到输出的移动变换过程。数据流图是系统逻辑模型的图形表示&#xff0c;从数据的传递与加工角度&#xff0c;来刻画数据流从输…

软考下午——数据流图

基本图形符号 设计原则 我们重点研究数据流图的三大设计原则。这三大设计原则是解题的法宝。 &#xff08;1&#xff09;父图与子图的平衡原则 子图的输入输出数据流同父图对应加工的输入输出数据流必须一致&#xff0c;此即父图与子图的平衡。 &#xff08;图1&#xff0c;不符…

软件工程数据流图

数据流图 数据流图是一种图形化技术&#xff0c;它描绘信息流和数据从输入移动到输出的过程中所经受的变换。在数据流图中没有任何具体的物理部件&#xff0c;它只是描绘数据在软件中流动和被处理的逻辑过程&#xff0c;是系统逻辑功能的图形表示。设计数据流图时只需考虑系统…

Vue单向数据流

Vue 的特性单向数据流&#xff0c;指数据一般从父组件传到子组件,子组件没有权利直接修改。 父组件传来的数据,即子组件从props中直接获取的数据&#xff0c;只能请求父组件修改数据再传给子组件&#xff0c;父组件属性值的更新会下行流动到子组件中。 1&#xff09;如果传很…

数据流分析

基本原理 数据流分析是一种用来获取相关数据沿着程序执行路径流动的信息分析技术。分析对象是程序执行路径上的数据流动或可能的取值 优点&#xff1a;具有更强的分析能力&#xff0c;适合需要考虑控制流信息且变量属性之操作十分简单的静态分析问题 缺点&#xff1a;分析效率…

数据流图DFD

数据流图和数据字典是结构化分析方法中常用的两种工具。本文中基础资料收集于网络&#xff0c;顶层数据流图部分加入里自己的理解。 数据流图 数据流图&#xff0c;简称DFD&#xff0c;是SA方法中用于表示系统逻辑模型的一种工具&#xff0c;它以图形的方式描绘数据在系统中流…

软考--数据流图(DFD)

数据流图的基本元素及其作用 数据流图通过外部代理(实体)描述系统与外界之间的数据交互关系&#xff0c;内部的活动通过处理(加工)表示&#xff0c;用数据流描述系统中不同活动之间的数据传输内容和方向&#xff0c;需要持久化存储的数据用数据存储表示&#xff0c;一般用文件…

数据流

数据流 引子 编译器后端会对前端生成的中间代码做很多优化&#xff0c;也就是在保证程序语义不变的前提下&#xff0c;提高程序执行的效率或减少代码size等优化目目标。优化需要依靠代码分析给出的"指导信息"来相应地改进代码&#xff0c;而代码分析中最重要的就是数…

数据流分析简介

文章目录 0. 前言1. 数据流分析简介1.1 数据流分析基本概念1.2 数据流分析结构简述 2. 数据流分析应用2.1 定义可达性分析(Reaching Definitions Analysis)2.1.1 定义可达描述2.1.2 定义可达算法2.1.3 定义可达算法示例 2.2 活变量分析(Live Variables Analysis)2.2.1 活变量描…

Swift抖动动画

一、直接实现某个视图的持续抖动、只需要给视图的layer添加动画就行。 /// 直接实现/// - Parameters:/// - repeatCount: 重复次数/// - duration: 持续时间/// - values: //抖动幅度数组&#xff1a;不需要太大&#xff1a;从-15度 到 15度、再回到原位置、为一个抖动…

os “抖动”与工作集

由于请求分页式虚拟存储器系统的性能优越&#xff0c;在正常运行情况下&#xff0c;它能有效地减少内存碎片&#xff0c;提高处理机的利用率和吞吐量&#xff0c;故是目前最常用的一种系统。但如果在系统中运行的进程太多&#xff0c;进程在运行中会频繁地发生缺页情况&#xf…

ADC 采样数据抖动

MSP430或STM32&#xff0c;在使用内部ADC出现的采样数据异常抖动问题 采样设计&#xff1a; 用于检测供电线路电流及电压。 产品运行在两种模式下&#xff0c;1、低功耗静态模式&#xff08;仓储态&#xff09;&#xff0c;2、全功能全速运行模式&#xff08;工作态&#xff09…

SiTime 硅晶振抖动定义和测量方法

1 简介 抖动是时钟信号边沿事件的时间点集合相对于其理想值的离散时序变量。时钟信号中的抖动通常是由系统中的噪声或其他干扰导致的。具体因素包括热噪声、电源变化、负载条件、器件噪声以及相邻电路耦合的干扰等。 2 抖动的类型 时钟信号抖动定义有多种主要是&#xff1a;…

如何理解相位噪声与时间抖动的关系?

每当介绍相位噪声测试方案时&#xff0c;都会提到时间抖动&#xff0c;经常提到二者都是表征信号短期频率稳定度的参数&#xff0c;而且是频域和时域相对应的参数。正如题目所示&#xff0c;相位噪声与时间抖动有着一定的关系&#xff0c;那么相噪是与哪种类型的抖动相对应&…

网络延时抖动

问题背景&#xff1a; 上线后延时抖动很频繁&#xff0c;正常延时为10ms左右&#xff0c;抖动时延达到300ms以上&#xff0c;严重影响了该业务的性能 问题结论&#xff1a;tcp传输报文段延时异常&#xff0c;传输内容越大&#xff0c;受网络影响越大 index模块延时正常&…

html图片抖动,css3图片抖动

受1楼启发Document .sdf{ width:500px; height:500px; overflow:hidden; margin:200px auto; position:relative; } .outter{ width:174px; height:155px; position:absolute; top:100px; left:200px; transition:all 1s ease; } .dd{ background:url(http://www.ppt123.net/be…