Send and SendPlay has issues with sending some “special chars” properly.
So I’ve done a simple function that “Safetize” your string to be send correctly. Hope be useful!
To beginners: Just put code below in a text file with a .ahk extension. Open it with autohotkey and press Ctrl+0
;############################################################################## ;Some chars are not sent properly by "Send" or "SendPlay" command. ;Use this function to get around this issue ;Version 1.0.2 Marcelo Gennari ;############################################################################## SafeSend(string) { local varStringOut := "" Loop, parse, string { If (InStr("!#+^{}/", A_LoopField, True) > 0) { If (A_LoopField = "/") varStringOut := varStringOut . "{ASC 47}" ; "/" has as special action else varStringOut := varStringOut . "{" . A_LoopField . "}" } else { varStringOut := varStringOut . A_LoopField } } return, %varStringOut% } ;Test SafeSend (Ctrl+0) ^0:: varStringToBeSend := "!""#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVW" varStringToBeSend .= "XYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ " varStringToBeSend .= " ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇ" varStringToBeSend .= "ÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ" run, notepad WinWaitActive varSafeStringToBeSend := SafeSend(varStringToBeSend) SendPlay, {Space 3}With SafeSend: %varSafeStringToBeSend% SendPlay, {Enter 2} SendPlay, Without SafeSend: %varStringToBeSend% Return
Comentários