WebViewFunLib.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. // Copyright aXiuShen. All Rights Reserved.
  2. #pragma once
  3. #include "CoreMinimal.h"
  4. #include "Kismet/BlueprintFunctionLibrary.h"
  5. #include "WebCookie.h"
  6. #include "ZipReader.h"
  7. #include "ImitateInput.h"
  8. #include "WebViewFunLib.generated.h"
  9. /**
  10. *
  11. */
  12. UCLASS()
  13. class WEBVIEW_API UWebViewFunLib : public UBlueprintFunctionLibrary
  14. {
  15. GENERATED_BODY()
  16. public:
  17. /**
  18. * Set web cookie
  19. */
  20. UFUNCTION(BlueprintCallable, Category = "Web View")
  21. static bool SetCookie(const FString& URL, const FWebCookie& Cookie);
  22. /**
  23. * delete web cookie
  24. */
  25. UFUNCTION(BlueprintCallable, Category = "Web View")
  26. static bool DeleteCookies(const FString& URL, const FString& CookieName);
  27. /**
  28. * encode url to %%%%
  29. * @param URL :
  30. * @param use_plus : is true spaces will change to "+".
  31. */
  32. UFUNCTION(BlueprintCallable, Category = "Web View")
  33. static FString EncodeURL(const FString& URL,const bool use_plus=false);
  34. /**
  35. * open external browser
  36. * @param URL
  37. */
  38. UFUNCTION(BlueprintCallable, Category = "Web View")
  39. static void PopupURL(const FString& URL);
  40. /**
  41. * convert data to base64 string
  42. * @param data To be encoded
  43. * @return Encoding result data
  44. */
  45. UFUNCTION(BlueprintCallable, Category = "Web View")
  46. static FString Base64Encode(const FString& data);
  47. /**
  48. * Decoding encoded base64 string
  49. * @param base64 Data to be decoded
  50. * @return Decoding result data
  51. */
  52. UFUNCTION(BlueprintCallable, Category = "Web View")
  53. static FString Base64Decode(const FString& base64);
  54. /**
  55. * convert file content to base64 string
  56. * @param file To be encoded
  57. * @return Encoding result data
  58. */
  59. UFUNCTION(BlueprintCallable, Category = "Web View")
  60. static FString Base64EncodeFile(const FString& file );
  61. /**
  62. * Decoding encoded base64 string into file
  63. * @param base64 Data to be decoded
  64. * @param SaveFile use to save Decoding result data
  65. * @return false is failed,true is successful
  66. */
  67. UFUNCTION(BlueprintCallable, Category = "Web View")
  68. static bool Base64DecodeFile(const FString& base64, const FString& SaveFile);
  69. /**
  70. * Compress the directory into a zip file
  71. * @param Dir Directory to be compressed
  72. * @param ZipFile Save compressed file name
  73. * @param IncludeHiddenFiles true Compress hidden files
  74. * @return false is failed,true is successful
  75. */
  76. UFUNCTION(BlueprintCallable, Category = "Web View")
  77. static bool Zip(const FString& Dir, const FString& ZipFile, const bool IncludeHiddenFiles);
  78. /**
  79. * Open compressed file
  80. * @param zipFile compressed file name
  81. * @param passwd Compress password
  82. * @param Reader Compress Objects
  83. * @return false is failed,true is successful
  84. */
  85. UFUNCTION(BlueprintCallable, Category = "Web View")
  86. static bool UnZip(const FString& zipFile, const FString& passwd, UZipReader*& Reader);
  87. /**
  88. * Add Mouse Event
  89. * @param mouse : Mouse Event Type
  90. * @param point : Screen coordinates for mouse event input
  91. */
  92. UFUNCTION(BlueprintCallable, Category = "Web View")
  93. static FImitateInput& AddMouse(UPARAM(ref) FImitateInput& screen,const WebView_ImitateInput_Mouse mouse, const FIntPoint& point);
  94. /**
  95. * Add mouse click event
  96. * @param point : Screen coordinates for mouse event input
  97. * @note : Including mouse press and release
  98. */
  99. UFUNCTION(BlueprintCallable, Category = "Web View")
  100. static FImitateInput& AddClicked(UPARAM(ref) FImitateInput& screen, const FIntPoint& point);
  101. /**
  102. * Enter text
  103. */
  104. UFUNCTION(BlueprintCallable, Category = "Web View")
  105. static FImitateInput& AddText(UPARAM(ref) FImitateInput& screen, const FString& text);
  106. /**
  107. * Add delay between events
  108. */
  109. UFUNCTION(BlueprintCallable, Category = "Web View")
  110. static FImitateInput& AddDelay(UPARAM(ref) FImitateInput& screen, const int ms);
  111. UFUNCTION(BlueprintCallable, Category = "Web View")
  112. static FImitateInput& AddKeystroke(UPARAM(ref) FImitateInput& screen, const WebView_ImitateInput_Key keyboard, const FKey& key, const TArray<FKey>& CombinKey);
  113. /**
  114. * Analog keyboard input,
  115. * @param key : To input button
  116. * @param CombinKey : Combination keys such as shift, ctrl, alt, etc
  117. */
  118. UFUNCTION(BlueprintCallable, Category = "Web View")
  119. static FImitateInput& AddKey(UPARAM(ref) FImitateInput& screen, const FKey& key, const TArray<FKey> CombinKey);
  120. /**
  121. * show mouse event position, default off
  122. */
  123. UFUNCTION(BlueprintCallable, Category = "Web View")
  124. static FImitateInput& ShowLog(UPARAM(ref) FImitateInput& screen, bool on = false);
  125. /**
  126. * clear all event info
  127. */
  128. UFUNCTION(BlueprintCallable, Category = "Web View")
  129. static FImitateInput& Clear(UPARAM(ref) FImitateInput& screen);
  130. };