#202548 - 2011-07-01 07:17 PM
HELP with Something very basic ... HELP ... HELP
|
stlaurentm
Fresh Scripter
Registered: 2011-02-07
Posts: 16
Loc: NY
|
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
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.
|
|
Top
|
|
|
|
#202549 - 2011-07-01 08:39 PM
Re: HELP with Something very basic ... HELP ... HELP
[Re: stlaurentm]
|
ShaneEP
MM club member
   
Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
|
Something like this?
Break Off
$System= CreateObject("Kixtart.System")
If Not $System
$nul= MessageBox("KiXforms Classic Not Installed This Script Will Now Close.","Error",16)
Quit()
EndIf
$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)
$Form1.Text = "MSL"
$button1 = $form1.Controls.ToolButton()
$button1.Text = "Yes"
$button1.OnClick = "ExitingToDeskTop()"
$button1.Location = $System.Point(100, 200)
$button2 = $form1.Controls.ToolButton()
$button2.Text = "No"
$button2.OnClick = "ExitingApp()"
$button2.Location = $System.Point(400, 200)
;$Label1 = $form1.Label()
$Label1 = $form1.Controls.Add("Label")
$Label1.BorderStyle = 0 ;FixedSingle
$Label1.Font = $System.Font("Microsoft Sans Serif",14.25,1) ;Bold
$Label1.Left = 10
$Label1.Text = "Test text 1"
;$Label1.Text = LoadIniPolicy()
$Label1.Top = 10
$Label1.Width = 600
$Label1.Height = 150
;$Label2 = $form1.Label()
$Label2 = $form1.Controls.Add("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 = "Test text 2"
;$Label2.Text = $strmsg2
$Label2.Top = 150
$Label2.Width = 600
$Label2.Height = 50
$button1.default = true
$button2.cancel = true
$Form1.Show()
$Form1.SetFocus()
$Form1.OnDeactivate = "ExitingApp()"
While $Form1.Visible
$Nul = Execute($Form1.DoEvents)
Loop
Exit 0
;*************************************** QUIT APPLICATION AND SHUT DOWN PC **********************************
Function ExitingApp()
$= $System.MessageBox.Show("shutting you down")
$Form1.Hide()
Endfunction
;*************************************************************************************************************************
;*************************************** QUIT APPLICATION GIVE USER ACCESS **********************************
Function ExitingToDeskTop()
$= $System.MessageBox.Show("Continue to Desktop ...")
$Form1.Hide()
Endfunction
;*************************************************************************************************************************
|
|
Top
|
|
|
|
#202550 - 2011-07-01 09:01 PM
Re: HELP with Something very basic ... HELP ... HELP
[Re: ShaneEP]
|
stlaurentm
Fresh Scripter
Registered: 2011-02-07
Posts: 16
Loc: NY
|
Thank you that is what I wanted to do..
Can you tell me where I can find a list of all the commads available in Kix
Thanks again
|
|
Top
|
|
|
|
#202598 - 2011-07-07 07:34 PM
Re: HELP with Something very basic ... HELP ... HELP
[Re: Lonkero]
|
stlaurentm
Fresh Scripter
Registered: 2011-02-07
Posts: 16
Loc: NY
|
Thanks all much appreciated the great help
After putting the script together, now during my testing phase I am face with a diffrent situation. Deadline is approaching and I need to get this to work the way it suppose to.
I have installed the script on a "Domain" server under the "NetLogon" folder. I have done all the steps from 2 to 2.1.4 provided in this article
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=81572&site_id=1#import
I have tied them separately and all at once and it is not working. I am getting the usual error "Kixtart not loaded ... this form will now close" error.
the only thing I was not sure of is in the ".INI" below is the "My Domain" a variable name or do I need to replace it with my actual Domain name
[KIXRPCMapping] MyDomain = \\Server1 ,\\Server2 AnotherDomain = \\ServerOtherDomain Default = \\ServerThatValidatesAnyone
********************************************** like this
[KIXRPCMapping] Adatum.com = \\Van-DC1,\\Van-DC1.Adatum.com Default = \\Van-DC1.Adatum.com
***************************
I am hopping that I can get this to work from the server, becasue I would hate to have to go around 250 workstation and install these dlls
********************************************** The environment is as follow
Server/Domain windows 2008R2 Script insalled in the "NetLogon" folder and called from the 1st line of the login script
Client: Windows 7
Please help ...
thank you again
Edited by stlaurentm (2011-07-07 07:36 PM)
|
|
Top
|
|
|
|
#202600 - 2011-07-07 08:26 PM
Re: HELP with Something very basic ... HELP ... HELP
[Re: Glenn Barnas]
|
stlaurentm
Fresh Scripter
Registered: 2011-02-07
Posts: 16
Loc: NY
|
Thanks for the quick response.. but I had started with the messagebox and I did not like the formating of the text when it is being pull from a DB. Sometimes the text is so long that you will need to scroll that is why I decided to use the form
I guess I have no choice
thanks again
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 764 anonymous users online.
|
|
|