Kixtart_Newbie
(Fresh Scripter)
2003-06-18 04:27 PM
Request

I am new to creating scripts using Kixtart. Can anyone help me along with a simple example for display an alert box (OK/Cancel) to a user logging in?

Les
(KiX Master)
2003-06-18 04:34 PM
Re: Request

code:
Break on
$msg='You have two choices.'
$rc=MessageBox($msg,'Pick one',1)



Howard Bullock
(KiX Supporter)
2003-06-18 04:36 PM
Re: Request

Here just an OK button:

$message = "An error occurred while running the logon script. " +
"Forward the text of the 'logon.log' to your support team."
$x =MessageBox($message,"Script Error",4160, 30)


Here is the OK/Cancel:


$message = "An error occurred while running the logon script. " +
"Forward the text of the 'logon.log' to your support team."
$x =MessageBox($message,"Script Error",4161, 30)


JochenAdministrator
(KiX Supporter)
2003-06-18 04:41 PM
Re: Request

Welcome !

Sure thing :


break on

$rc = messagebox("Message here","Title",4096+48+1) ; or even 5045:4096=System Modal 48=! 1=OK/Cancel

select
case $rc = 1
"User clicked OK" ?
case $rc = 2
"User clicked Cancel" ?
case 42 ; or "default" or even 1 if you prefer
"User did something unexpected" ?
endselect

get $_ ;pause script


There are also a few undocumented super modal etc. states (IIRC the super modal was 2^16 = 65536)

[ 18. June 2003, 16:42: Message edited by: Jochen ]


JochenAdministrator
(KiX Supporter)
2003-06-18 04:43 PM
Re: Request

Errg ... beaten by 7 minutes [Embarrassed]

[ 18. June 2003, 16:45: Message edited by: Jochen ]


Les
(KiX Master)
2003-06-18 04:46 PM
Re: Request

ARG!!! getting one-upped by the masters... [Mad]

Sealeopard
(KiX Master)
2003-06-18 04:53 PM
Re: Request

I have to wonder, though, why the example in the KiXtart Manual is not sufficient for this. [Confused]

Les
(KiX Master)
2003-06-18 06:12 PM
Re: Request

Easier to post?

quote:
When all else fails, read the manual


Kixtart_Newbie
(Fresh Scripter)
2003-06-18 07:18 PM
Re: Request

Wow! You are all good! I have never received such a response on any forum ever before.

After learning a few different languages from documentation, books, etc., I have learned to only trust those who use the language everyday. I rarely take examples from a book or documentation without first consulting a forum such as this. Although, comparing the KiXtart manual with your responses, I find KiXtart's reference to be better than most. [Smile]

I have one more question though. I have not been able to find the answer in several searches so far. How would I include a line break and a hyperlink within a message box?


Chris S.
(MM club member)
2003-06-18 07:37 PM
Re: Request

You can include a line break by adding the macro @CRLF to your message. Such as...

$msg = "Your machine is broken."+@CRLF+@CRLF+"It will now shutdown."

The hyperlink you can't do in a messagebox. You could create a custom KiXforms form to accomplish this, however.


Les
(KiX Master)
2003-06-18 07:40 PM
Re: Request

You could also build an HTML page and use COM to launch it. That way you would not have to register the kixforms DLL.

Kixtart_Newbie
(Fresh Scripter)
2003-06-18 07:47 PM
Re: Request

You know, all these Windows programming languages have so much in common. It is just always a bumpy ride for me to learn the other ones though. [Frown]

Why would this throw an error when a user clicks "NO"?
code:
$message = "This is the message body question?"

$title = "This is the title text"

$Selection = MessageBox($message,$title,4096+4+48+256,300)

If $Selection = 7
Run @LDRIVE + "Logoff.exe /n"
EndIf

If $Selection = -1
Run @LDRIVE + "Logoff.exe /n"
EndIf

I get the following error message if the "No" button is clicked:

ERROR : unknown command [END]!
Script: (script path)
Line : 24


Kixtart_Newbie
(Fresh Scripter)
2003-06-18 07:57 PM
Re: Request

Sorry, the line the error is referencing is the final ENDIF.

Sealeopard
(KiX Master)
2003-06-18 07:58 PM
Re: Request

Because there's an error in line 24 of your script. You did not post the complete script. KiXtart has a build-in LOGOFF function, use it! In case of a simple YEs/NO you only need to test for one condition, thus an IF-ELSE-ENDIF is sufficient. Why do you log them off in either case, anyway?

Kixtart_Newbie
(Fresh Scripter)
2003-06-18 08:34 PM
Re: Request

It is one of those corporate "emergencies" and the higher powers that be are "requesting" that there be a pop-up only allowing users to log in to the network if they agree to the e-mail and internet policy. I am sure you know what I mean.

Thanks for the posts!


Kixtart_Newbie
(Fresh Scripter)
2003-06-18 08:52 PM
Re: Request

All that logoff function did was close a couple windows and disable the active desktop.
code:
logoff(1)



Kixtart_Newbie
(Fresh Scripter)
2003-06-18 09:12 PM
Re: Request

Here is all the script as it is now. What do I need to do to get it to work right? I know this is probably annoying some of you. I am sorry...
code:
$message = "Internet and e-mail policy text" + @CRLF + @CRLF +
"Do you accept the Internet and E-Mail Policy?"

$title = "Window Title"

$Selection = MessageBox($message,$title,4096+4+48+256,300)

If $Selection = 7
Logoff(1)
EndIf

If $Selection = -1
Logoff(1)
EndIf

Also, on Win9x, the Network Sign-On disappears if you click "NO". In order to try logging on again, you are forced to reboot.


Sealeopard
(KiX Master)
2003-06-18 09:24 PM
Re: Request

code:
$message = "Internet and e-mail policy text" + @CRLF + @CRLF +
"Do you accept the Internet and E-Mail Policy?"
$title = "Window Title"
$Selection = MessageBox($message,$title,4096+4+48+256,300)
If $Selection = 7
; log user off
RC = LogOff(1)
endif



[ 18. June 2003, 22:06: Message edited by: sealeopard ]


Kixtart_Newbie
(Fresh Scripter)
2003-06-18 10:05 PM
Re: Request

Argh... Does the Logoff() function just not work in Win9x?

The script still does the same thing. If you click "No", the login script windows simply close. The login dialog box doesn't reappear, and no other errors occur. In order to login after that, you need to reboot the system. We have the necessary DLL's and EXE's mapped in the login script, but I also have them loaded into the Win9x machine as well now but it didn't make any difference.

Does anyone know of any work-arounds or fixes?


Sealeopard
(KiX Master)
2003-06-18 10:08 PM
Re: Request

It might be a problem with the calling batch file not being closed properly. Always have a EXIT 0 at the end of a batch file in Windows 9x.

Kixtart_Newbie
(Fresh Scripter)
2003-06-20 08:22 PM
Re: Request

Thank you all for all of you wonderful input. This is great. We have concluded that this particular method is not Win98 compliant. Win2k+ works just fine with this script. I appreciate the time and effort from you all. [Smile]

Chris S.
(MM club member)
2003-06-20 09:24 PM
Re: Request

Hmmm. Have you tried the RunDll32 method yet?

code:
If @INWIN=2
Run 'RunDLL32.EXE SHELL32.DLL,SHExitWindowsEx 0'
Quit 1
EndIf



Sealeopard
(KiX Master)
2003-06-20 09:37 PM
Re: Request

See also this classic: www.robvanderwoude.com/rundll.html

Les
(KiX Master)
2003-06-20 09:39 PM
Re: Request

...or our very own FAQ

Topic: Shutdown/Restart - options


NTDOCAdministrator
(KiX Master)
2003-06-21 03:39 AM
Re: Request

Microsoft can't make Windows 9x shutdown properly themselves. Why do you think they have so many issues and fixes trying to fix the problem.

Many, many things in Windows 9x can prevent a shut-down

Try some of the mentioned methods or maybe even try setting a Task Schedule based on their answer that will allow the logon script to complete, but will then shut down the PC in something like 5 minutes. That way the logon processes won't be the cause of why it won't shut down or log off.

NOTE: Just an FYI, this is NOT a very descriptive title for your post. Please try to use a better description of the issue when posting.

[ 21. June 2003, 03:40: Message edited by: NTDOC ]


Sealeopard
(KiX Master)
2003-06-21 03:46 AM
Re: Request

Descriptive thread titles are covered in this FAQ: ABC's of KiXtart board etiquette and message to new forum users

Kixtart_Newbie
(Fresh Scripter)
2003-06-21 02:05 PM
Re: Request

That looks like it might work, but I won't be able to try it until next Wednesday morning. Sorry that my thread has the title it does. At the time, it seemed to be appropriate.