/lib/PlayMacro.ahk

http://github.com/Skiouros/Macro · AutoHotKey · 30 lines · 27 code · 3 blank · 0 comment · 5 complexity · 414a5a376c12336993707a36414ecb2f MD5 · raw file

  1. PlayMacro(macro) {
  2. global currentXml
  3. static oXML := ComObjCreate("MSXML2.DOMDocument")
  4. oXML.async := False
  5. oXML.Load(currentXml)
  6. text := oXml.selectSingleNode("/profile/macros/" . macro . "/value").text
  7. StringReplace, text, text, ``n, `n, all
  8. Loop, Parse, text, `n
  9. {
  10. if (!A_LoopField)
  11. Continue
  12. else if (InStr(A_LoopField, "MouseMove"))
  13. {
  14. RegExMatch(A_LoopField, "O)MouseMove, (\d*?), (\d*)", match)
  15. MouseMove, % match.1, % match.2, 1
  16. }
  17. else if (InStr(A_LoopField, "Sleep,"))
  18. {
  19. Send % sendString
  20. sendString := ""
  21. Sleep % SubStr(A_LoopField, 8)
  22. }
  23. else
  24. sendString .= A_LoopField
  25. }
  26. Send % sendString
  27. }