I cannot get either StrReplace() or StringReplace to work with AutoHotkey.dll. The code below doesn't throw an error for the ahktextdll call, but yields "292" instead of the desired result. (I've tried lots of other syntax - suffice it to say I can't get anything to work.)
Code: Select all
#Persistent
ahk := ComObjCreate("AutoHotkey.Script")
haystack := "Hello World"
needle := "World"
code =
(
global out
out := StrReplace("You are a primate", " a ", " an insignificant ")
)
out := ahk.ahktextdll("strreplace(""You are a primate"", ""primate"", ""fat monkey"")")
while (ahk.ahkready())
sleep 100
ahk.ahkterminate()
msgbox %out% ; Shows "292"
out := StrReplace("Fat monkeys are not everywhere", " not", " most certainly")
msgbox %out% ; Shows "Fat monkeys are most certainly everywhere"
StringReplace, outagain, haystack, %needle%
msgbox %outagain% ; Shows "Hello"
ExitApp
burque505