0
나는 스크린 샷을 세분화하고 아래 그림과 같이 각 미리 정의 된 블록을 자체 이미지로 저장하는 격자와 같은 스크린 샷을 반복해야합니다. 실제 그리드 크기는 10X8입니다. 2 번 열을 건너 뛰고 있습니다. 지난 3 일 동안 100 번 if 블록을 10 가지 방법으로 다시 작성 했으므로 논리적 결함으로 교육 해 주시기 바랍니다. 이미지를 세분화하는 동안 루프가 전체 열을 건너 뜁니다.
Col1 Col2 Col3
Row1 1 2 3
Row2 4 5 6
Row3 7 8 9
"Starting to loop image for each ball" [int]$startCell = 1 [int]$startRow = 1 [int]$startColumn = 1 [int]$totalLoops = 81 [int]$startleftCoord = 293 [int]$starttopCoord = 90 [int]$startrightCoord = 385 [int]$startbottomCoord = 160 [int]$cellheight = 75 [int]$cellwidth = 100 [int]$offset = 2 Do { #get the current time and build the filename from it $Time = (Get-Date) [string] $FileName += "-cellshot" $FileName = "$($Time.Month)" $FileName += '-' $FileName += "$($Time.Day)" $FileName += '-' $FileName += "$($Time.Year)" $FileName += '-' $FileName += "$($Time.Hour)" $FileName += '-' $FileName += "$($Time.Minute)" $FileName += '-' $FileName += "$($Time.Second)" $FileName += '-' $FileName += "$($Time.Millisecond)" $FileName += '-' $FileName += [string]$currentCell $FileName += '.png' #use join-path to add path to filename [string] $FilePath = (Join-Path $Path $FileName) if (!$currentCell -OR !$currentColumn -OR !$currentRow){ "Initializing Globals" $currentCell = $startCell $currentColumn = $startColumn $currentRow = $startRow } "Designate capture point" if ($currentColumn -gt 1 -AND $currentColumn -lt 11) { "Calculating side coordinates offset" $newleftCoord = $startleftCoord+($currentColumn*$cellwidth) $newrightCoord = $startrightCoord+($currentColumn*$cellwidth) } elseif ($currentColumn -eq 11) { "Resetting column coordinates " $currentColumn = $startColumn $newleftCoord = $startleftCoord $newrightCoord = $startrightCoord "Compensating for multiple rows offest" $newtopCoord = $starttopCoord+($currentRow*$cellheight)+$offset $newbottomCoord = $startbottomCoord+($currentRow*$cellheight)+$offset $currentRow++ }else{ "Getting number one" $newleftCoord = $startleftCoord $newtopCoord = $starttopCoord $newrightCoord = $startrightCoord $newbottomCoord = $startbottomCoord } "Current Column is " + $currentColumn "Current row is " + $currentRow "Current cell is " + $currentCell #save cellshot $cellBounds = [Drawing.Rectangle]::FromLTRB($newleftCoord,$newtopCoord, $newrightCoord, $newbottomCoord) $cellObject = New-Object Drawing.Bitmap $cellBounds.Width, $cellBounds.Height $cellGraphics = [Drawing.Graphics]::FromImage($cellObject) $cellGraphics.CopyFromScreen($cellBounds.Location, [Drawing.Point]::Empty, $cellBounds.Size) $cellGraphics.Dispose() $cellObject.Save($FilePath) $currentColumn++ $currentCell++ }Until ($currentCell -eq $totalLoops) Start-Sleep -Second 20 } #load required assembly Add-Type -Assembly System.Windows.Forms Start-Sleep -Seconds 5 $ballarray = @{} Do { #run screenshot function # If ($ballarray.count -eq 20){ # GenScreenshot # "Snapped screenshot - $Filename ." # }else{ Do{ GetNewBall }Until($currentCell -eq 80) #} #$bounds = [Drawing.Rectangle]::FromLTRB(307,129, 1060, 668) #screenshot $bounds $Filepath #Start-Sleep -Second 10 }Until($ballarray.count -eq 20)
의 0부터 카운트가 시간을내어 주셔서 감사합니다. "어떻게 & 왜"에 대한 자세한 설명을 위해 나는 결과를 얻고있었습니다. 귀하의 "고침"은 정확히 해결책이었습니다. 나는 너를 부러워한다. @TessellatingHeckler 당신의 관대함에 감사드립니다. 나는 지역 사회에 기여하고 활동적으로 활동하며 15 세 이상의 내 대리인을 얻은 다음 당신의 대답에 공헌합니다. 그때까지, 누군가가 표를 따라 산책을하기를 바랍니다. – Eric
@Eric Thanks :) 아직 PowerShell ISE를 살펴 보지 않았다면 Windows와 함께 제공됩니다. 스크립트를 열고 루프의 맨 위에있는 코드를 클릭하고 Debug> Toggle Breakpoint' (또는 F9 키), 선이 빨간색으로 바뀝니다. 그런 다음'Debug -> Run/Continue' (F5)를 실행하면 해당 행에서 실행되고 중지됩니다. 한 번에 한 줄씩'Debug-> Step Over' (F10과 F11) 할 수 있습니다. 정말 유용하게 변수 위에 마우스를 올리거나 값을 볼 수 있습니다. 열 위치가 잘못 변경된 이유와 이유를 정확히 찾아보십시오. '[DBG] : PS >>'프롬프트에서 코드를 실행하고, 일시 정지 상태에서 찌릅니다. – TessellatingHeckler
(추신 : 원하는 경우 투표 화살표 아래의 체크 표시를 선택하고 '대답'을 '수락'하면 질문이 '답변 됨'으로 표시되고 점수가 표시됨). – TessellatingHeckler