如何输入指定的证券代码,谁帮我一下
本帖最后由 gddyao 于 2009-8-31 10:05 编辑我在搞一个快速下单的小程序,网上人家写的都是抓取飞狐的行情软件的证券代码,我想搞个能抓取通达信的。我参考了一个抓飞狐行情软件代码的程序,然后把它的源码用的通达信上却只能抓的股票的中文名称,飞狐的可以抓到数字代码。说的复杂了,不搞股票的人可能看不明白了。
其实是这样,比如一个股票:浦发银行对应代码600000,因为下单时要输入数字600000,但我现在只能抓的浦发银行的中文名称,所以怎么用autoit把我抓的中文名称转换成数字?比如建一个txt文档,其中每一行一个证券名称+数字代码,像这样:
浦发银行600000
白云机场600004
武钢股份600005
。。。
然后比如我抓取的证券名称为白云机场($Text2),源码如下:
$Text=ControlGetText ( "招商全能版V6.45 -", "", 65281)
$Text2=StringRight ( $Text,4 )
下一步我要输入600004,在txt文件中找到白云机场600004这一行,然后怎么输入600004?写了一大堆,不知道有人看懂不?哪位大虾帮帮忙? 用ini,
白云机场=600004
我觉得这样比较方便 我不懂股票,没用过你说的通达信。。汗。。 嘿嘿,股票有1000多个,所以想引用txt里面对应的 其实没那么复杂,就是提取到一组文字,然后在txt文件中找到一致的,再引用一致文件的后面几个字符或下一行的字符,让程序自动输入 Global $X = IniRead($ini, "证券", "X1", "")
Global $Y = IniRead($ini, "证券", "Y1", "")
在ini文件里面这样写
[证券]
X1=白云机场
Y1=600004
X2=罗岗机场
Y2=600003
希望给你参考 $Text=ControlGetText ( "招商全能版V6.45 -", "", 65281)
$Text2=StringRight ( $Text,4 )
$file =fileopen("1.ini" ,0)
$read=fileread($file)
$c=StringMid($read,StringInStr($read,$Text2)+4,6)
MsgBox(0, "Rightmost 3 characters are:", $c)
先谢谢各位帮忙,又研究了半天,我用这个可以取得,但有错误,就是如果招商全能版V6.45 没有运行,它还是会去取数据,取第一行第四个字开始,不知道什么原因。下面这个源码为什么不运行?谁帮我看看
Func Button1Click();强卖
#region --- ScriptWriter generated code Start ---
Opt("WinWaitDelay",100)
Opt("WinTitleMatchMode",2)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",0)
WinWait("网上交易","")
If Not WinActive("网上交易","") Then WinActivate("网上交易","")
WinWaitActive("网上交易","")
Send("{F2}")
$Text=ControlGetText ( "飞狐交易师 - ", "", 65281 )
$Text2=StringRight ( $Text,6 )
Sleep(300)
ControlClick ( "网上交易", "", 12005,"left",1)
If $Text2>0 Then
Send($Text2)
Sleep(480)
$Text3=ControlGetText ( "飞狐-通达信类下单", "", "Edit1" )
Send($Text3);输入价格
Sleep(150)
Send("{ENTER}")
$Text18=ControlGetText ( "飞狐-通达信类下单", "", "Edit2" )
Send($Text18);输入数量
Sleep(180)
Send("{ENTER}");交易确定前的回车
Sleep(200)
If Not WinActive("提示","") Then ;WinActivate("提示","")
Sleep(200)
Send("{ENTER}");交易确定
Sleep(200)
WinWait("提示","")
If Not WinActive("提示","") Then WinActivate("提示","")
WinWaitActive("提示","")
Send("{ENTER}");提交提示确定
;ElseIf $Text8<0Then
Else
;MsgBox ("{ENTER}" , "提示", "没有持仓,回车取消提示!" ,1000 )
Send("{ENTER}");判断空仓提示确定
Endif
Else
MsgBox ("{ENTER}" , "提示", "行情软件不匹配,回车取消提示!" ,1000 )
Endif
ControlSetText ( "飞狐-通达信类下单", "", "Edit1","" )
ControlSetText ( "飞狐-通达信类下单", "", "Edit2","" )
#endregion --- ScriptWriter generated code End ---
EndFunc
Func Button2Click()
#region --- ScriptWriter generated code Start ---
Opt("WinWaitDelay",100)
Opt("WinTitleMatchMode",2)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",0)
$Text=ControlGetText ( "飞狐交易师 - ", "", 65281 )
$Text2=StringRight ( $Text,6 )
Sleep(300)
WinWait("网上交易","")
If Not WinActive("网上交易","") Then WinActivate("网上交易","")
WinWaitActive("网上交易","")
Send("{F1}")
Sleep(300)
;ControlClick ( "网上交易", "", 12005,"left",1)
If $Text2>0 Then
Send($Text2)
Sleep(480)
$Text3=ControlGetText ( "飞狐-通达信类下单", "", "Edit1" )
Send($Text3)
Send("{ENTER}");第一个回车
Sleep(150)
$Text18=ControlGetText ( "飞狐-通达信类下单", "", "Edit2" )
Send($Text18)
Sleep(180)
Send("{ENTER}");第二个回车
Sleep(200)
Send("{ENTER}");交易确定
Sleep(200)
Send("{ENTER}");提示确定
Sleep(180)
Send("{ENTER}")
Else
MsgBox ("{ENTER}" , "提示", "行情软件不匹配,控件不对,回车取消提示!" ,1000 )
EndIf
ControlSetText ( "飞狐-通达信类下单", "", "Edit1","" )
ControlSetText ( "飞狐-通达信类下单", "", "Edit2","" )
#endregion --- ScriptWriter generated code End ---
EndFunc
Func Button5Click();仓位
#region --- ScriptWriter generated code Start ---
Opt("WinWaitDelay",100)
Opt("WinTitleMatchMode",2)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",0)
WinWait("网上交易","")
If Not WinActive("网上交易","") Then WinActivate("网上交易","")
WinWaitActive("网上交易","")
;Send("{F2}")
MouseMove(70,130)
MouseDown("left")
MouseUp("left")
#endregion --- ScriptWriter generated code End ---
EndFunc
Func Button6Click()
#region --- ScriptWriter generated code Start ---
Opt("WinWaitDelay",100)
Opt("WinTitleMatchMode",2)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",0)
WinWait("网上交易","")
If Not WinActive("网上交易","") Then WinActivate("网上交易","")
WinWaitActive("网上交易","")
Send("{F3}")
Sleep(800)
IfWinActive("提示","")Then
Send("{ENTER}")
Else
Endif
#endregion --- ScriptWriter generated code End ---
EndFunc
Func Button7Click()
#region --- ScriptWriter generated code Start ---
Opt("WinWaitDelay",100)
Opt("WinTitleMatchMode",2)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",0)
WinWait("网上交易","")
If Not WinActive("网上交易","") Then WinActivate("网上交易","")
WinWaitActive("网上交易","")
Send("{F10}")
Sleep(1800)
Send("{ENTER}")
#endregion --- ScriptWriter generated code End ---
EndFunc
Func Button8Click()
#region --- ScriptWriter generated code Start ---
Opt("WinWaitDelay",100)
Opt("WinTitleMatchMode",2)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",0)
WinWait("网上交易","")
If Not WinActive("网上交易","") Then WinActivate("网上交易","")
WinWaitActive("网上交易","")
Send("{F3}")
Sleep(800)
If Not WinActive("提示","")Then
Sleep(200)
ControlClick ( "网上交易", "", 14,"left",2)
Sleep(200)
ControlClick ( "网上交易", "", 1136,"left",2)
WinWait("提示","确定")
If Not WinActive("提示","确定") Then WinActivate("提示","确定")
WinWaitActive("提示","确定")
Sleep(200)
Send("{ENTER}")
Sleep(300)
Send("{ENTER}")
Sleep(680)
Send("{ENTER}")
Sleep(200)
Send("{ENTER}")
Else
;MsgBox ("{ENTER}" , "提示", "没有挂单,回车取消提示!" ,1000 )
Send("{ENTER}")
Endif
#endregion --- ScriptWriter generated code End ---
EndFunc
Func Form1_1Close()
Exit
EndFunc
Func Form1_1Maximize()
EndFunc
Func Form1_1Minimize()
EndFunc
Func Form1_1Restore()
EndFunc
Func Input1Change()
EndFunc
Func Input2Change()
EndFunc
Func Label1Click()
EndFunc
Func Label2Click()
EndFunc 不如直接整个sqlite数据库了 谢谢大家,已经解决了 源码如下:
$Text=ControlGetText ( "招商全能版V6.45 -", "", 65281)
$Text2=StringRight ( $Text,6 )
$file =fileopen("1.ini" ,0)
$read=fileread($file)
$jc=StringInStr($read,$Text2)
If $jc>0 Then
$Text3=StringMid($read,$jc+6,6)
MsgBox(0, "Rightmost 3 characters are:", $Text3)
Else
MsgBox(0, "Rightmost 3 characters are:", "无此证券请添加")
EndIf
页:
[1]