Boa tarde!
Comprei um teclado que não tem o botao "." no teclado numérico e queria saber se é possível criar uma regra para inserir pontos, e vírgulas, no seguinte formato: "1.234.567,89" quando eu digitar 123456789 (ou qualquer número para o formato brasileiro).
Desde já, obrigado!!!
Inserir automaticamente pontos, e vírgula, ao digitar números
Moderator: Gio
Re: Inserir automaticamente pontos, e vírgula, ao digitar números
converter
Code: Select all
x:="123456789"
l:=SubStr(x,-1)
StringTrimRight,x,x,2
n:= ThousandsSep(x)
t:=n . "," . l
MsgBox,%t% ;- 1.234.567,89
ThousandsSep(x, s=".") {
return RegExReplace(x, "\G\d+?(?=(\d{3})+(?:\D|$))", "$0" s)
}
Re: Inserir automaticamente pontos, e vírgula, ao digitar números
garry wrote: ↑30 Aug 2023, 14:46converterCode: Select all
x:="123456789" l:=SubStr(x,-1) StringTrimRight,x,x,2 n:= ThousandsSep(x) t:=n . "," . l MsgBox,%t% ;- 1.234.567,89 ThousandsSep(x, s=".") { return RegExReplace(x, "\G\d+?(?=(\d{3})+(?:\D|$))", "$0" s) }
Unfortunately, it didn't work! Could it be because of the version I use (Version 1.0.48.05)?
I simply type de nubers and send an enter?
I really need this!
tks!
Re: Inserir automaticamente pontos, e vírgula, ao digitar números
Download > ;-- version 1 ... https://www.autohotkey.com/download/ last version is 1.1.37.01 20230901
2 exemplos
enviar para o bloco de notas
escrever no arquivo
2 exemplos
enviar para o bloco de notas
Code: Select all
;-- version 1 ... https://www.autohotkey.com/download/ last version is 1.1.37.01 20230901
;-
;--- use F8 -------------------
#Requires AutoHotkey v1.1
#Warn
#Singleinstance,force
SetKeyDelay, 80, 10
run,notepad ;- abra o bloco de notas para teste / então use F8
#If WinActive("ahk_exe notepad.exe")
return
;-------------
~$F8::
InputBox,x,enviar para o bloco de notas,escrever dígitos ...,, 225, 125,400,100,Locale,,123456789
clipboard=
l:=SubStr(x,-1)
StringTrimRight,x,x,2
n:= ThousandsSep(x)
t:=n . "," . l
If !ErrorLevel && x != "" {
clipboard=%t%
send,^v`n
}
#if
return
;-------------
ThousandsSep(x, s=".") {
return RegExReplace(x, "\G\d+?(?=(\d{3})+(?:\D|$))", "$0" s)
}
;------------
esc::exitapp
;===========================
escrever no arquivo
Code: Select all
;- use F9 to run ...
#Requires AutoHotkey v1.1
#Warn
#Singleinstance,force
Filename :="digits.txt"
dir1:= a_desktop . "\My Digits Folder"
F1:= dir1 . "\" . filename
ifnotexist,%dir1%
FileCreateDir % dir1
return
;-------------
~$F9::
InputBox,x,escrever no arquivo,escrever dígitos ...,, 225, 125,400,100,Locale,,123456789
l:=SubStr(x,-1)
StringTrimRight,x,x,2
n:= ThousandsSep(x)
t:=n . "," . l
If !ErrorLevel && x != "" {
RunWait, %Comspec% /U /C echo %t%>>"%f1%"
try,
run,%F1%
}
return
;-------------
ThousandsSep(x, s=".") {
return RegExReplace(x, "\G\d+?(?=(\d{3})+(?:\D|$))", "$0" s)
}
--------------
esc::exitapp
;=============