当前位置 博文首页 > haimianjie2012的专栏:paraview C/S mode:如何使用python控件pa

    haimianjie2012的专栏:paraview C/S mode:如何使用python控件pa

    作者:[db:作者] 时间:2021-08-18 21:51

    目录

    问题阐述

    背景介绍

    解决方法:

    1.第一步,将调整好的设置保存state

    2.第二步,autoit自动加载state文件


    问题阐述

    问题已经在paraview中描述了,这里不再重复描述,下面是文件描述链接:

    how to use python control paraveiw GUI adjust cameara when work with client /server mode - ParaView Support - ParaView

    背景介绍

    1.paraview client/server mode

    2.paraview save results

    解决方法:

    1.第一步,将调整好的设置保存state

    【File】==>【Save State】

    2.第二步,autoit自动加载state文件

    启动paraview并连接到pvserver服务器之后,autoit自动控制paraview GUI加载保存的state文件state.pvsm

    autoit脚本代码:

    WinMenuSelectItem("ParaView 5.9.0","","&File","Load State...")
    
    Send("!f")
    For $i=1 To 2 Step 1
        Send("{DOWN}")
    	Sleep(500)
    Next
    Send("{ENTER}")
    
    Local $hWserver=WinWaitActive("Load State File")
    ;深入state.pvsm
    Send("state.pvsm{ENTER}")
    
    For $i=1 To 2 Step 1
        Send("{TAB}")
    	Sleep(100)
    Next
    Send("{SPACE}")
    
    WinWaitActive("Load State Options")
    Send("{ENTER}")

    autoit完整代码:

    包括操作:1.启动paraview.exe;2.连接到pvserver服务器;3.等待paraview连接到pvserver服务器后,加载state文件state.pvsm

    有关autoit讲解:(7条消息) autoit自动化控制windows程序:paraview GUI_haimianjie2012的专栏-CSDN博客

    因为项目需要,这里paraview使用的是Client/Server模式,你也可以使用paraview模式,即去掉连接pvserver服务器的代码:

    WinMenuSelectItem("ParaView 5.9.0","","&File","Connect...")
    
    
    Send("!f")
    For $i=1 To 12 Step 1
        Send("{DOWN}")
    	Sleep(200)
    Next
    Send("{ENTER}")
    
    Local $hWserver=WinWaitActive("Choose Server Configuration")
    For $i=1 To 3 Step 1
        Send("{TAB}")
    	Sleep(300)
    Next
    #Sleep(2000)
    Send("{ENTER}")
    #MsgBox($MB_OK, "wait paraview connect to server","connect")
    #WinWaitActive("ParaView 5.9.0")
    #MsgBox($MB_OK, "load state","connect")
    ;wait 40 seconds,connect need 40 seconds
    Sleep(37000)

    paraview GUI连接到pvserver服务器

    #cs ----------------------------------------------------------------------------
    
     AutoIt Version: 3.3.14.5
     Author:         myName
    
     Script Function:
    	Template AutoIt script.
    
    #ce ----------------------------------------------------------------------------
    
    ; Script Start - Add your code below here
    #include <MsgBoxConstants.au3>
    
    #Run("pvserver.exe","C:\\Program Files\\ParaView 5.9.0-Windows-Python3.8-msvc2017-64bit\\bin")
    #WinWaitActive("C:\Program Files\ParaView 5.9.0-Windows-Python3.8-msvc2017-64bit\bin\pvserver.exe")
    Run("paraview.exe","C:\\Program Files\\ParaView 5.9.0-Windows-Python3.8-msvc2017-64bit\\bin")
    WinWaitActive("ParaView 5.9.0")
    WinWaitActive("Welcome to ParaView")
    WinClose("Welcome to ParaView")
    
    WinMenuSelectItem("ParaView 5.9.0","","&File","Connect...")
    
    
    Send("!f")
    For $i=1 To 12 Step 1
        Send("{DOWN}")
    	Sleep(200)
    Next
    Send("{ENTER}")
    
    Local $hWserver=WinWaitActive("Choose Server Configuration")
    For $i=1 To 3 Step 1
        Send("{TAB}")
    	Sleep(300)
    Next
    #Sleep(2000)
    Send("{ENTER}")
    #MsgBox($MB_OK, "wait paraview connect to server","connect")
    #WinWaitActive("ParaView 5.9.0")
    #MsgBox($MB_OK, "load state","connect")
    ;wait 40 seconds,connect need 40 seconds
    Sleep(37000)
    WinMenuSelectItem("ParaView 5.9.0","","&File","Load State...")
    
    
    Send("!f")
    For $i=1 To 2 Step 1
        Send("{DOWN}")
    	Sleep(500)
    Next
    Send("{ENTER}")
    #MsgBox($MB_OK, "beigin connect","connect")
    #Sleep(1000)
    Local $hWserver=WinWaitActive("Load State File")
    ;深入state.pvsm
    Send("state.pvsm{ENTER}")
    
    For $i=1 To 2 Step 1
        Send("{TAB}")
    	Sleep(100)
    Next
    Send("{SPACE}")
    
    WinWaitActive("Load State Options")
    Send("{ENTER}")
    
    #cs
    IF Not $hWserver Then
    	MsgBox($MB_OK, "rdm first scrip","hello,rdm")
    	Sleep(2000)
    	Exit
    EndIf
    
    If $hWserver Then ; Check if Notepad is currently active.
        MsgBox($MB_SYSTEMMODAL, "", "WinActive" & @CRLF & "Notepad is active.")
    	Sleep(2000)
    Else
        MsgBox($MB_SYSTEMMODAL, "", "WinActive" & @CRLF & "Notepad is not active.")
    	Sleep(2000)
    EndIf
    #ce
    
    
    #WinClose("Choose Server Configuration")
    #WinClose("ParaView 5.9.0")
    #WinClose("C:\Program Files\ParaView 5.9.0-Windows-Python3.8-msvc2017-64bit\bin\pvserver.exe")

    autoit完整代码?

    cs