Page 1 of 2 12>
Topic Options
#37319 - 2003-03-05 02:48 PM Test for keypress for a specific Time - then continue
Luziekix Offline
Getting the hang of it

Registered: 2003-02-27
Posts: 68
Hi!

Anyone have a clue on how to do a small loop
which reads the keyboard for e.g. 5 seconds time and then continues with the script even if was no key pressed ?!

If thereīs any input in the 5 seconds, it should be stored in a string-variable.

My problem is, that the GET / GETS commands donīt seem to continue with the script if thereīs no key-input.

Thanks for any help / think-about,

Luziekix

Top
#37320 - 2003-03-05 02:58 PM Re: Test for keypress for a specific Time - then continue
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Luzie,

something similar to this ?

Timer with Bypass

[ 05. March 2003, 14:59: Message edited by: jpols ]
_________________________



Top
#37321 - 2003-03-05 03:01 PM Re: Test for keypress for a specific Time - then continue
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
code:
for $=0 to 100
if kbhit()
$=100
endif
sleep 0.1
next

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#37322 - 2003-03-05 03:04 PM Re: Test for keypress for a specific Time - then continue
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Yeah,

Les' sample is more to the point , not to say my link demonstrates the opposite [Embarrassed]
_________________________



Top
#37323 - 2003-03-05 03:07 PM Re: Test for keypress for a specific Time - then continue
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
OOPS! Missed all the reqs though.

code:
for $=0 to 10
if kbhit()
get $key
$=10
endif
sleep 5
next



[ 05. March 2003, 15:07: Message edited by: LLigetfa ]
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#37324 - 2003-03-05 03:07 PM Re: Test for keypress for a specific Time - then continue
Luziekix Offline
Getting the hang of it

Registered: 2003-02-27
Posts: 68
Dear Jochen (and LLigetva)!

As Wizard write in the postings you linked me to:

"Thanks. I am usually quite good with kix, but this was a simple 'Duh' moment."

(Iīve searched the board for it but seem to
have used the wrong search-keyword).

Thanks,

Luzie

[ 05. March 2003, 15:11: Message edited by: Luziekix ]

Top
#37325 - 2003-03-05 03:12 PM Re: Test for keypress for a specific Time - then continue
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
oh well,

preparing for the next golf course :



while not kbhit() and $<500
    sleep 0.01
    $=1+$
loop



which is also not to the point !

storing that var ?



break on

"paused for 5 secs waiting for key ... "

while not $var and $<500
    sleep 0.01
    $=1+$
    if kbhit() get $var endif
loop


"Pause end" ? ?

"Key pressed : " + $var

get $



[Roll Eyes]

[ 05. March 2003, 15:21: Message edited by: jpols ]
_________________________



Top
#37326 - 2003-03-05 03:32 PM Re: Test for keypress for a specific Time - then continue
Luziekix Offline
Getting the hang of it

Registered: 2003-02-27
Posts: 68
I just want to add, that the

kbhit() - function

only seem to be available in KIX v4,
and not in KIX v3.63.

Since I use KIX v3.63 (because of "INGROUP-Test-problems") I have to use Jochenīs first example.

Regards,

Luziekix

Top
#37327 - 2003-03-05 03:33 PM Re: Test for keypress for a specific Time - then continue
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Oh well,

make sure to update your version soon (as this will enable you to use the COM interface as well as UDFs [Wink] )
_________________________



Top
#37328 - 2003-03-05 03:38 PM Re: Test for keypress for a specific Time - then continue
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
And the next time please state those (important) pieces of info in your questions.

[ 05. March 2003, 15:42: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#37329 - 2003-03-05 04:26 PM Re: Test for keypress for a specific Time - then continue
Luziekix Offline
Getting the hang of it

Registered: 2003-02-27
Posts: 68
Hello Jochen!

Now Iīve tried:

code:
-------------------------------------------------
? "Hit any key to cancel"

while $key = " " AND $count < 5
; ca. 5 seconds
sleep 1
$count = $count + 1
$=sendkeys(" ")
get $key
AT(3,$ypos)"."
$ypos = $ypos + 1
loop

IF $key="p"
? "PAUSED - Press any key to continue"
get $
ENDIF
-------------------------------------------------

My problem now: I want the script to pause when I press the "p"-key in the time-out-period.
But if I use the above code, it donīt pauses and waits for an key-input at the last "GET $"-command.
The "FLUSHKB"-command doesnīt seem to help.
KIX32.EXE v4.20 seem to do the same as KIX32.EXE v3.63. Where am I wrong ?

btw. On KIX v4.20 the example from you donīt seem to run using the SENDKEYS-command.
The script just continues without the "waiting-loop".

Luziekix

ps. to SEALEOPARD: sorry forgetting to mention my used KIX-version.

Top
#37330 - 2003-03-05 04:31 PM Re: Test for keypress for a specific Time - then continue
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Okay, to get this straight. You want a way to interrupt/stop a running script at an arbitrary point during the script execution?

Is this correct?

I don't think you can do this as a KiXtart script is a synchronously executed script. Unless, you put a keypress check after pretty much every couple of lines of code.

Question: WHY? What's the reason for this? It alwasy helps to also provide background information when posting a question. This is even specified in the 'ABCs of KiXtart Etiquette' post in the FAQ Forum.

[ 05. March 2003, 16:54: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#37331 - 2003-03-05 04:46 PM Re: Test for keypress for a specific Time - then continue
Luziekix Offline
Getting the hang of it

Registered: 2003-02-27
Posts: 68
The "WHY I WANT TO DO THIS" is a lot to explain, but I will try:

When the script runs on a users account the first time, the CMD-windows takes the default-values for the windows-size with e.g. 300 lines display-length. If I now have a script, which runs very fast I canīt alter the CMD-window-settings to the wanted 25 lines display-length. And if I use an long SLEEP-command like e.g. SLEEP 10 the script will just make an unnecessary pause for the "normal" user.

So I search for a possibility to stop execution of my KIX-login-script if I want with using an "secret"-key.

btw. these CMD-windows-settings can be set through the Registry but a key have to be set for each servers NETLOGON. So itīs more handy to me to set these CMD-Windows-settings manually.

Regards,

Luziekix

Top
#37332 - 2003-03-05 04:56 PM Re: Test for keypress for a specific Time - then continue
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
I think this is what you want:
code:
"Hit 'P' to pause: "
$=sendkeys(" ")
get $key
while $key <> "P" AND $count < 5 ; ca. 5 seconds
sleep 1
$count = $count + 1
$=sendkeys(" ")
get $key
loop
IF $key="p"
Chr(13) "PAUSED - Press any key to continue: "
get $ ; Swallow Sent space
get $
ENDIF
Chr(13) " "

Note though, this is a real kludge - you should use "SetFocus()" before the "SendKeys", to ensure that the keys get sent to the right place.

Sendkeys is not required for the KiXtart 4.x versions, as we use KBHit() which allows us to "peek" at the keyboard buffer and see if there is something there.

Top
#37333 - 2003-03-05 04:58 PM Re: Test for keypress for a specific Time - then continue
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Still: Why do you want to stop execution?

If you are interested in seeing what the script prints to the screen, then you cna alwys use any of the logging UDFs that have been posted here, e.g. WriteLog2() or DisplayText()

Alternatively, use DEBUG ON.
_________________________
There are two types of vessels, submarines and targets.

Top
#37334 - 2003-03-05 05:03 PM Re: Test for keypress for a specific Time - then continue
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Jens, it's a little more bizarre than that.

The first time his users log on, their console window is 300 lines deep.

He wants to be able to pause the login to change the window properties to 25 lines.

I'd have thought that there were simpler ways of doing it, but who knows.

Top
#37335 - 2003-03-05 05:05 PM Re: Test for keypress for a specific Time - then continue
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
There is:
code:
MODE CON COLS=80 LINES=25

in the batch file that calls the KiXtart script.
_________________________
There are two types of vessels, submarines and targets.

Top
#37336 - 2003-03-05 05:40 PM Re: Test for keypress for a specific Time - then continue
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
See also fnGetM() - Get Keystrokes with Optional Mask and Timeout
_________________________
There are two types of vessels, submarines and targets.

Top
#37337 - 2003-03-05 10:18 PM Re: Test for keypress for a specific Time - then continue
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Oh well, back at home

Additional Information :

FLUSHKB indeed did never worked until it was fixed in IIRC version 4.11 [Wink]

Think I was just too annoying for Ruud to leave this unfixed [Big Grin]
_________________________



Top
#37338 - 2003-03-06 08:54 AM Re: Test for keypress for a specific Time - then continue
Luziekix Offline
Getting the hang of it

Registered: 2003-02-27
Posts: 68
Hi Richard!

Your solution is exactly what Iīm searching for.

Thank you!

To Jens: I donīt call my Login-Skript from an Batch-File, I have just used "KIX32" as Login-Skript-Name in the NT-User-Manager. Thanks anyway
for your idea.

Luziekix

Top
Page 1 of 2 12>


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

Who's Online
0 registered and 1160 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.07 seconds in which 0.036 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