-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbenchmark.psm1
2310 lines (1714 loc) · 66.1 KB
/
benchmark.psm1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
function benchmark ([string]$para1, [string]$para2, [string]$para3,[string]$para4){
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Bypass -Force;
$shell=New-Object -ComObject shell.application
$wshell=New-Object -ComObject wscript.shell
Add-Type -AssemblyName Microsoft.VisualBasic
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Windows.Forms,System.Drawing
#region functions
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
public class Window {
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect);
}
public class Win32 {
[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect);
}
public struct RECT {
public int Left;
public int Top;
public int Right;
public int Bottom;
}
"@
$source = @"
using System;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace KeySends
{
public class KeySend
{
[DllImport("user32.dll")]
public static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);
private const int KEYEVENTF_EXTENDEDKEY = 1;
private const int KEYEVENTF_KEYUP = 2;
public static void KeyDown(Keys vKey)
{
keybd_event((byte)vKey, 0, KEYEVENTF_EXTENDEDKEY, 0);
}
public static void KeyUp(Keys vKey)
{
keybd_event((byte)vKey, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
}
}
}
"@
Add-Type -TypeDefinition $source -ReferencedAssemblies "System.Windows.Forms"
$cSource = @'
using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;
public class Clicker
{
//https://msdn.microsoft.com/en-us/library/windows/desktop/ms646270(v=vs.85).aspx
[StructLayout(LayoutKind.Sequential)]
struct INPUT
{
public int type; // 0 = INPUT_MOUSE,
// 1 = INPUT_KEYBOARD
// 2 = INPUT_HARDWARE
public MOUSEINPUT mi;
}
//https://msdn.microsoft.com/en-us/library/windows/desktop/ms646273(v=vs.85).aspx
[StructLayout(LayoutKind.Sequential)]
struct MOUSEINPUT
{
public int dx ;
public int dy ;
public int mouseData ;
public int dwFlags;
public int time;
public IntPtr dwExtraInfo;
}
//This covers most use cases although complex mice may have additional buttons
//There are additional constants you can use for those cases, see the msdn page
const int MOUSEEVENTF_MOVED = 0x0001 ;
const int MOUSEEVENTF_LEFTDOWN = 0x0002 ;
const int MOUSEEVENTF_LEFTUP = 0x0004 ;
const int MOUSEEVENTF_RIGHTDOWN = 0x0008 ;
const int MOUSEEVENTF_RIGHTUP = 0x0010 ;
const int MOUSEEVENTF_MIDDLEDOWN = 0x0020 ;
const int MOUSEEVENTF_MIDDLEUP = 0x0040 ;
const int MOUSEEVENTF_WHEEL = 0x0080 ;
const int MOUSEEVENTF_XDOWN = 0x0100 ;
const int MOUSEEVENTF_XUP = 0x0200 ;
const int MOUSEEVENTF_ABSOLUTE = 0x8000 ;
const int screen_length = 0x10000 ;
//https://msdn.microsoft.com/en-us/library/windows/desktop/ms646310(v=vs.85).aspx
[System.Runtime.InteropServices.DllImport("user32.dll")]
extern static uint SendInput(uint nInputs, INPUT[] pInputs, int cbSize);
public static void LeftClickAtPoint(int x, int y)
{
//Move the mouse
INPUT[] input = new INPUT[3];
input[0].mi.dx = x*(65535/System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width);
input[0].mi.dy = y*(65535/System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height);
input[0].mi.dwFlags = MOUSEEVENTF_MOVED | MOUSEEVENTF_ABSOLUTE;
//Left mouse button down
input[1].mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
//Left mouse button up
input[2].mi.dwFlags = MOUSEEVENTF_LEFTUP;
SendInput(3, input, Marshal.SizeOf(input[0]));
}
}
'@
Add-Type -TypeDefinition $cSource -ReferencedAssemblies System.Windows.Forms,System.Drawing
function Set-WindowState {
<#
.LINK
https://gist.github.com/Nora-Ballard/11240204
#>
[CmdletBinding(DefaultParameterSetName = 'InputObject')]
param(
[Parameter(Position = 0, Mandatory = $true, ValueFromPipeline = $true)]
[Object[]] $InputObject,
[Parameter(Position = 1)]
[ValidateSet('FORCEMINIMIZE', 'HIDE', 'MAXIMIZE', 'MINIMIZE', 'RESTORE',
'SHOW', 'SHOWDEFAULT', 'SHOWMAXIMIZED', 'SHOWMINIMIZED',
'SHOWMINNOACTIVE', 'SHOWNA', 'SHOWNOACTIVATE', 'SHOWNORMAL')]
[string] $State = 'SHOW'
)
Begin {
$WindowStates = @{
'FORCEMINIMIZE' = 11
'HIDE' = 0
'MAXIMIZE' = 3
'MINIMIZE' = 6
'RESTORE' = 9
'SHOW' = 5
'SHOWDEFAULT' = 10
'SHOWMAXIMIZED' = 3
'SHOWMINIMIZED' = 2
'SHOWMINNOACTIVE' = 7
'SHOWNA' = 8
'SHOWNOACTIVATE' = 4
'SHOWNORMAL' = 1
}
$Win32ShowWindowAsync = Add-Type -MemberDefinition @'
[DllImport("user32.dll")]
public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
'@ -Name "Win32ShowWindowAsync" -Namespace Win32Functions -PassThru
if (!$global:MainWindowHandles) {
$global:MainWindowHandles = @{ }
}
}
Process {
foreach ($process in $InputObject) {
if ($process.MainWindowHandle -eq 0) {
if ($global:MainWindowHandles.ContainsKey($process.Id)) {
$handle = $global:MainWindowHandles[$process.Id]
} else {
Write-Error "Main Window handle is '0'"
continue
}
} else {
$handle = $process.MainWindowHandle
$global:MainWindowHandles[$process.Id] = $handle
}
$Win32ShowWindowAsync::ShowWindowAsync($handle, $WindowStates[$State]) | Out-Null
Write-Verbose ("Set Window State '{1} on '{0}'" -f $MainWindowHandle, $State)
}
}
}
# create a new .NET type
$signature = @"
[DllImport("user32.dll")]public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
"@
Add-Type -MemberDefinition $signature -Name MyType -Namespace MyNamespace
## https://github.com/proxb/PowerShell_Scripts/blob/master/Set-Window.ps1
Function Set-Window ([string]$processname,$x,$y){
Try{
[void][Window]
} Catch {
Add-Type @"
using System;
using System.Runtime.InteropServices;
public class Window {
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect);
[DllImport("User32.dll")]
public extern static bool MoveWindow(IntPtr handle, int x, int y, int width, int height, bool redraw);
}
public struct RECT
{
public int Left; // x position of upper-left corner
public int Top; // y position of upper-left corner
public int Right; // x position of lower-right corner
public int Bottom; // y position of lower-right corner
}
"@
}
$Rectangle = New-Object RECT
$Handle = (Get-Process -Name $processname).MainWindowHandle
$Return = [Window]::GetWindowRect($Handle,[ref]$Rectangle)
$Width = $Rectangle.Right - $Rectangle.Left
$Height = $Rectangle.Bottom - $Rectangle.Top
[Window]::MoveWindow($Handle, $x, $y, $Width, $Height,$True)
}
#endregion functions
#region tc settings
$paracheck1=$PSBoundParameters.ContainsKey('para1')
$paracheck2=$PSBoundParameters.ContainsKey('para2')
$paracheck3=$PSBoundParameters.ContainsKey('para3')
$paracheck4=$PSBoundParameters.ContainsKey('para4')
if($paracheck3 -eq $false -or $para3.Length -eq 0){
$para3=""
}
if($paracheck4 -eq $false -or $para4.Length -eq 0){
$para4=""
}
$bitype=$para1
$bitconfig=$para2
$noexit_flag=$para3
$option2=$para4
if($PSScriptRoot.length -eq 0){
$scriptRoot="C:\testing_AI\modules"
}
else{
$scriptRoot=$PSScriptRoot
}
$actionss="screenshot"
Get-Module -name $actionss|remove-module
$mdpath=(Get-ChildItem -path $scriptRoot -r -file |Where-object{$_.name -match "^$actionss\b" -and $_.name -match "psm1"}).fullname
Import-Module $mdpath -WarningAction SilentlyContinue -Global
$actioncmd="cmdline"
Get-Module -name $actioncmd|remove-module
$mdpath=(Get-ChildItem -path $scriptRoot -r -file |Where-object{$_.name -match "^$actioncmd\b" -and $_.name -match "psm1"}).fullname
Import-Module $mdpath -WarningAction SilentlyContinue -Global
$tcpath=(Split-Path -Parent $scriptRoot)+"\currentjob\TC.txt"
$tcnumber=((get-content $tcpath).split(","))[0]
$tcstep=((get-content $tcpath).split(","))[1]
$timenow=get-date -format "yyMMdd_HHmmss"
#$picpath=(Split-Path -Parent $scriptRoot)+"\logs\screenshot\"
$picpath=(Split-Path -Parent $scriptRoot)+"\logs\$($tcnumber)\"
if(-not(test-path $picpath)){new-item -ItemType directory -path $picpath |out-null}
$screen = [System.Windows.Forms.Screen]::PrimaryScreen
$bounds = $screen.Bounds
$width = $bounds.Width
$height =$bounds.Height
#$width = ([string]::Join("`n", (wmic path Win32_VideoController get CurrentHorizontalResolution))).split("`n") -match "\d{1,}" |select -first 1
#$height = ([string]::Join("`n", (wmic path Win32_VideoController get CurrentVerticalResolution))).split("`n") -match "\d{1,}" |select -first 1
#endregion
if($bitype -match "passmark"){
$action="passmark burnin"
$bifolder= "C:\Program Files\BurnInTest\bit.exe"
$bipath=(Get-ChildItem "$scriptRoot\BITools\$bitype\" -r -file |Where-object{$_.name -match "bit" -and $_.name -match "exe"}).FullName
$keypath=(Get-ChildItem "$scriptRoot\BITools\$bitype\" -r -file |Where-object{$_.name -match "key"}).FullName
$cfgpath=(Get-ChildItem "$scriptRoot\BITools\config\" -r -file |Where-object{$_.name -match $bitconfig}).FullName
#check $bitconfig volumn # exist ##
if($bitconfig -match "volume"){
$text1=($bitconfig -split "volume")[1]
$diskid=$text1.Substring(0,1)
$currentdisks= ((Get-WmiObject -Class Win32_LogicalDisk |Where-Object{$_.providername -notlike "\\*"}).name).replace(":","")
$currentdiskstring=$currentdisks|Out-String
write-host "current all disks:$currentdiskstring"
if(!($diskid -in $currentdisks)){
write-host "Drive $diskid doesnot exist, quit running, go to next step"
$resultNG="NG"
$index="no disk $diskid exist in $currentdiskstring"
$noexit_flag="noexit"
}
}
if(!$resultNG){
if((test-path $bifolder) -eq $false){
new-item -ItemType directory -path "C:\Program Files\BurnInTest\" -Force | Out-Null
copy-item "$keypath" -destination "C:\Program Files\BurnInTest\" -Force | Out-Null
&$bipath /VERYSILENT
do{
$bitp=Get-Process -Name "bit" -ErrorAction SilentlyContinue
$bcount=($bitp.id).Count
Start-Sleep -s 1
} until ($bcount -eq 1)
}
$des= "c:\dash\tools\storage\burnintest\"
if(-not(test-path $des)){new-item -ItemType directory -Path $des |Out-Null}
copy-item C:\testing_AI\modules\BITools\passmark\Bear.wmv $des -force
start-sleep -s 10
taskkill -pid (get-process |Where-object{$_ -match "bit"}).Id /F
start-sleep -s 5
##### pcaui delete for windows 11 new pcaui mesasge tab once (old versoin tab twice) ###
$checkpcaui= ((get-process pcaui -ErrorAction SilentlyContinue).id).count
$checkpcauiids= ((get-process pcaui -ErrorAction SilentlyContinue).id)
if($checkpcaui -gt 0){
foreach($checkpcauiid in $checkpcauiids){
[Microsoft.VisualBasic.Interaction]::AppActivate($checkpcauiid)
Start-Sleep -s 2
[System.Windows.Forms.SendKeys]::SendWait("{tab}")
Start-Sleep -s 1
[System.Windows.Forms.SendKeys]::SendWait(" ")
Start-Sleep -s 1
[System.Windows.Forms.SendKeys]::SendWait("{tab 2}")
Start-Sleep -s 1
[System.Windows.Forms.SendKeys]::SendWait(" ")
Start-Sleep -s 1
}
}
(get-process pcaui -ea SilentlyContinue)|Stop-Process -Force -ErrorAction SilentlyContinue
start-sleep -s 3
&$bifolder /C $cfgpath /R
start-sleep -s 10
##### pcaui delete for windows 11 new pcaui mesasge tab once (old versoin tab twice) ###
$checkpcaui= ((get-process pcaui -ErrorAction SilentlyContinue).id).count
$checkpcauiids= ((get-process pcaui -ErrorAction SilentlyContinue).id)
if($checkpcaui -gt 0){
foreach($checkpcauiid in $checkpcauiids){
[Microsoft.VisualBasic.Interaction]::AppActivate($checkpcauiid)
Start-Sleep -s 2
[System.Windows.Forms.SendKeys]::SendWait("{tab}")
Start-Sleep -s 1
[System.Windows.Forms.SendKeys]::SendWait(" ")
Start-Sleep -s 1
[System.Windows.Forms.SendKeys]::SendWait("{tab 2}")
Start-Sleep -s 1
[System.Windows.Forms.SendKeys]::SendWait(" ")
Start-Sleep -s 1
}
}
(get-process pcaui -ea SilentlyContinue)|Stop-Process -Force -ErrorAction SilentlyContinue
Start-Sleep -s 20
##### screen shot ###
$title=(get-process bit).MainWindowTitle
if ( $title -match "evaluation"){
[Microsoft.VisualBasic.Interaction]::AppActivate("Error")
Start-Sleep -s 1
[System.Windows.Forms.SendKeys]::SendWait("% ")
[System.Windows.Forms.SendKeys]::SendWait("{Down}")
[System.Windows.Forms.SendKeys]::SendWait("{Enter}")
start-sleep -s 2
}
$cmptid= (get-process *|Where-object{$_.MainWindowTitle -match "Program Compatibility Assistant"}).Id
if ($cmptid -ne $null){
[Microsoft.VisualBasic.Interaction]::AppActivate($cmptid)
Start-Sleep -s 1
[System.Windows.Forms.SendKeys]::SendWait("% ")
[System.Windows.Forms.SendKeys]::SendWait("{Down}")
[System.Windows.Forms.SendKeys]::SendWait("{Enter}")
start-sleep -s 2
}
$title=(get-process bit).MainWindowTitle
[Microsoft.VisualBasic.interaction]::AppActivate($title)|out-null
## scrrenshot##
&$actionss -para3 nonlog -para5 "$action-start"
## second picture ##
&$actionss -para3 nonlog -para5 "$action-start2"
}
}
if($bitype -match "furmark"){
$action="furmark burnin"
$duration=($bitype.split("-"))[1]
if($duration.length -eq 0){$duration=1}
$bitype= ($bitype.split("-"))[0]
$durationtime=[int64]$duration*60*1000
$bifolder= "C:\Program Files (x86)\Geeks3D\Benchmarks\FurMark\FurMark.exe"
$bipath=(Get-ChildItem "$scriptRoot\BITools\$bitype\" -r -file |Where-object{$_.name -match "FurMark" -and $_.name -match "exe"}).FullName
#$keypath=(Get-ChildItem "$scriptRoot\BITools\$bitype\" -r -file |Where-object{$_.name -match "key"}).FullName
#$cfgpath=(Get-ChildItem "$scriptRoot\BITools\config\" -r -file |Where-object{$_.name -match $bitconfig}).FullName
if((test-path $bifolder) -eq $false){
#new-item -ItemType directory -path "C:\Program Files\BurnInTest\" -Force | Out-Null
#copy-item "$keypath" -destination "C:\Program Files\BurnInTest\" -Force | Out-Null
&$bipath /VERYSILENT
do{
$checkinstall=test-path $bifolder
Start-Sleep -s 1
} until ($checkinstall -eq $true)
}
start-sleep -s 10
do{
### check if furmark running ##
get-process -name furmark -ErrorVariable b -ErrorAction SilentlyContinue
if(-not (($b.CategoryInfo).Reason -match "ProcessCommandException")){
taskkill -pid (get-process |Where-object{$_ -match "furmark"}).Id /F
start-sleep -s 2
}
# &$bifolder /width=$width /height=$height /fullscreen /max_time=$durationtime /run_mode=1 /log_score /disable_catalyst_warning
&$bifolder /width=$width /height=$height /max_time=$durationtime /run_mode=1 /log_score /disable_catalyst_warning
start-sleep -s 10
if($wshell.AppActivate('FurMark - Check for update') -eq $true ){
start-sleep -s 2
$wshell.SendKeys("%{F4}")
start-sleep -s 2
}
## settings screen shot
if($wshell.AppActivate('Geeks3D') -eq $true ){
## scrrenshot##
&$actionss -para3 nonlog -para5 "$action-settings"
$picfile1=(Get-ChildItem $picpath |Where-object{$_.name -match ".jpg" -and $_.name -match "$action-settings" }).FullName
## start running
$wshell.AppActivate('Geeks3D')
start-sleep -s 2
$wshell.SendKeys("+{tab 5}")
#[System.Windows.Forms.SendKeys]::SendWait("+{tab 5}")
start-sleep -s 5
$wshell.SendKeys("~")
start-sleep -s 2
if($wshell.AppActivate('*** Caution') -eq $true ){
start-sleep -s 1
$wshell.SendKeys("~")
start-sleep -s 2
}
}
start-sleep -s 10
$checkrun= (get-process -name furmark).MainWindowTitle -match "FPS"
} until ($checkrun -eq $true)
<##### screen shot by F9 ###
$pic1= (Get-ChildItem -path "C:\Program Files (x86)\Geeks3D\Benchmarks\FurMark\screenshots\*" -Recurse -file -Filter "*jpg*").fullname
start-sleep -s 2
$wshell.SendKeys("{F1}")
start-sleep -s 2
$wshell.SendKeys("G")
start-sleep -s 2
$wshell.SendKeys("{F9}")
start-sleep -s 5
$pic2= (Get-ChildItem -path "C:\Program Files (x86)\Geeks3D\Benchmarks\FurMark\screenshots\*" -Recurse -file -Filter "*jpg*").fullname
foreach($pic in $pic2){
if($pic -notin $pic1){
$picfile=$picpath+"$timenow-$tcnumber-$tcstep-$action-1.jpg"
Copy-Item $pic -Destination $picfile -Force
}
}
$wshell.SendKeys("{F1}")
start-sleep -s 2
$wshell.SendKeys("G")
start-sleep -s 2
$wshell.SendKeys("{F9}")
start-sleep -s 5
$pic3= (Get-ChildItem -path "C:\Program Files (x86)\Geeks3D\Benchmarks\FurMark\screenshots\*" -Recurse -file -Filter "*jpg*").fullname
foreach($pic in $pic3){
if($pic -notin $pic2){
$picfile=$picpath+"$timenow-$tcnumber-$tcstep-$action-2.jpg"
Copy-Item $pic -Destination $picfile -Force
}
}
##### screen shot by F9 ###>
start-sleep -s 10
[KeySends.KeySend]::KeyDown("LWin")
[KeySends.KeySend]::KeyDown("B")
[KeySends.KeySend]::KeyUp("LWin")
[KeySends.KeySend]::KeyUp("B")
Start-Sleep -s 1
[KeySends.KeySend]::KeyDown("LWin")
[KeySends.KeySend]::KeyUp("LWin")
Start-Sleep -s 1
[KeySends.KeySend]::KeyDown("LWin")
[KeySends.KeySend]::KeyUp("LWin")
Start-Sleep -s 2
##### screen shot by Windows ###
&$actionss -para3 nonlog -para5 "$action-start"
$picfile2=(Get-ChildItem $picpath |Where-object{$_.name -match ".jpg" -and $_.name -match "$action-start" }).FullName
$picfile=[string]::join("`n",$picfile1,$picfile2)
#$id=(get-process -name FurMark).id
#$wshell.AppActivate($id)
}
if($bitype -match "FluidMark"){
if($wshell.AppActivate('Geeks3D') -eq $true ){
(get-process -name FluidMark -ea SilentlyContinue).CloseMainWindow()
}
$action="FluidMark burnin"
$duration=($bitype.split("-"))[1]
if($duration.length -eq 0){$duration=1}
$bitype= ($bitype.split("-"))[0]
$counts=[int64]$duration
#$durationtime=[int64]$duration*60*1000
$bifolder= "C:\Program Files (x86)\Geeks3D\Benchmarks\FluidMark\"
$bitprg=".\FluidMark.exe"
$bipath=(Get-ChildItem "$scriptRoot\BITools\$bitype\" -r -file |Where-object{$_.name -match "FluidMark" -and $_.name -match "exe"}).FullName
$bipath2=(Get-ChildItem "$scriptRoot\BITools\$bitype\" -r -file -filter "*PhysX*System*").FullName
#$keypath=(Get-ChildItem "$scriptRoot\BITools\$bitype\" -r -file |Where-object{$_.name -match "key"}).FullName
#$cfgpath=(Get-ChildItem "$scriptRoot\BITools\config\" -r -file |Where-object{$_.name -match $bitconfig}).FullName
## install##
if((test-path "C:\Program Files (x86)\Geeks3D\Benchmarks\FluidMark\data") -eq $false){
#new-item -ItemType directory -path "C:\Program Files\BurnInTest\" -Force | Out-Null
#copy-item "$keypath" -destination "C:\Program Files\BurnInTest\" -Force | Out-Null
&$bipath2 -s
&$bipath /VERYSILENT
do{
$checkinstall=test-path "C:\Program Files (x86)\Geeks3D\Benchmarks\FluidMark\data"
Start-Sleep -s 1
} until ($checkinstall -eq $true)
Copy-Item "C:\testing_AI\modules\BITools\FluidMark\startup_options.xml" "C:\Program Files (x86)\Geeks3D\Benchmarks\FluidMark\" -Force
}
<## play for counts ##
$x=0
do{
$x++
set-location $bifolder
#&$bitprg /width=$width /height=$height /fullscreen
&".\start_preset_1080.bat"
start-sleep -s 10
if($wshell.AppActivate('Geeks3D') -eq $true ){
### window focus ###
Get-Module -name appfocus |remove-module
$mdpath=(Get-ChildItem -path $scriptRoot -r -file |Where-object{$_.name -match "^appfocus\b" -and $_.name -match "psm1"}).fullname
Import-Module $mdpath -WarningAction SilentlyContinue -Global
appfocus -para1 FluidMark
start-sleep -s 5
##### screen shot ###
$timenow=get-date -format "yyMMdd_HHmmss"
$picfile=$picpath+"$($timenow)-$($tcnumber)-$($tcstep)-$($action)"+"_cycle-$($x)_starting.jpg"
$bounds = [Drawing.Rectangle]::FromLTRB(0, 0, [int64] $width.trim() , [int64] $height.trim() )
$bmp = New-Object System.Drawing.Bitmap ([int]$bounds.width), ([int]$bounds.height)
$graphics = [Drawing.Graphics]::FromImage($bmp)
$graphics.CopyFromScreen($bounds.Location, [Drawing.Point]::Empty, $bounds.size)
start-sleep -s 5
$bmp.Save($picfile)
start-sleep -s 2
$graphics.Dispose()
$bmp.Dispose()
start-sleep -s 2
$wshell.SendKeys("{tab}")
start-sleep -s 2
$wshell.SendKeys("+{tab}")
start-sleep -s 2
$wshell.SendKeys("~")
start-sleep -s 2
}
start-sleep -s 5
##### screen shot when running ###
$n=0
do{
start-sleep -s 180
$checkrunning=$wshell.AppActivate('FluidMark')
if($checkrunning -eq $true ){
##### screen shot ###
$timenow=get-date -format "yyMMdd_HHmmss"
$picfile=$picpath+"$($timenow)-$($tcnumber)-$($tcstep)-$($action)"+"_cycle-"+"$($x)_$($n)"+".jpg"
$bounds = [Drawing.Rectangle]::FromLTRB(0, 0, [int64] $width.trim() , [int64] $height.trim() )
$bmp = New-Object System.Drawing.Bitmap ([int]$bounds.width), ([int]$bounds.height)
$graphics = [Drawing.Graphics]::FromImage($bmp)
$graphics.CopyFromScreen($bounds.Location, [Drawing.Point]::Empty, $bounds.size)
start-sleep -s 5
$bmp.Save($picfile)
start-sleep -s 2
$graphics.Dispose()
$bmp.Dispose()
$n++
}
}until($checkrunning -eq $false )
start-sleep -s 5
if($wshell.AppActivate('Geeks3D') -eq $true ){
(get-process -name FluidMark -ea SilentlyContinue).CloseMainWindow()
if($wshell.AppActivate('Geeks3D') -eq $true ){
stop-process -name FluidMark -ea SilentlyContinue
}
}
}until($x -ge $counts)
## play for counts ##>
}
if($bitype -match "prime95"){
$action="prime95 stress burnin"
$bipath=(Get-ChildItem "$scriptRoot\BITools\$bitype\" -r -file |Where-object{$_.name -match $bitype -and $_.name -match "exe"}).FullName
$checkrun=((get-process -Name prime95 -ErrorAction SilentlyContinue).Id).count
if( $checkrun -ne 0){
taskkill /IM prime95.exe /F
start-sleep -s 10
}
remove-item -Path $scriptRoot\BITools\$bitype\prime.txt -Force
remove-item -Path $scriptRoot\BITools\$bitype\local.txt -Force
&$bipath
start-sleep -s 10
$primid= (get-process -name prime95).Id
$Handle = Get-Process prime95| Where-Object { $_.MainWindowTitle -match $env:TITLE } | ForEach-Object { $_.MainWindowHandle }
if ( $Handle -is [System.Array] ) { $Handle = $Handle[0] }
$WindowRect = New-Object RECT
$GotWindowRect = [Window]::GetWindowRect($Handle, [ref]$WindowRect)
#Write-Host $WindowRect.Left $WindowRect.Top $WindowRect.Right $WindowRect.Bottom
##scale
$bdh=(([System.Windows.Forms.Screen]::AllScreens|Select-Object Bounds).Bounds).Bottom
$height = ([string]::Join("`n", (wmic path Win32_VideoController get CurrentVerticalResolution))).split("`n") -match "\d{1,}"
#$sacle=$height[0]/$bdh[0]
$sacle=1 ## for command use, no need to divided with scale ( don't know the reason yet)
$x1=[math]::Round(($WindowRect.Left + $WindowRect.Right)/2/$sacle,0)
$y1=[math]::Round(($WindowRect.Top + $WindowRect.Bottom)/2/$sacle,0)
if( $wshell.AppActivate($primid) ){
#[Clicker]::LeftClickAtPoint( [int64]$width[0].ToString()/2, [int64]$height[0].ToString()/2)
[Clicker]::LeftClickAtPoint($x1, $y1)
start-sleep -s 3
$wshell.SendKeys("s")
start-sleep -s 3
$wshell.SendKeys("{tab}")
start-sleep -s 2
$wshell.SendKeys("2")
start-sleep -s 2
$wshell.SendKeys("{tab}")
start-sleep -s 2
$wshell.SendKeys("{tab}")
start-sleep -s 2
##### screenshot for settings ###
&$actionss -para3 nonlog -para5 "$action-settings"
$picfile1=(Get-ChildItem $picpath |Where-object{$_.name -match ".jpg" -and $_.name -match "$action-settings" }).FullName
##### go ###
$wshell.AppActivate('Run a Torture Test')
$wshell.SendKeys("~")
##### screenshot for running ###
start-sleep -s 20
&$actionss -para3 nonlog -para5 "$action-start"
$picfile1=(Get-ChildItem $picpath |Where-object{$_.name -match ".jpg" -and $_.name -match "$action-start" }).FullName
$picfile=[string]::join("`n",$picfile1,$picfile2)
}
}
if($bitype -match "Unigine_Heaven"){
$action="Unigine Heaven burnin"
$appname="Heaven"
$noexit_flag="noexit"
#API(opengl/dx11/dx9)|Quality(Low/Medium/High/Ultra)|Resolution(System/[WidthxLength])
$bitconfig_api=($bitconfig.split("|"))[0]
$bitconfig_quality=($bitconfig.split("|"))[1]
$bitconfig_res=($bitconfig.split("|"))[2]
$bitconfig_window=($bitconfig.split("|"))[3]
if($bitconfig_res -match "x"){
$bitconfig_resx=($bitconfig_res.split("x"))[0]
$bitconfig_resy=($bitconfig_res.split("x"))[1]
}
$logfilename="Unigine_Heaven_Benchmark_4.0_"+$bitconfig.replace("|","_")+".html"
$logfilename2="step$($tcstep)_"+$bitconfig.replace("|","_")+"_log.html"
$bipath=(Get-ChildItem "$scriptRoot\BITools\$bitype\" -r -file |Where-object{$_.name -match $bitype -and $_.name -match "exe"}).FullName
$checkprocessing1=((get-process -name Valley -ea SilentlyContinue).Id).count
if( $checkprocessing1 -gt 0){
taskkill /IM "$appname.exe" /F
start-sleep -s 20
}
$checkprocessing2=((get-process -name browser_x86 -ea SilentlyContinue).Id).count
if( $checkprocessing2 -gt 0){
taskkill /IM browser_x86.exe /F
start-sleep -s 5
}
### uninstall ###
$uninstallexe="C:\Program Files (x86)\Unigine\Heaven Benchmark 4.0\unins000.exe"
if(test-path $uninstallexe){
&$uninstallexe /silent
do{
Start-Sleep -s 5
$checkins=get-process -name unins000 -ErrorAction SilentlyContinue
}until(!$checkins)
start-sleep -s 10
}
### install ###
write-host "start install $(get-date)"
&$bipath /VERYSILENT
#set-location "C:\Program Files (x86)\Unigine\Valley Benchmark 1.0\
do{
Start-Sleep -s 10
$checkins=get-process -name Unigine_Heaven-4.0 -ErrorAction SilentlyContinue
}until(!$checkins)
write-host "install cmplt $(get-date)"
start-sleep -s 30
## brower js move ###
$backuppath="C:\testing_AI\modules\BITools\Unigine_Heaven\backup\"
$brwjsfrom="C:\testing_AI\modules\BITools\Unigine_Heaven"
$brwjsfolder="C:\Program Files (x86)\Unigine\Heaven Benchmark 4.0\data\launcher\js"
$jsstartfile="C:\Program Files (x86)\Unigine\Heaven Benchmark 4.0\data\launcher\js\heaven-ui-logic.js"
if(! (test-path $backuppath)){
new-item -ItemType Directory $backuppath |Out-Null
}
copy-item $jsstartfile -destination $backuppath -Force
Get-ChildItem -path $brwjsfolder -Filter "browser.js" |Copy-Item -Destination $backuppath -Force
Get-ChildItem -path $brwjsfrom -Filter "browser.js" |Copy-Item -Destination $brwjsfolder -Force
## remove cashe##
$cashe="$env:USERPROFILE\AppData\Local\file__0.localstorage"
$cashe2="$env:HOMEPATH\Heaven\log.html"
$cashe3="$env:USERPROFILE\documents\Unigine_Heaven_Benchmark_4.0*.html"
$cashe4="$env:USERPROFILE\Unigine_Heaven_Benchmark_4.0*.html"
if(test-path $cashe){remove-item -path $cashe -Force}
if(test-path $cashe2){remove-item -path $cashe2 -Force}
if(test-path $cashe3){remove-item -path $cashe3 -Force}
if(test-path $cashe4){remove-item -path $cashe4 -Force}
## revise autostart js ###
$uicontent= get-content $jsstartfile
$cmdadd='setTimeout(function() {EngineLauncher.launch(OptionsBuilder.getCommandLine());}, 90000);'
$lineafter="OptionsBuilder.build"
$newcontent= foreach($uiline in $uicontent){
$uiline
if($uiline -match $lineafter){
$cmdadd
}
}
$newcontent|set-content $jsstartfile -Force
if($bitconfig_window -match "window"){
(get-content $brwjsfolder\browser.js).replace("""video_fullscreen"",""default"":true","""video_fullscreen"",""default"":false") `
|set-content $brwjsfolder\browser.js
}
## start UI ##
$runbatfile="C:\Program Files (x86)\Unigine\Heaven Benchmark 4.0\heaven.bat"
#$runpath="C:\Program Files (x86)\Unigine\Heaven Benchmark 4.0\"
$opentime=get-date
&$runbatfile
do{
Start-Sleep -s 1
$unigineid=(get-process -name * |Where-Object{$_.MainWindowTitle -match "Unigine Heaven Benchmark"}).Id
$timepassed=(New-TimeSpan -start $opentime -end (get-date)).TotalSeconds
}until ($unigineid -or $timepassed -gt 60)
if($timepassed -gt 60){
$results="NG"
$index="fail to open Unigin Heave"
}
else{
$Handle = (get-process -name * |Where-Object{$_.MainWindowTitle -match "Unigine Heaven Benchmark"}).MainWindowHandle
if ( $Handle -is [System.Array] ) { $Handle = $Handle[0] }
$WindowRect = New-Object RECT
$GotWindowRect = [Window]::GetWindowRect($Handle, [ref]$WindowRect)
##scale
$bdh=(([System.Windows.Forms.Screen]::AllScreens|Select-Object Bounds).Bounds).Bottom
$height = ([string]::Join("`n", (wmic path Win32_VideoController get CurrentVerticalResolution))).split("`n") -match "\d{1,}"
#$sacle=$height[0]/$bdh[0]
$sacle=1 ## for command use, no need to divided with scale ( don't know the reason yet)
$x1=[math]::Round(($WindowRect.Left + $WindowRect.Right)/2/$sacle,0)
$y1=[math]::Round(($WindowRect.Top + $WindowRect.Bottom)/2/$sacle,0)
[Microsoft.VisualBasic.interaction]::AppActivate($unigineid)|out-null
start-sleep -s 2
[Clicker]::LeftClickAtPoint($x1, $y1)
start-sleep -s 2
&$actionss -para3 nonlog -para5 "open"
##api settings
[System.Windows.Forms.SendKeys]::SendWait("{tab 3}")
Start-Sleep -s 1
[System.Windows.Forms.SendKeys]::SendWait(" ")
&$actionss -para3 nonlog -para5 "API_check"
if($bitconfig_api -match "9"){
[System.Windows.Forms.SendKeys]::SendWait("{down}")
}
if($bitconfig_api -match "opengl"){
[System.Windows.Forms.SendKeys]::SendWait("{down 2}")
}
Start-Sleep -s 1
[System.Windows.Forms.SendKeys]::SendWait("~")
##quality settings
[System.Windows.Forms.SendKeys]::SendWait("{tab}")
Start-Sleep -s 1
[System.Windows.Forms.SendKeys]::SendWait(" ")
&$actionss -para3 nonlog -para5 "Quality_check"
[System.Windows.Forms.SendKeys]::SendWait("{UP 5}")
Start-Sleep -s 1
if($bitconfig_quality -match "medium"){
[System.Windows.Forms.SendKeys]::SendWait("{Down}")