Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
  2. ; #Warn ; Enable warnings to assist with detecting common errors.
  3. SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
  4. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
  5.  
  6. #Persistent
  7. #SingleInstance, force
  8. SetBatchLines, -1
  9.  
  10. paths := {}
  11. paths["/SendConsole"] := Func("SendConsole")
  12. paths["404"] := Func("NotFound")
  13. paths["/logo"] := Func("Logo")
  14. paths["/FadeUp"] := Func("FadeUp")
  15. paths["/FadeDown"] := Func("FadeDown")
  16.  
  17. server := new HttpServer()
  18. server.LoadMimes(A_ScriptDir . "/mime.types")
  19. server.SetPaths(paths)
  20. server.Serve(8000)
  21. return
  22.  
  23. Logo(ByRef req, ByRef res, ByRef server) {
  24. server.ServeFile(res, A_ScriptDir . "/logo.png")
  25. res.status := 200
  26. }
  27.  
  28. NotFound(ByRef req, ByRef res) {
  29. res.SetBodyText("Page not found")
  30. }
  31.  
  32. SendConsole(ByRef req, ByRef res) {
  33. ; Go to VConsole
  34. WinActivate, VConsole
  35. ; Command field
  36. Click, 133, 782
  37. ; Type command
  38. Cmd := req.queries["command"]
  39. Send, %Cmd%
  40. ; Hit enter
  41. Send, {Enter}
  42.  
  43. res.SetBodyText("OK")
  44. res.status := 200
  45. }
  46.  
  47. FadeUp(ByRef req, ByRef res) {
  48. Loop 100 {
  49. Sleep 10
  50. SoundSet,+1
  51. }
  52. res.SetBodyText("OK")
  53. res.status := 200
  54. }
  55.  
  56. FadeDown(ByRef req, ByRef res) {
  57. Loop 100 {
  58. Sleep 10
  59. SoundSet,-1
  60. }
  61. res.SetBodyText("OK")
  62. res.status := 200
  63. }
  64.  
  65. #include, %A_ScriptDir%\AHKhttp.ahk
  66. #include %A_ScriptDir%\AHKsock.ahk
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement