Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.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
应用程序windows闪存,而不是变为活动状态_Windows_User Interface_Microsoft Dynamics_Autoit - Fatal编程技术网

应用程序windows闪存,而不是变为活动状态

应用程序windows闪存,而不是变为活动状态,windows,user-interface,microsoft-dynamics,autoit,Windows,User Interface,Microsoft Dynamics,Autoit,我的AutoIt脚本根据传递的参数激活Dynamics AX应用程序。我打开并最小化了各种AX应用程序 大多数情况下,正确的应用程序(基于$partition参数)被激活并处于焦点,因此脚本将继续。但有时(可能是三分之一)应用程序只是在任务栏中闪烁,无法激活,因此脚本无法继续 .Net应用程序在Windows 2012 Server上通过参数调用我的AutoIt脚本: #include <MsgBoxConstants.au3> #include <GuiListView.au

我的AutoIt脚本根据传递的参数激活Dynamics AX应用程序。我打开并最小化了各种AX应用程序

大多数情况下,正确的应用程序(基于
$partition
参数)被激活并处于焦点,因此脚本将继续。但有时(可能是三分之一)应用程序只是在任务栏中闪烁,无法激活,因此脚本无法继续

.Net应用程序在Windows 2012 Server上通过参数调用我的AutoIt脚本:

#include <MsgBoxConstants.au3>
#include <GuiListView.au3>

Local $partition = $CmdLine[1]
Local $axc       = $CmdLine[2]
Local $brand     = $CmdLine[3]
Local $sTerm     = $CmdLine[4]

;command line example
;GoToCustomerServicePage.exe "msl" "MSLtd" "MSUK" "LS14 6PN"

SearchForCust($partition, $axc, $brand, $sTerm)

Func SearchForCust($partition, $axc, $brand, $sTerm)
    ;Set the Title match mode
    Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase

    Local $custSer = StringUpper($partition) & "/Omnica MCR/Common/Customer Service"
    Local $exePath = "C:\Program Files (x86)\Microsoft Dynamics AX\60\Client\Bin\Ax32.exe \\zoom-sql2\axcshare\" & $axc & ".axc"
    Local $axTitle = "[TITLE:" & $partition & "; CLASS:AxMainFrame]"

    ; Wait 10 seconds for the window to appear.
    WinWait($axTitle, "", 10)

    ; Test if the window exists and display the results.
    If WinExists($axTitle, "") Then
    Else
        Run($exePath)
        WinWait($axTitle, "", 20)
    EndIf

    Local $hWnd = WinGetHandle($axTitle)

    WinActivate($hWnd)

    If WinActive($hWnd) Then
    Else
        WinWaitActive($hWnd, 5)
    EndIf

    ; Simulate clicking on the address bar
    Send("{F11}")

    ;Enter this into the address bar
    Send($custSer)
    Send("{ENTER}")

    ;Set the Brand
    Send($brand)
    Send("{ENTER}")

    ;send search term
    If $sTerm <> "unavailable" Then
        Send($sTerm)
        Send("{ENTER}")
    EndIf

EndFunc
#包括
#包括
本地$partition=$CmdLine[1]
本地$axc=$CmdLine[2]
本地$brand=$CmdLine[3]
本地$sTerm=$CmdLine[4]
;命令行示例
;GoToCustomerServicePage.exe“msl”“MSLtd”“MSUK”“LS14 6PN”
SearchForCust($partition、$axc、$brand、$sTerm)
Func SearchForCust($partition、$axc、$brand、$sTerm)
;设置标题匹配模式
选择(“WinTitleMatchMode”,2);1=开始,2=次级,3=精确,4=高级,-1至-4=无条件
本地$custSer=StringUpper($partition)和“/Omnica MCR/公共/客户服务”
本地$exePath=“C:\Program Files(x86)\Microsoft Dynamics AX\60\Client\Bin\Ax32.exe\\zoom-sql2\axcshare\”和$axc&“.axc”
本地$axTitle=“[TITLE:&$partition&”类:AxMainFrame]”
; 等待10秒钟,窗口才会出现。
WinWait($axTitle,“,10)
; 测试窗口是否存在并显示结果。
如果WinExists($axTitle,“”),那么
其他的
运行($exePath)
WinWait($axTitle,“,20)
恩迪夫
本地$hWnd=wingthandle($axTitle)
WinActivate($hWnd)
如果WinActive($hWnd),则
其他的
WinWaitActive($hWnd,5)
恩迪夫
; 模拟单击地址栏
发送(“{F11}”)
;将其输入地址栏
发送($cusser)
发送(“{ENTER}”)
;树立品牌
发送($brand)
发送(“{ENTER}”)
;发送搜索词
如果$sTerm“不可用”,则
发送($sTerm)
发送(“{ENTER}”)
恩迪夫
EndFunc
试试这个:

; Test if the window exists and display the results.
If WinExists($axTitle, "") Then
    ; add here: check if the window is active - activate if not
    If Not WinActive($axTitle) Then WinActivate($axTitle)
Else
    Run($exePath)
    WinWait($axTitle, "", 20)
EndIf

在序列之间添加一组睡眠,看看它是否按预期工作。如果它呈橙色闪烁,这意味着程序已经执行,但从未被激活(我想)。可能您的应用程序处理速度太快(试图激活新窗口,但尚未注册),我将试一试,看看会发生什么情况
WinWaitActive($hWnd,5)
be
WinWaitActive($hWnd,”,5)
?是的,WinWaitActive缺少一个参数,但通过添加它似乎没有改变任何东西。好的,我在这里看到了逻辑-因此,在获取窗口句柄之前,请确保已激活窗口。应该可以在不激活窗口的情况下检索窗口句柄。。。