[Ma...] Posted May 15 Share Posted May 15 Curious if there is a way without PCM to automatically close the Gear Pro program after the PDF report is generated at the end of the run? Link to comment https://qualityforum.zeiss.com/topic/26634-automatically-close-gear-pro-program/ Share on other sites More sharing options...
[Ro...] Posted May 18 Share Posted May 18 Still a known but not realized functionality to set this directly in GEAR PRO. 1 Link to comment https://qualityforum.zeiss.com/topic/26634-automatically-close-gear-pro-program/#findComment-150730 Share on other sites More sharing options...
[Ch...] Posted May 18 Share Posted May 18 Windows cmd, with .bat file ? you would have to guesstimate the gear run time per program, and use it in Calypso to start a timer, etc. Would take some development, but just a thought, obviously don't want to close it too soon. 1 Link to comment https://qualityforum.zeiss.com/topic/26634-automatically-close-gear-pro-program/#findComment-150760 Share on other sites More sharing options...
[DW...] Posted May 27 Share Posted May 27 Please sign in to view this username. You need a script that watches a location for PDF generation, waits for PDF generation to complete, then executes a command to close your program. If you were using PowerShell, it might look like this: # ============================================================ # PowerShell Script: Monitor for PDF Report and Close Program # ============================================================ # ----------------------------- # CONFIGURATION SECTION # ----------------------------- # Folder to monitor $WatchFolder = "C:\Reports" # File filter $Filter = "*.pdf" # Wait time after PDF creation $WaitSeconds = 30 # Prevent duplicate processing $Script:AlreadyTriggered = $false # ----------------------------- # FIND ZEISS/CALYPSO PROCESS # ----------------------------- $DetectedProcess = Get-Process | Where-Object { $_.ProcessName -match "calypso|zeiss|gear" } | Select-Object -First 1 if ($DetectedProcess) { $ProcessName = $DetectedProcess.ProcessName Write-Host "Detected process: $ProcessName" } else { Write-Host "No ZEISS/CALYPSO process found." exit } # ----------------------------- # CREATE FILE SYSTEM WATCHER # ----------------------------- $Watcher = New-Object System.IO.FileSystemWatcher $Watcher.Path = $WatchFolder $Watcher.Filter = $Filter $Watcher.NotifyFilter = [System.IO.NotifyFilters]'FileName, LastWrite' $Watcher.EnableRaisingEvents = $true # ----------------------------- # ACTION WHEN PDF IS DETECTED # ----------------------------- $Action = { # Prevent multiple triggers if ($Script:AlreadyTriggered) { return } $Script:AlreadyTriggered = $true $FilePath = $Event.SourceEventArgs.FullPath Write-Host "PDF detected: $FilePath" # Wait for file generation to complete Write-Host "Waiting $using:WaitSeconds seconds..." Start-Sleep -Seconds $using:WaitSeconds # Verify file is accessible try { $stream = [System.IO.File]::Open( $FilePath, 'Open', 'Read', 'None' ) $stream.Close() Write-Host "PDF file is complete." } catch { Write-Host "PDF still locked or unavailable." } # Get process again before closing $Process = Get-Process -Name $using:ProcessName -ErrorAction SilentlyContinue if ($Process) { Write-Host "Closing process: $using:ProcessName" # Try graceful close first $Process.CloseMainWindow() | Out-Null Start-Sleep -Seconds 5 # Force close if still running if (Get-Process -Name $using:ProcessName -ErrorAction SilentlyContinue) { Write-Host "Force stopping process..." Stop-Process -Name $using:ProcessName -Force } Write-Host "Process closed." } else { Write-Host "Process not running." } } # ----------------------------- # REGISTER EVENT # ----------------------------- Register-ObjectEvent ` -InputObject $Watcher ` -EventName Created ` -Action $Action | Out-Null # ----------------------------- # KEEP SCRIPT RUNNING # ----------------------------- Write-Host "Monitoring folder: $WatchFolder" Write-Host "Waiting for PDF files..." Write-Host "Press CTRL+C to stop." while ($true) { Start-Sleep -Seconds 1 } Link to comment https://qualityforum.zeiss.com/topic/26634-automatically-close-gear-pro-program/#findComment-151148 Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in