[ ] 
[ ] // This file was downloaded from    http://www.autotestgroup.com
[ ] // All materials from this site cannot be used without agreement
[ ] // with www.autotestgroup.com
[ ] // If you are interested in commercial usage, please contact us
[ ] // 		info@autotestgroup.com
[ ] 
[ ] use "msw32.inc"
[+] window MainWin wCalc
	[ ] tag "Calculator|Калькулятор"
[ ] 
[+] dll "shell32.dll"
	[ ] HINSTANCE ShellExecute (in HWND hwnd,in STRING lpOperation,in STRING lpFile,in STRING lpParameters,in STRING lpDirectory, in INT nShowCmd) alias "ShellExecuteA"
[ ] 
[+] testcase Test_PC_Restart() appstate none
	[ ] // this testcase covers following functionallity:
	[ ] // * runs first part
	[ ] // * modifies file SilkTest.bat in general startup folder
	[ ] //	 ("C:\Documents and Settings\All Users\Start Menu\Programs\Startup")
	[ ] //   to run SilkTest again after restart
	[ ] // * restarts PC
	[ ] // * starts SilkTest again after restart and continue script running
	[ ] //
	[ ] 
	[ ] // *** Step 1: 
	[ ] // note: this step should be run each time (before and after restarting)
	[ ] 
	[ ] Print("Starting Calculator")
	[+] if(!wCalc.Exists (0))
		[ ] wCalc.Start ("calc.exe")
	[+] else
		[ ] Print ("Calculator is already running")
	[ ] wCalc.SetActive()
	[ ] 
	[ ] // *** Step 2:
	[+] if(ListCount(GetArgs()) == 0)
		[ ] Print("Evaluating expression 2+3=")
		[ ] wCalc.PushButton("2").Click()
		[ ] wCalc.PushButton("+").Click()
		[ ] wCalc.PushButton("3").Click()
		[ ] wCalc.PushButton("=").Click()
		[ ] Print("Result: {wCalc.TextField("#1").sValue}")
		[ ] 
		[ ] // Step 3:
		[ ] Print ("Modifying SilkTest.bat")
		[ ] //HFILE hF = FileOpen("C:\Documents and Settings\All Users\Start Menu\Programs\Startup\SilkTest.bat", FM_WRITE)
		[ ] HFILE hF = FileOpen("C:\Documents and Settings\All Users\Главное меню\Программы\Автозагрузка\SilkTest.bat", FM_WRITE)
		[ ] //""
		[ ] FileWriteLine (hF, """{SYS_GetEnv("SEGUE_HOME")}\partner.exe"" -r ""{GetProgramDir()}\{GetProgramName ()}"" AfterRestart")
		[ ] FileClose(hF)
		[ ] 
		[ ] ShellExecute (0, "", "shutdown.exe", "-r -t 00", "", 1)
	[+] else if(GetArgs()[1] == "AfterRestart") // this section will run only after restarting PC
		[ ] Print ("PC has been restarted")
		[ ] Print ("Evaluating expression 72-9=")
		[ ] wCalc.PushButton("7").Click()
		[ ] wCalc.PushButton("2").Click()
		[ ] wCalc.PushButton("-").Click()
		[ ] wCalc.PushButton("9").Click()
		[ ] wCalc.PushButton("=").Click()
		[ ] Print("Result: {wCalc.TextField("#1").sValue}")
[ ] 

