简体   繁体   English

sendkeys() 到 bloomberg 面板 python

[英]sendkeys() to bloomberg panel python

I try to do a basic sendkeys() to and open an logged into bloomberg panel.我尝试执行一个基本的sendkeys()并打开一个已登录的 bloomberg 面板。

I am able to verify that sendkeys() works with this:我能够验证sendkeys()是否适用于此:

import time
import win32com.client as comclt

wsh= comclt.Dispatch("WScript.Shell")
wsh.AppActivate("Notepad") # select another application
time.sleep(0.5) # wait for half a second
wsh.SendKeys("a") # send the keys you want
print('key is sent')

What i have tried: With the above i try to change Notepad for Bloomberg or Bloomberg App Host as is seen in the task manager, but i am unable to sendkeys...我尝试了什么:通过上面的内容,我尝试更改任务管理器中看到的BloombergBloomberg App HostNotepad ,但我无法发送密钥...

How can one get this to work or is there an alternative method that does work?如何才能让它发挥作用,或者是否有另一种有效的方法?

assuming you are trying to log into bloomberg automatically using some script.假设您正在尝试使用某些脚本自动登录 bloomberg。 i use vbscript to achieve this at a scheduled time of the day.我使用 vbscript 在一天中的预定时间实现此目的。

below is my vb script saved as a.vbs file and executed using windows task manager下面是我保存为.vbs文件并使用windows任务管理器执行的vb脚本

you will need to change loginname and password to match yours您将需要更改登录名和密码以匹配您的

the commented part of the loop waits for the Bloomberg chat window to appear.循环的注释部分等待 Bloomberg 聊天 window 出现。 this was then commented as i made some settings on bloomberg to not to open chat window upon logon.当我在 bloomberg 上进行一些设置以在登录时不打开聊天 window 时对此进行了评论。 - i do not remember what was exactly done then - 我不记得当时到底做了什么

This will work only if you have a bloomberg open terminal which does not ask for an otp after login as it generally asks on a Bloomberg Anywhere terminal这只有在你有一个 bloomberg 开放式终端时才有效,该终端在登录后不要求 otp,因为它通常在 Bloomberg Anywhere 终端上要求

also before running this script ensure that bloomberg application is closed / not open在运行此脚本之前还要确保 bloomberg 应用程序已关闭/未打开

you may use taskkill command to close all the instances of wintrv.exe您可以使用 taskkill 命令关闭 wintrv.exe 的所有实例

taskkill /IM wintrv.exe /F

Below is the vbs script.下面是vbs脚本。

set WshShell = WScript.CreateObject("WScript.Shell") 
dim ret
ret = False
do while ret=False
ret = WshShell.AppActivate("BLOOMBERG: Login")
WScript.Sleep 10000
If ret = True Then
    'CreateObject("WScript.Shell").PopUp "here", 5
    'WshShell.AppActivate("BLOOMBERG: Login")
    WScript.Sleep 3000 
    WshShell.SendKeys "{esc}" 
    WScript.Sleep 1000 
    WshShell.SendKeys "login~" 
    WScript.Sleep 10000 
    WshShell.SendKeys "loginname{tab}password~"
    wScript.Sleep 20000
else
    Call WshShell.Run("C:\blp\Wintrv\wintrv.exe")
    WScript.Sleep 15000
End If 
loop
'WScript.Sleep 5000
'ret=False
'do while ret=False
'ret = WshShell.AppActivate("IB - IB Manager")
'if ret=False Then
'   WScript.Sleep 3000
'End If
'loop
WScript.Sleep 5000
WshShell.AppActivate("New Tab")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM