match5 / thsauto Goto Github PK
View Code? Open in Web Editor NEW同花顺自动下单工具
同花顺自动下单工具
192.168.1.116 6000 C:\Users\shams\Desktop\thsauto-master\xiadan.exe
def input_ocr(self):
ocr = self.get_ocr_hwnd()
i = 0
while ocr>0 and i < 10:
self.capture_window(ocr, 'ocr.png')
code = pytesseract.image_to_string(Image.open('ocr.png')).strip('\n')
ctrl = ctypes.windll.user32.GetWindow(ocr, win32con.GW_HWNDNEXT)
ctrl = ctypes.windll.user32.GetWindow(ctrl, win32con.GW_HWNDNEXT)
ctrl = ctypes.windll.user32.GetWindow(ctrl, win32con.GW_HWNDNEXT)
set_text(ctrl, code)
hot_key(['enter'])
# with open('ocr.png', 'rb') as f:
# data = f.read()
# code = DdddOcr.classification(data)
# ctrl = ctypes.windll.user32.GetWindow(ocr, win32con.GW_HWNDNEXT)
# ctrl = ctypes.windll.user32.GetWindow(ctrl, win32con.GW_HWNDNEXT)
# ctrl = ctypes.windll.user32.GetWindow(ctrl, win32con.GW_HWNDNEXT)
# set_text(ctrl, code)
# hot_key(['enter'])
i += 1
err_text = get_text(ctypes.windll.user32.GetWindow(ocr, win32con.GW_HWNDNEXT))
if u'验证码错误' in err_text:
left, top, right, bottom = win32gui.GetWindowRect(ocr)
win32api.SetCursorPos(((left + right) // 2, (top + bottom) // 2))
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
time.sleep(sleep_time)
else:
return
目前是搜索内存中的下单程序的方法。如果同时运行两个下单程序,有可能会绑定错误。
能否使用绑定指定路径下的下单程序的方法呢?
谢谢!
def get_text(hwnd):
length = ctypes.windll.user32.SendMessageW(hwnd, win32con.WM_GETTEXTLENGTH)
buf = ctypes.create_unicode_buffer(length + 1)
ctypes.windll.user32.SendMessageW(hwnd, win32con.WM_GETTEXT, length, ctypes.byref(buf)) # 这里的length改成length+1,否则中文存在切断变成一个问号
return buf.value
def hot_key(keys):
time.sleep(sleep_time)
for key in keys:
win32api.keybd_event(VK_CODE[key], 0, 0, 0)
# 这里插入一个小的延时,否则有时候两次键盘虚拟事件太快,导致失效
time.sleep(0.01)
for key in reversed(keys):
win32api.keybd_event(VK_CODE[key], 0, win32con.KEYEVENTF_KEYUP, 0)
独立下单客户端,版本V5.18.81
调用接口,弹出提示窗口
https://z3.ax1x.com/2021/09/17/4uRaLt.png
本来跑的好好的,我的server运行在另外一台局域网内的服务器上,平时用的远程桌面连接,都正常,但是当我断开远程桌面连接后,就出问题了,表现在:
win32gui.SetForegroundWindow(hwnd)调用和win32api.SetCursorPos((x,y))调用出现‘’No error message is available‘’错误提示。
win32api.SetCursorPos((x,y))改成ctypes.windll.user32.SetCursorPos(x, y)后,不报错了,但是SetForegroundWindow解决不了,网上说在调用他之前执行
win32com.client.Dispatch("WScript.Shell").SendKeys('%')
也无济于事。
可能原因是远程桌面RDP断开后,服务器可能不保留GUI的上下文,导致某些函数执行出错?
ddddocr识别率不高,经常把大写字母识别成小写字母,这也服了,大小写差异很大的,同花顺是大小写敏感,我尝试了几个ocr,发现tesseract成功率很高,还没碰到过失败,速度也快,唯一是需要从官网下载安装一次。
QQ:5108926
get_position方法,好象是错的,获取的是委托信息,而不是持仓信息
有问题想咨询一下,求加QQ:5108926
银河证券的“账户资金”balance读取会出错。
银河证券的“账户资金”balance的设计方式和其它券商不一样。
能否也适配一下银河证券呢?
谢谢!
ocr识别时有时候会出现特殊字符,导致输入不进去,比如 'fvfF'识别成了'f£VFTF',其中£键入不进去,导致set_text会抛出Exception,进而程序进行不下去,验证码窗口也没消失,所以set_text加上try,发现异常就点击验证码图片,重新生成一个来重新尝试
兄弟 能不能更新一下 python搞不懂
def empty_clipboard():
win32clipboard.OpenClipboard()
try:
win32clipboard.EmptyClipboard()
finally:
win32clipboard.CloseClipboard()
def copy_table(self, hwnd):
win32gui.SetForegroundWindow(hwnd)
empty_clipboard()
os.system('echo off | clip')
hot_key(['ctrl', 'c'])
self.input_ocr()
请问这个有什么办法解决么?
下单成功,返回订单编号12,调用撤单,就提示没找到指定订单
url 上传订单后自动传入代码价格,有问题,股票代码确实,无法完整填充
在新版本的下单程序有问题?安装了旧版本的,要强制升级。能否提供一下下单程序?谢谢!
测试中发现程序经常不能正常复制表格,后来发现是hot_key的问题。程序执行Ctrl+c,但是客户端只收到了c。目前看是按键过程执行过快的原因,我在两个keybd_event后面分别加了time.sleep(0.2)就可以正常使用了👀。
你好,不知道你是在什么环境下跑的,我是跑在阿里云的windows server 2019上的,64位机,经常会出现(5, 'SetCursorPos', '拒绝访问')的错误,特别是我要查询当前持仓的时候,特别容易出现,现在的自动交易程序因为这个不稳定因素,执行不下去了,请教,多谢指点
I see 网上股票交易系统 5.0.
应该安装哪个名字的同花顺客户端? 同花顺自己提供的什么版本 还是券商的版本?
适配的是哪个版本的客户端?复制持仓现在不都会让填写验证码了吗?
服务端报错信息 [07/Mar/2022 10:43:30] "GET /thsauto/balance HTTP/1.1" 400 -
请求端报错信息 {"code":1,"msg":"(1400, 'GetWindowRect', '无效的窗口句柄。')","status":"failed"}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.