A coworker of mine is trying to run one of my scripts.
- He's over in India.
- I'm here in the USA.
- Our computers are configured identically for Regional and Language settings. The same keyboard, system locale, and other character display settings.
- We're using SciTE4AutoHotKey Version 3.0.06.01 - Based on SciTE 3.5.1 Built on Oct 12 2014 13:40:05iin
Oddly, when he runs my script, any Send command that types characters into the Command Prompt window interprets the double quotation marks character (") as the at (@) character. (Other characters suffer a similar issue.) It seems to only be the command prompt window. Quotation marks sent directly to other apps (like the Windows Run app) seem to work fine. It's only when AutoHotKey sends it that it gets messed up with those @ chars. If he manually types a quotation mark in the Command Prompt window it is a quotation mark.
Here's what the results of a test script look like when ran on his computer:
https://www.dropbox.com/s/fqlx6hu4izffm ... 6.jpg?dl=0
Anyone seen this? Ideas on how to fix this?
Double quote symbols appear as @ symbols in Command Prompt window
Re: Double quote symbols appear as @ symbols in Command Prompt window
All the extra navigation to run a command prompt seems useless.
What happens when you run:
This should open the file in the default program that handles it.
Dont forget to SetWorkingDir if you are not going to have the full path.
What happens when you run:
Code: Select all
Run, %varProjPathToprep%\%varCurProjXPJ%
Dont forget to SetWorkingDir if you are not going to have the full path.
Re: Double quote symbols appear as @ symbols in Command Prompt window
I am absolutely no expert for this kind of supposed localization (?) issues, but what about loading the string into the built-in clipboard variable and pasting it via (Send, ^v) instead of sending the string itself via Send.
Other options might be to try different SendModes of the Send command to send the string, for example SendInput https://autohotkey.com/docs/commands/Se ... nputDetail.
Finally, is it a Unicode or Ansi file that you send to your colleague? Unicode ("UTF8 with BOM") would probably be the preferred format in this case.
Anyway, I hope that someone with a little more insight into this issue will chime in. Good Luck!
Edit: Xtra has probably a valid point there; why use Cmd at all in this case?!
Other options might be to try different SendModes of the Send command to send the string, for example SendInput https://autohotkey.com/docs/commands/Se ... nputDetail.
Finally, is it a Unicode or Ansi file that you send to your colleague? Unicode ("UTF8 with BOM") would probably be the preferred format in this case.
Anyway, I hope that someone with a little more insight into this issue will chime in. Good Luck!
Edit: Xtra has probably a valid point there; why use Cmd at all in this case?!
Re: Double quote symbols appear as @ symbols in Command Prompt window
You could try using WM_CHAR to send characters:
- I tried getting information on certain keys by checking AutoHotkey's key history, this script gave the same VK/SC codes that the key history showed.
- To send " on my PC you have to send shift+2, and indeed 2 and " have the same VK and SC codes in my results.
- So perhaps certain methods of sending keys will see " and then try and send shift+2, which may or may not give the intended result.
[EDIT:] Here's a further script:
Code: Select all
q:: ;test send characters
WinGet, hWnd, ID, A
ControlGetFocus, vCtlClassNN, % "ahk_id " hWnd
ControlGet, hCtl, Hwnd,, % vCtlClassNN, % "ahk_id " hWnd
if hCtl
hWnd := hCtl
vText := Chr(34) "@"
Loop, Parse, vText
PostMessage, 0x102, % Ord(A_LoopField), 1,, % "ahk_id " hWnd ;WM_CHAR := 0x102
return
- To send " on my PC you have to send shift+2, and indeed 2 and " have the same VK and SC codes in my results.
- So perhaps certain methods of sending keys will see " and then try and send shift+2, which may or may not give the intended result.
Code: Select all
w:: ;get VK and SC codes for a list of characters
;based on:
;What is the keycode for the following keys? - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=5&t=38807&p=177887#p177887
vText := "2" Chr(34) "'@"
vOutput := ""
Loop, Parse, vText
{
vKey := A_LoopField
vVK := GetKeyVK(vKey)
vSC := GetKeySC(vKey)
vOutput .= Format("VK{:02X} SC{:03X} {}`r`n", vVK, vSC, vKey)
}
Clipboard := vOutput
MsgBox, % "done"
return
;VK32 SC003 2
;VK32 SC003 "
;VKC0 SC028 '
;VKC0 SC028 @
Code: Select all
q:: ;send characters to the command prompt
WinGet, hWnd, ID, ahk_class ConsoleWindowClass
ControlGetFocus, vCtlClassNN, % "ahk_id " hWnd
ControlGet, hCtl, Hwnd,, % vCtlClassNN, % "ahk_id " hWnd
if hCtl
hWnd := hCtl
vTarget = "C:\Windows\System32\notepad.exe" "%A_ScriptFullPath%"
Loop, Parse, vTarget
SendMessage, 0x102, % Ord(A_LoopField), 1,, % "ahk_id " hWnd ;WM_CHAR := 0x102
;PostMessage seems to work fine,
;although SendMessage would be more reliable in theory
ControlSend,, {Enter}, % "ahk_id " hWnd
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: Double quote symbols appear as @ symbols in Command Prompt window
Thanks everyone. I appreciate the quick responses. I'll give them a try.
As to why I'm using a Command Prompt, I suppose in this particular case, it might not be necessary, but there are other statements throughout the real script that do need to use Command Prompt (such as using 7zip to zip up a directory using command line) and using RoboCopy commands to send the zipped file to a shared drive. And for those things we'd need quotes to be interpreted correctly anyway.
As to why I'm using a Command Prompt, I suppose in this particular case, it might not be necessary, but there are other statements throughout the real script that do need to use Command Prompt (such as using 7zip to zip up a directory using command line) and using RoboCopy commands to send the zipped file to a shared drive. And for those things we'd need quotes to be interpreted correctly anyway.
Re: Double quote symbols appear as @ symbols in Command Prompt window
Do a search for using stdin with command prompt.
Re: Double quote symbols appear as @ symbols in Command Prompt window
@JaredHess
1. You can try https://autohotkey.com/board/topic/25446-consolesend/
2. I wouldn't rely on SENDs to the command window, you can just as easily - I think - have your script write a temporary Batch file and RUN the batch file, just use RunWait and delete the batch file afterwards. You can use FileDelete and FileAppend. 7zip can also with with filelists (text files with lists of files to zip).
1. You can try https://autohotkey.com/board/topic/25446-consolesend/
2. I wouldn't rely on SENDs to the command window, you can just as easily - I think - have your script write a temporary Batch file and RUN the batch file, just use RunWait and delete the batch file afterwards. You can use FileDelete and FileAppend. 7zip can also with with filelists (text files with lists of files to zip).
Re: Double quote symbols appear as @ symbols in Command Prompt window
Here's an update on this.
We tested some things on his computer today.
gregster,
SendInput behaves the same as Send (@ appears instead of ").
jesswg,
We ran the script that returns VK and SC codes. This yielded this when we pasted it into Notepad:
VK32 SC003 2
VKDE SC028 "
VKDE SC028 '
VK32 SC003 @
We then tested using WM_CHAR to send characters. That does seem to work. I was able to get a " char to appear. Woot! I don't really understand what it does yet though, so I'll need to research some more and then rework my main script if I use this approach.
Xtra,
thanks. I did look at some older posts on the old forum, but couldn't really figure it out yet.
Guest,
I haven't tested writing, running, and deleting a batch file, but that's a good idea if it works, and might be a more elegant solution.
We tested some things on his computer today.
gregster,
SendInput behaves the same as Send (@ appears instead of ").
jesswg,
We ran the script that returns VK and SC codes. This yielded this when we pasted it into Notepad:
VK32 SC003 2
VKDE SC028 "
VKDE SC028 '
VK32 SC003 @
We then tested using WM_CHAR to send characters. That does seem to work. I was able to get a " char to appear. Woot! I don't really understand what it does yet though, so I'll need to research some more and then rework my main script if I use this approach.
Xtra,
thanks. I did look at some older posts on the old forum, but couldn't really figure it out yet.
Guest,
I haven't tested writing, running, and deleting a batch file, but that's a good idea if it works, and might be a more elegant solution.
Re: Double quote symbols appear as @ symbols in Command Prompt window
- Normally you can do anything you would do in the command prompt via AutoHotkey, as was mentioned above, via Run or RunWait. You can even do special commands like 'set' by specifying the path of ComSpec with some arguments.
- There is an example of getting the StdOut from a process here, see JEE_RunGetStdOut:
jeeswg's documentation extension tutorial - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=33596
- Regarding WM_CHAR. Every Unicode character has a number. I use PostMessage or SendMessage with WM_CHAR, with a number, and it sends that character to the window. We send a separate message for each individual character.
- Regarding " versus @:
my results:
VK32 SC003 2
VK32 SC003 "
VKC0 SC028 '
VKC0 SC028 @
your results:
VK32 SC003 2
VKDE SC028 "
VKDE SC028 '
VK32 SC003 @
This shows that neither the VK nor SC codes are consistent between the 2 systems, and therefore you cannot do Send/SendInput with VK or SC, to guarantee that the correct character is sent.
- There is an example of getting the StdOut from a process here, see JEE_RunGetStdOut:
jeeswg's documentation extension tutorial - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=33596
- Regarding WM_CHAR. Every Unicode character has a number. I use PostMessage or SendMessage with WM_CHAR, with a number, and it sends that character to the window. We send a separate message for each individual character.
- Regarding " versus @:
my results:
VK32 SC003 2
VK32 SC003 "
VKC0 SC028 '
VKC0 SC028 @
your results:
VK32 SC003 2
VKDE SC028 "
VKDE SC028 '
VK32 SC003 @
This shows that neither the VK nor SC codes are consistent between the 2 systems, and therefore you cannot do Send/SendInput with VK or SC, to guarantee that the correct character is sent.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: Double quote symbols appear as @ symbols in Command Prompt window
Final update. We ended up reworking our main script using the above WM_CHAR approach and PostMessage for anything we had to do with the command prompt on his system. The script is now working fine for my co-worker. Thanks again jesswg for your help.
Re: Double quote symbols appear as @ symbols in Command Prompt window
I have this issue in cmd.exe on Windows 10, and still don't understand what is causing this.
All punctuation signs in a string with send command are substituted with the
symbols from different keyboard layout, as if I was typing them with cyrillic layout switched on,
but it is not on. And it happens not always, so it's really weird.
The solution I came up with is to prepend the string with {text} and it solved the issue.
For example:
Types in cmd.exe:
With {text} prefix it works correctly
All punctuation signs in a string with send command are substituted with the
symbols from different keyboard layout, as if I was typing them with cyrillic layout switched on,
but it is not on. And it happens not always, so it's really weird.
The solution I came up with is to prepend the string with {text} and it solved the issue.
For example:
Code: Select all
a := "cd ""c:"""
send %a%
Code: Select all
cd @c^@
Code: Select all
a := "cd ""c:"""
send {text}%a%
Code: Select all
cd "c:"
Re: Double quote symbols appear as @ symbols in Command Prompt window
Yes, the {text} option would now be my first recommendation in such a case - unfortunately, it wasn't introduced when this threat was discussed, but shortly after... in version 1.1.27 in december 2017.
Re: Double quote symbols appear as @ symbols in Command Prompt window
I believe that Send {Text} was added as a consequence of this script and/or others at the time. Thanks being to lexikos for the quick response. It uses the same technique: WM_CHAR.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Who is online
Users browsing this forum: JKJadan and 262 guests