set/p with time?
Moderator: DosItHelp
Re: set/p with time?
After doing some reading the codepage shouldn't make a difference for those ascii characters. It does sound like it is a keyboard language problem. I saw something like this happen a few years ago. The user had changed their keyboard language and then none of their scripts or shortcuts worked.
Re: set/p with time?
Antonio, I certainly can't disagree with your point of view. I try to code things the simplest way possible. This should be a rudimentary task with the choice command. I like your programs for their unique abilities to overcome batch deficiencies but I just think it is overkill in this instance. If this is a keyboard language problem I would think your program would not work either because they may be pressing the physical W key but the language setting is sending a different character.
Re: set/p with time?
changed the chcp code still does not work!
i do some tests looks like the choice command does not care about the language of keys i send its only need to press shft + alt
even when my language is english and then i open script still give me beep sound by pressing wasd but after shift + alt when even language is not english its works!
also the focus must be on the command prompet window for example if i press shif + alt when the focus in on notepad it wont work!
very strange!
i do some tests looks like the choice command does not care about the language of keys i send its only need to press shft + alt
even when my language is english and then i open script still give me beep sound by pressing wasd but after shift + alt when even language is not english its works!
also the focus must be on the command prompet window for example if i press shif + alt when the focus in on notepad it wont work!
very strange!
Re: set/p with time?
tcpman wrote:also the focus must be on the command prompet window for example if i press shif + alt when the focus in on notepad it wont work!
This is one of the most basic concepts of Windows - the foreground window and all background windows.
Only one window has focus.
Re: set/p with time?
tcpman wrote:the problem is choice command has some problems for me!
What version of Windows are you using?
Are you using the native choice.exe or an addon replacement?
Re: set/p with time?
I'm not sure about your actual situation (confusing, that you said ".. even language is not english");tcpman wrote:i do some tests looks like the choice command does not care about the language of keys i send its only need to press shft + alt
even when my language is english and then i open script still give me beep sound by pressing wasd but after shift + alt when even language is not english its works!
i think the following is true:
Your default keyboard layout is "A (B)" (for example "German (Germany)".
Then you have switched your current keyboard layout from "A (B)" to "English (...)"
After that you start the batch script: But "set/P" only works after pressing SHIFT+ALT.
If the above is your situation, then the cause of that issue is:
Child processes/threads will be created using the default keyboard layout.
So if you start the batch script, a child (process/thread) is created with the default keyboard layout (== not "English (...)"), so you have to press SHIFT+ALT.
Sad to say that windows actually doesn't support to change this for child/parent processes using actual programming languages.
If you don't want to press SHIFT+ALT (again and again) then the only workaround (i know) is,
to set the default keyboard layout to "English (...)", while working on your batch.
With this setting a newly created batch process/thread is using the "English (...)" keyboard layout.
After you have finshed your (batch) work, you should reset the default layout back to "A (B)" to avoid other problems.
penpen
Re: set/p with time?
@foxdrive
win 7 no i use choice.exe
@penpen
look
my keybord language is en i start batch need's shif + alt
my keybord language is not en i start batch and still need's shft + alt
so i think the choice does not care about my language at all its just need me to press shft + alt
even when language is english and i run script still need shft + alt and the imteresting thing is when i press it its works! but the language is not english because when i type into notepad or something is not english anymore because i pressed shift + alt but its work in the batch script
my problem is with choice other commands are oky
can someone upload his own choice.exe for me so i can test it?
win 7 no i use choice.exe
@penpen
look
my keybord language is en i start batch need's shif + alt
my keybord language is not en i start batch and still need's shft + alt
so i think the choice does not care about my language at all its just need me to press shft + alt
even when language is english and i run script still need shft + alt and the imteresting thing is when i press it its works! but the language is not english because when i type into notepad or something is not english anymore because i pressed shift + alt but its work in the batch script
my problem is with choice other commands are oky
can someone upload his own choice.exe for me so i can test it?
-
- Expert
- Posts: 941
- Joined: 15 Jun 2012 13:16
- Location: Italy, Rome
Re: set/p with time?
tcpman wrote:hi all
i am creating a game and i was wondring
is it possible to use a timer with set/p
so if the timer equal to 0
and no input has been giving we go to a label or something?
i think its inpossible because of batch interpreter runs the line one by one!
but just wanted to ask!
I think it's possible using multithreading batch.
1) start a thread with input. (sign the pid)
2) start a second thread that count and kill the first thread
OR you can use alternate input method with xcopy http://www.dostips.com/forum/viewtopic.php?p=33741#p33741
a trace
Code: Select all
@echo off & if NOT "%1"=="" goto :%1
del %tmp%\input.save.dat.txt 2>nul
start "" /B cmd /c "%0 setp"
ping 127.0.0.1 -n 8 >nul
if not exist %tmp%\input.save.dat.txt goto :Timeout
type %tmp%\input.save.dat.txt
exit /b
:Timeout
echo No input detect
rem kill the process...
exit /b
:setp
setlocal EnableDelayedExpansion
set /p "v=" <CON:
>%tmp%\input.save.dat.txt echo !v!
exit /b
einstein1969
Re: set/p with time?
@einstein1969
tnx i will give it a try
----------------
also i was thinking maybe we could do what shift+alt do in batch? so then the problem will be solved
tnx i will give it a try
----------------
also i was thinking maybe we could do what shift+alt do in batch? so then the problem will be solved
-
- Expert
- Posts: 1160
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: set/p with time?
tcpman wrote:even when language is english and i run script still need shft + alt and the interesting thing is when i press it its works! but the language is not english because when i type into notepad or something is not english anymore because i pressed shift + alt but its work in the batch script
It sounds like your default language isn't English, which is why when you changed your keyboard language to English and then started the script, the keyboard was set back to whatever the default is for you.
Re: set/p with time?
@ShadowThief
I fully agree with you .
@tcpman
I think you have not fully realized what i've written in my above post.
I'm pretty sure your default keyboard layout is NOT "English (...)".
Because i don't know your default keyboard layout, i will denote it with "Your".
This may happen in your described cases (if i am right):
This value will be ignored, whenever a new process/thread is created.
So whenever your batch reaches the line with choice and wants to execute it,
the system creates a new process/thread with the default keyboard layout "Your".
The same happens to all external tools (executable files).
It has to do nothing with the current keyboard layout value of your command shell.
And this value of the command shell has nothing to do with the current keyboard
layout of the external choice command.
Every process has its own current keyboard layout value.
There this issue doesn't occure, because it is an internal command.
Internal commands are executed within the current "cmd.exe" thread/process.
So they don't use their own keyboard layout.
penpen
I fully agree with you .
@tcpman
I think you have not fully realized what i've written in my above post.
I'm pretty sure your default keyboard layout is NOT "English (...)".
Because i don't know your default keyboard layout, i will denote it with "Your".
This may happen in your described cases (if i am right):
It doesn't matter if you have set the keyboard layout to a specific value (en/not en):tcpman wrote:my keybord language is en i start batch need's shif + alt
my keybord language is not en i start batch and still need's shft + alt
(...)
even when language is english and i run script still need shft + alt and the imteresting thing is when i press it its works!
This value will be ignored, whenever a new process/thread is created.
So whenever your batch reaches the line with choice and wants to execute it,
the system creates a new process/thread with the default keyboard layout "Your".
The same happens to all external tools (executable files).
You may set current keyboard layout of the process/thread, that executes notepad to whatever value you like.tcpman wrote:but the language is not english because when i type into notepad or something is not english anymore because i pressed shift + alt but its work in the batch script
It has to do nothing with the current keyboard layout value of your command shell.
And this value of the command shell has nothing to do with the current keyboard
layout of the external choice command.
Every process has its own current keyboard layout value.
And i've probably described the reason above.tcpman wrote:so i think the choice does not care about my language at all its just need me to press shft + alt
I asusme you have tested for example "set /P".tcpman wrote:my problem is with choice other commands are oky
There this issue doesn't occure, because it is an internal command.
Internal commands are executed within the current "cmd.exe" thread/process.
So they don't use their own keyboard layout.
penpen
Re: set/p with time?
oh yes sory my mistake
tnx all the problem is now solved
but what about others?? is there any way to change the default language with batch? or do the shft+alt work?
because i going to give this to others
tnx all the problem is now solved
but what about others?? is there any way to change the default language with batch? or do the shft+alt work?
because i going to give this to others
Re: set/p with time?
No problem.oh yes sory my mistake
As written above, i'm sad to say that windows actually doesn't support the change of the keyboard layout for child/parent processes/threads programatically.
As far as i know it even can't be done using any programming language.
Even when using hooks it is just a temporary success... :
- while "hooking", it could be changed, but
- if the "hooking" process terminates the unchanged values are in use again.
Beside this, such applications are detected by nearly any virus scanner... .
penpen
Edit: Added some text to be more clear.
Last edited by penpen on 05 Sep 2014 14:06, edited 1 time in total.
Re: set/p with time?
Maybe it is possible to specify the keyboard layout programmatically.
Have a look at the list os LCIDs.
The behavior may differ though. MS changed it for Win8 as far as I read there.
Regards
aGerman
Code: Select all
@echo off &setlocal
call :changeKL 0409
:: your code
goto :eof
:changeKL LCID
>"%temp%\config.xml" (
echo ^<gs:GlobalizationServices xmlns:gs="urn:longhornGlobalizationUnattend"^>
echo ^<gs:UserList^>
echo ^<gs:User UserID="Current"/^>
echo ^</gs:UserList^>
echo ^<gs:InputPreferences^>
echo ^<gs:InputLanguageID Action="add" ID="%1:0000%1" Default="true"/^>
echo ^</gs:InputPreferences^>
echo ^</gs:GlobalizationServices^>
)
control intl.cpl,, /f:"%temp%\config.xml"
del "%temp%\config.xml"
goto :eof
Have a look at the list os LCIDs.
The behavior may differ though. MS changed it for Win8 as far as I read there.
Regards
aGerman