ddxoft / master

547 stars 173 forks source link

DD_str方法在python2.x中可以用,python3.x中存在问题,只会输入字符串中第一个字符,就结束了 #57

Open zxxwslq opened 2 years ago

zxxwslq commented 2 years ago

如题,求解~~~

zxxwslq commented 2 years ago

调用的是DD94687.64.dll这个驱动

ddxoft commented 2 years ago

输入单字节类型

zxxwslq @.***> 于2022年7月20日周三 15:22写道:

调用的是DD94687.64.dll这个驱动

— Reply to this email directly, view it on GitHub https://github.com/ddxoft/master/issues/57#issuecomment-1189921624, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARXPLN5AWYJUWNV4CL2ZCXLVU6SLBANCNFSM54CQTGPA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

kvii commented 6 months ago

c_char_p(s.encode("ascii")) 解决了问题。下面是复现 demo:

from ctypes import *
import time

print("Load DD!")

dd_dll = windll.LoadLibrary("./dd.dll")
time.sleep(2)

st = dd_dll.DD_btn(0)  # DD Initialize
if st == 1:
    print("OK")
else:
    print("Error")
    exit(101)

def input_str(s: str):
    dd_dll.DD_str(c_char_p(s.encode("ascii")))

time.sleep(5)
input_str("Hello World!")

注意这个解决方案是我随便找的,可能有潜在的问题,我没仔细分析。文档链接

ddxoft commented 6 months ago

DD_str(b"123")

在 2024-03-06 10:26:47,"kvii" @.***> 写道:

用 c_char_p(s.encode("ascii")) 解决了问题。下面是复现 demo:

fromctypesimport*importtimeprint("Load DD!")

dd_dll=windll.LoadLibrary("./dd.dll") time.sleep(2)

st=dd_dll.DD_btn(0) # DD Initializeifst==1: print("OK") else: print("Error") exit(101)

definput_str(s: str): dd_dll.DD_str(c_char_p(s.encode("ascii")))

time.sleep(5) input_str("Hello World!")

注意这个解决方案是我随便找的,可能有潜在的问题,我没仔细分析。文档链接。

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>