#37319 - 2003-03-05 02:48 PM
Test for keypress for a specific Time - then continue
|
Luziekix
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
|
|
|
|
#37324 - 2003-03-05 03:07 PM
Re: Test for keypress for a specific Time - then continue
|
Luziekix
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
|
|
|
|
#37326 - 2003-03-05 03:32 PM
Re: Test for keypress for a specific Time - then continue
|
Luziekix
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
|
|
|
|
#37329 - 2003-03-05 04:26 PM
Re: Test for keypress for a specific Time - then continue
|
Luziekix
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
|
|
|
|
#37331 - 2003-03-05 04:46 PM
Re: Test for keypress for a specific Time - then continue
|
Luziekix
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
   
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
|
|
|
|
#37337 - 2003-03-05 10:18 PM
Re: Test for keypress for a specific Time - then continue
|
Jochen
KiX Supporter
   
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
|
|
Top
|
|
|
|
#37338 - 2003-03-06 08:54 AM
Re: Test for keypress for a specific Time - then continue
|
Luziekix
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
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 1160 anonymous users online.
|
|
|