Page 1 of 1 1
Topic Options
#202548 - 2011-07-01 07:17 PM HELP with Something very basic ... HELP ... HELP
stlaurentm Offline
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


 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.

Top
#202549 - 2011-07-01 08:39 PM Re: HELP with Something very basic ... HELP ... HELP [Re: stlaurentm]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Something like this?

 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

$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 Offline
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
#202551 - 2011-07-01 09:34 PM Re: HELP with Something very basic ... HELP ... HELP [Re: stlaurentm]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Here is a link to the help file for kixforms classic...

http://www.kixforms.org/assets/files/kixforms/KiXforms_246.chm

And here is a link to the most recent help file for kixtart...

http://www.kixtart.org/binary/docs/KiXhelp453.zip

And location of other help docs...

http://www.kixtart.org/?p=manual

Top
#202553 - 2011-07-02 12:41 AM Re: HELP with Something very basic ... HELP ... HELP [Re: ShaneEP]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
you could also consider making the box always on top and behind it fullscreen black image or something.
thus rendering the pc unusable unless clickity is correct.
_________________________
!

download KiXnet

Top
#202598 - 2011-07-07 07:34 PM Re: HELP with Something very basic ... HELP ... HELP [Re: Lonkero]
stlaurentm Offline
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
#202599 - 2011-07-07 08:12 PM Re: HELP with Something very basic ... HELP ... HELP [Re: stlaurentm]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
Unless you are still working with Windows 98, those steps are unnecessary.

Simply place the Kix32.exe executable in the netlogon share (\\mydomain\netlogon), along with the script you want to run. The RPC utility is only needed/supported for Windows NT and Win-9x clients.

If you are using KixForms, the Kixforms.dll file must be installed and registered on every client. This is probably the key reason I (personally) avoid using KixForms for login scripts. Look at the MessageBox() function as a possible alternative for a GUI message box to display and respond to Yes/No or OK/Cancel type dialogs.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#202600 - 2011-07-07 08:26 PM Re: HELP with Something very basic ... HELP ... HELP [Re: Glenn Barnas]
stlaurentm Offline
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
#202606 - 2011-07-08 11:33 AM Re: HELP with Something very basic ... HELP ... HELP [Re: stlaurentm]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 687
Loc: Maryland, USA
If you need even older school, you could use the whole display and "at" commands to specify the location and color of you message. Maybe pause for a few seconds and then display a messagebox that asks for a yes/no response. Just gives a lot more "real estate" to work with if your message is to long for a messagebox.
Top
#202611 - 2011-07-08 04:24 PM Re: HELP with Something very basic ... HELP ... HELP [Re: stlaurentm]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
The messagebox should resize dynamically, unless you feed it one long string. Try using a function or process to chop the text into shorter pieces. For example -

use InStr() to locate a space after position 60
Replace that position with a @CRLF using Join(Split()) or the Replace function from newer Kix versions.
Find the next possible space position to replace - 60+ char later and repeat until you exceed the string data length.

This will keep the message more "blocked" with line lenghts of 60-70 characters.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 764 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.184 seconds in which 0.152 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org