Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Internet explorer 错误太多:字符串不正确_1;控制发送?_Internet Explorer_Outlook_Autohotkey_Subject - Fatal编程技术网

Internet explorer 错误太多:字符串不正确_1;控制发送?

Internet explorer 错误太多:字符串不正确_1;控制发送?,internet-explorer,outlook,autohotkey,subject,Internet Explorer,Outlook,Autohotkey,Subject,从一个程序(IE)复制到“我的电子邮件主题”字段的字符串有时包含错误: 然而,变量主题的消息框(见下文)总是正确的: 主题=%protocol%,%LSN%,%Site%,%Requisition% 但是,当代码运行时: 十分之一的字符串未正确放入主题字段: 我希望: 协议C16019,LSN(102707),现场22902,请购单102921403 我得到: 协议c16019(小写字母C而不是大写字母C),lSN(&02707°(%而不是1,°而不是)),siteé2902(而不是2),请购单

从一个程序(IE)复制到“我的电子邮件主题”字段的字符串有时包含错误:

然而,变量主题的消息框(见下文)总是正确的:

主题=%protocol%,%LSN%,%Site%,%Requisition%

但是,当代码运行时:

十分之一的字符串未正确放入主题字段:

我希望:

协议C16019,LSN(102707),现场22902,请购单102921403

我得到:

协议c16019(小写字母C而不是大写字母C),lSN(&02707°(%而不是1,°而不是)),siteé2902(而不是2),请购单和02921403(&而不是1)

似乎AHK正在使用我的特殊字符(F1-F12键下方的字符行)或shift按钮正在激活。

为什么以及如何解决此问题?

我在某个地方读到,controlsend并不总是有效,这是一个已知的问题

旁注:我在另一个脚本中也看到了这一点,其中电子邮件地址的@并不总是放在“发送到”字段中

我的代码:

    Home::

    pwb := WBGet()
    pTable:= pwb.document.GetElementsByTagName("Table") [4] ;outerHTML ;Set Tag name and Array value
    Loop, % pTable.rows.length {
    LSN_1:= pTable.rows[9] .GetElementsByTagName("TD") [1].outerHTML ; LSN

    protocol_1:= pTable.rows[9] .GetElementsByTagName("TD") [3].outerHTML ; Protocol

    Site_1:=pTable.rows[10] .GetElementsByTagName("TD") [1].outerHTML ; Site

    Requisition_1:=pTable.rows[12] .GetElementsByTagName("TD") [3].outerHTML ;   Requisition


    StringTrimLeft, NLSN, LSN_1, 6   ;trims 6 characters from left  ( <TD> >)
    StringTrimRight, fLSN, NLSN, 5   ;trims 5 characters from right (<TD> )

    StringTrimLeft, Nprotocol, protocol_1, 6
    StringTrimRight, fprotocol, Nprotocol, 5


    StringTrimLeft, Nsite, site_1, 6
    StringTrimRight, fsite, Nsite, 5


    StringTrimLeft, NRequisition, Requisition_1, 6
    StringTrimRight, fRequisition, NRequisition, 5


    Requisition= requisition %fRequisition%

    sleep,10

    LSN= LSN (%fLSN%)  ; essential that this variable is put into brackets

    sleep,10

    Site= site %fsite% ; "site" has to be put before the string

    sleep,10

    Protocol= protocol %fprotocol% ;"protocol" has to be put before the string

    sleep,10

    subject= %protocol% , %LSN% , %Site% , %Requisition%

    sleep,150

;the variable in Msgbox is always correct here

    ;send the contents of subject into the subject of outlook
    controlFocus, RichEdit20WPT4, ahk_class rctrl_renwnd32
    controlSend, RichEdit20WPT4, {end} , ahk_class rctrl_renwnd32 ; send to the end of subject field
    controlSendRaw, RichEdit20WPT4, %subject%, ahk_class rctrl_renwnd32
    sleep,100
    subject :=""
    return
    } 
Home::
pwb:=WBGet()
pTable:=pwb.document.GetElementsByTagName(“表”)[4];外层TML;设置标记名和数组值
循环,%pTable.rows.length{
LSN_1:=pTable.rows[9]。GetElementsByTagName(“TD”)[1]。outerHTML;LSN
协议_1:=pTable.rows[9]。GetElementsByTagName(“TD”)[3]。outerHTML;协议
Site_1:=pTable.rows[10]。GetElementsByTagName(“TD”)[1]。outerHTML;Site
请购单_1:=pTable.rows[12]。GetElementsByTagName(“TD”)[3]。outerHTML;请购单
StringTrimLeft,NLSN,LSN_1,6;从左侧修剪6个字符(>)
StringTrimRight,fLSN,NLSN,5;从右侧修剪5个字符()
StringTrimpleft,Nprotocol,协议1,6
StringTrimRight,fprotocol,Nprotocol,5
左弦,Nsite,现场1,6
StringTrimRight,fsite,Nsite,5
左、右请购单、请购单1、6
右,右,频率,NRequisition,5
请购单=请购单%频率%
睡吧,10
LSN=LSN(%fLSN%);必须将此变量置于括号内
睡吧,10
Site=Site%fsite%;“Site”必须放在字符串之前
睡吧,10
协议=协议%fprotocol%;“协议”必须放在字符串之前
睡吧,10
主题=%protocol%,%LSN%,%Site%,%Requisition%
睡吧,150
;此处Msgbox中的变量始终正确
;将主题的内容发送到outlook的主题中
controlFocus,RichEdit20WPT4,ahk_等级rctrl_renwnd32
controlSend,RichEdit20WPT4,{end},ahk_类rctrl_renwnd32;发送到主题字段的末尾
controlSendRaw,RichEdit20WPT4,%subject%,ahk_类rctrl_renwnd32
睡吧,100
主题:=“”
返回
} 
字符串在10%-20%的时间内不正确


请注意,我是一个完全的新手,我已经学习和尝试写脚本大约两个星期了。我不明白为什么这个脚本不能100%工作。

您使用ControlSendRaw而不是ControlSend有什么原因吗?我打赌这可能是你的问题

如果您继续使用,建议您使用On和BlockInput、Off环绕代码来限制按键的干扰

以下是您在上面发布的内容的清理版本:

Home::

    pwb := WBGet()
    pTable := pwb.document.GetElementsByTagName("Table") [4] ;outerHTML ;Set Tag name and Array value
    LSN_1 := pTable.rows[9] .GetElementsByTagName("TD") [1].outerHTML ; LSN
    protocol_1:= pTable.rows[9] .GetElementsByTagName("TD") [3].outerHTML ; Protocol
    Site_1:=pTable.rows[10] .GetElementsByTagName("TD") [1].outerHTML ; Site
    Requisition_1:=pTable.rows[12] .GetElementsByTagName("TD") [3].outerHTML ;   Requisition  

    subject := "protocol " trimVar(protocol_1) " , LSN (" trimVar(LSN_1) ") , Site " trimVar(Site_1) " ,  Requisition " trimVar(Requisition_1)

    ;send the contents of subject into the subject of outlook
    controlFocus, RichEdit20WPT4, ahk_class rctrl_renwnd32
    controlSend, RichEdit20WPT4, {end} , ahk_class rctrl_renwnd32 ; send to the end of subject field
    BlockInput, On
    controlSendRaw, RichEdit20WPT4, %subject%, ahk_class rctrl_renwnd32
    BlockInput, Off
    sleep,100
    subject :=""
return

trimVar(x) { 
    StringTrimLeft, x, x, 6   ;trims 6 characters from left  ( <TD> >)
    StringTrimRight, x, x, 5   ;trims 5 characters from right (<TD> )
    Return x
}
Home::
pwb:=WBGet()
pTable:=pwb.document.GetElementsByTagName(“表”)[4];外层TML;设置标记名和数组值
LSN_1:=pTable.rows[9]。GetElementsByTagName(“TD”)[1]。outerHTML;LSN
协议_1:=pTable.rows[9]。GetElementsByTagName(“TD”)[3]。outerHTML;协议
Site_1:=pTable.rows[10]。GetElementsByTagName(“TD”)[1]。outerHTML;场地
请购单_1:=pTable.rows[12]。GetElementsByTagName(“TD”)[3]。outerHTML;征用
主题:=“协议”trimVar(协议1)”、LSN(“trimVar(LSN_1)”、站点“trimVar(站点1)”、请求“trimVar(请求1)”
;将主题的内容发送到outlook的主题
controlFocus,RichEdit20WPT4,ahk_等级rctrl_renwnd32
controlSend,RichEdit20WPT4,{end},ahk_class rctrl_renwnd32;发送到主题字段的末尾
块输入,打开
controlSendRaw,RichEdit20WPT4,%subject%,ahk_类rctrl_renwnd32
块输入,关闭
睡吧,100
主题:=“”
返回
trimVar(x){
StringTrimLeft,x,x,6;从左侧修剪6个字符(>)
StringTrimRight,x,x,5;从右侧修剪5个字符()
返回x
}
我不认为真正需要循环,可能是查找行和列的索引时留下的代码?或者可能有一个目的,很容易把它们重新编辑进去。希望这能解决你的随机性格问题。如果不是,请尝试使用普通ControlSend而不是ControlSendRaw,删除块输入

在我看来,当您使用此脚本插入文本时,您可能正在Outlook中主动键入电子邮件?如果是这种情况,则以下代码用于激活它而不是热键,并且不再需要ControlSend:

#IfWinActive ahk_class rctrl_renwnd32 ;The code below will only work if Outlook is the Active application
::insertlsn:: ;Type HotString to activate code below
    pwb := WBGet()
    pTable := pwb.document.GetElementsByTagName("Table") [4] ;outerHTML ;Set Tag name and Array value
    LSN_1 := pTable.rows[9] .GetElementsByTagName("TD") [1].outerHTML ; LSN
    protocol_1:= pTable.rows[9] .GetElementsByTagName("TD") [3].outerHTML ; Protocol
    Site_1:=pTable.rows[10] .GetElementsByTagName("TD") [1].outerHTML ; Site
    Requisition_1:=pTable.rows[12] .GetElementsByTagName("TD") [3].outerHTML ;   Requisition

    subject := "protocol " trimVar(protocol_1) " , LSN (" trimVar(LSN_1) ") , Site " trimVar(Site_1) " ,  Requisition " trimVar(Requisition_1)

    SendInput, %subject%
return 

trimVar(x) { 
    StringTrimLeft, x, x, 6   ;trims 6 characters from left  ( <TD> >)
    StringTrimRight, x, x, 5   ;trims 5 characters from right (<TD> )
    Return x
}
#IfWinActive ahk#U类rctrl#U renwnd32;以下代码仅在Outlook是活动应用程序时有效
::insertlsn::;键入热字符串以激活下面的代码
pwb:=WBGet()
pTable:=pwb.document.GetElementsByTagName(“表”)[4];外层TML;设置标记名和数组值
LSN_1:=pTable.rows[9]。GetElementsByTagName(“TD”)[1]。outerHTML;LSN
协议_1:=pTable.rows[9]。GetElementsByTagName(“TD”)[3]。outerHTML;协议
Site_1:=pTable.rows[10]。GetElementsByTagName(“TD”)[1]。outerHTML;场地
请购单_1:=pTable.rows[12]。GetElementsByTagName(“TD”)[3]。outerHTML;征用
主题:=“协议”trimVar(协议1)”,LSN(“trimVar(LSN_1)”),站点“trimVar(站点1)”,请求