How to send € to the CMD-window Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
Albireo
Posts: 1777
Joined: 16 Oct 2013, 13:53

Re: How to send € to the CMD-window

28 Oct 2023, 04:04

Seven0528 wrote:
28 Oct 2023, 03:15

Code: Select all

ControlSend("{Text}" Chr(0x20AC),, "ahk_pid " cmdPID)
 Maybe...? Chr(0x20AC)=="€"
I don't understand!

Code: Select all

ControlSend(Chr(0x20AC)=="€",, "ahk_pid " cmdPID)
I got the sesult = 0 (zero)
User avatar
Seven0528
Posts: 412
Joined: 23 Jan 2023, 04:52
Location: South Korea
Contact:

Re: How to send € to the CMD-window

28 Oct 2023, 04:19

 ...What I'm trying to say is that Chr(0x20AC) is exactly the same as the string "€".
The Chr function returns a string using its parameter, which represents a Unicode number.
Every character has its own Unicode number, and the Unicode number for is 0x20AC in hexadecimal.
In most cases (though not always in a programmatic context), U+20AC is the standard notation.

Code: Select all

#Requires AutoHotkey v2.0
#SingleInstance Force
Msgbox Chr(0x20AC)=="€" ;  true
  • English is not my native language. Please forgive any awkward expressions.
  • 영어는 제 모국어가 아닙니다. 어색한 표현이 있어도 양해해 주세요.
User avatar
Seven0528
Posts: 412
Joined: 23 Jan 2023, 04:52
Location: South Korea
Contact:

Re: How to send € to the CMD-window

28 Oct 2023, 04:25

 equal
== is a comparison operator that returns 1 if two values are equal, and 0 if they are not.
1 represents true, and 0 represents false.
In many cases, you may have seen = used as a comparison operator.
== and = are similar, but the former always distinguishes between uppercase and lowercase characters,
while the latter is case-insensitive.
(Personally, I prefer the former to avoid confusion with other programming languages.)
  • English is not my native language. Please forgive any awkward expressions.
  • 영어는 제 모국어가 아닙니다. 어색한 표현이 있어도 양해해 주세요.
User avatar
mikeyww
Posts: 27314
Joined: 09 Sep 2014, 18:38

Re: How to send € to the CMD-window

28 Oct 2023, 06:25

I would argue that, as a case-insensitive comparison operator, = in AHK v2 is closest to == in the languages that use it. Thus, I think that using == in AHK to try to replicate == in other languages creates more confusion rather than less confusion. In many cases (situations), it also generates a bug in the script, because most string comparisons are intended to be case-insensitive.
User avatar
Seven0528
Posts: 412
Joined: 23 Jan 2023, 04:52
Location: South Korea
Contact:

Re: How to send € to the CMD-window

28 Oct 2023, 06:28

 This is my mistake. Sorry.
In other languages, = is usually used as an assignment operator. (In AHK, :=)
So I tend to use it simply to reduce typing errors, personally...
(Of course, I've mentioned the differences, but it seems there was some potential for misunderstanding.)
Last edited by Seven0528 on 28 Oct 2023, 15:01, edited 1 time in total.
  • English is not my native language. Please forgive any awkward expressions.
  • 영어는 제 모국어가 아닙니다. 어색한 표현이 있어도 양해해 주세요.
Albireo
Posts: 1777
Joined: 16 Oct 2013, 13:53

Re: How to send € to the CMD-window  Topic is solved

28 Oct 2023, 14:12

Thanks to all of you. :bravo:

This is a compilation of five (different) ways to send a slightly unusual character (€) to a DOS window .:

Code: Select all

#Requires AutoHotkey v2

Run 'cmd',,, &cmdPID
WinWait('ahk_pid' . cmdPID)

; Send Keys
Send "{U+20AC}"	; Sends € to CMD window
Send Chr(0x20AC)      ; Sends € to CMD window

; ControlSend Keys , Control, WinTitle, WinText, ExcludeTitle, ExcludeText
ControlSend("{U+20AC}",, "ahk_exe cmd.exe")	; Sends € to CMD window
ControlSend("{U+20AC}",, "ahk_pid " cmdPID)	; Sends € to CMD window
ControlSend("{Text}" Chr(0x20AC),, "ahk_pid " cmdPID)	; Sends € to CMD window

MsgBox  A_AhkVersion "`n" A_PtrSize " (4 = 32-bit, 8 = 64-bit) `n`nTecken (5st) .: " chr(0x20AC)

; WinClose WinTitle, WinText, SecondsToWait, ExcludeTitle, ExcludeText
; WinClose "Calculator"
WinClose "ahk_pid " cmdPID

; WinWaitClose WinTitle, WinText, Timeout, ExcludeTitle, ExcludeText
WinWaitClose "ahk_pid " cmdPID

; MsgBox Text, Title, Options
MsgBox "Ready!", "Row .: " A_LineNumber " - " A_ScriptName

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: No registered users and 27 guests