Below is my code, all I want to be able to do is to shutdown the PC if the kixform loaded looses focus. Meaning, if the user decides to click on the desktop and ignore the messages being displayed.. the PC will shutdown just like if they would click on the "No" button. This is for a Policy...


Please help.. I have tried a lot of the example I have seen in the forum but nothing seems to work


 Code:
Break Off

$System= CreateObject("Kixtart.System")
If Not $System
   $nul= MessageBox("KiXforms Classic Not Installed This Script Will Now Close.","Error",16)
   Quit()
EndIf


:iniMessage	
	$form1 = $System.Form();
	$Form1.FormBorderStyle = 1 
	$Form1.MaximizeBox = 0  ;False
	$Form1.MinimizeBox = 0  ;False
	$Form1.ControlBox = -1  ;True
	$Form1.StartPosition = 1  ;FormStartPosition_CenterScreen
	$Form1.Size = $System.Size(625,260) ;(Width,Height)		
	
	$button1 = $form1.Controls.Button ()
	$button2 = $form1.Controls.Button ()
	$button1.Text = "Yes";
	$button1.Location = $System.Point (100, 200)
	$button2.Text = "No";
	$button2.Location = $System.Point (400, 200)
	
	
	$button1.DialogResult = $System.DialogResult.Yes
	$button2.DialogResult = $System.DialogResult.No
	
	$form1.Text = "MSL"


	$Label1 = $form1.Label()
	$Label1.BorderStyle = 0  ;FixedSingle
	$Label1.Font = $System.Font("Microsoft Sans Serif",14.25,1) ;Bold
	$Label1.Left = 10
	$Label1.Text = LoadIniPolicy()
	$Label1.Top = 10
	$Label1.Width = 600
	$Label1.Height = 150
	$nul = $form1.Controls.Add($Label1)

	$Label2 = $form1.Label()
	$Label2.BorderStyle = 0  ;FixedSingle
	$Label2.Font = $System.Font("Microsoft Sans Serif",14.25,1) ;Bold
	$Label2.ForeColor = $System.Color.FromName("Red")
	$Label2.Left = 10
	$Label2.Text = $strmsg2
	$Label2.Top = 150
	$Label2.Width = 600
	$Label2.Height = 50

	$nul = $form1.Controls.Add($Label2)

	$button1.default = true
	$button2.cancel = true
	$form1.OnLostFocus="ExitingApp()"
	
	$= $form1.ShowDialog()
$ReturnCode = SetFocus("MSL")


			If ($form1.DialogResult = $System.DialogResult.Yes)
			 ;$= $System.MessageBox.Show("AUP Agreed")
				ExitingToDeskTop
			Else
				ExitingApp
			EndIf		




Exit 0


;***************************************                QUIT       APPLICATION  AND SHUT DOWN PC        **********************************

Function ExitingApp


;$= $System.MessageBox.Show("Bye ...")

$= $System.MessageBox.Show("shutting you down")
		


endfunction
;*************************************************************************************************************************
;***************************************                QUIT       APPLICATION    GIVE USER ACCESS      **********************************

Function ExitingToDeskTop

$= $System.MessageBox.Show("Continue to Desktop ...")
quit()

endfunction


Edited by Mart (2011-07-03 07:54 PM)
Edit Reason: Please use code tags when posting code.