Last active
April 26, 2021 15:34
-
-
Save JoeGlines/1f9c6c1d51f72526d51b7b1622f49e37 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;******************************************************* | |
; Want a clear path for learning AutoHotkey; Take a look at our AutoHotkey Udemy courses. They're structured in a way to make learning AHK EASY | |
; Right now you can get a coupon code here: https://the-Automator.com/Learn | |
;******************************************************* | |
HTTP:=ComObjCreate("WinHttp.WinHttpRequest.5.1") | |
AHKPastebin(Content,Name:="",Notify:=1,Run:=0){ | |
HTTP.Open("POST","https://p.ahkscript.org/", False) | |
HTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded") | |
HTTP.Send("code=" UriEncode(Content) "&name=" UriEncode(Name) "&channel=#ahkscript") | |
if HTTP.Status()!=200{ ;If not okay | |
MsgBox Something went wrong | |
return | |
} | |
If (Notify) | |
Notify().AddWindow(Content,{Time:3000,Icon:300,Background:"0x1100AA",Icon:14,Title:"Added to pastebin at: " HTTP.Option(1),TitleSize:18,size:14,TitleColor:"0xFF0000"}) | |
If (Run) | |
Run % HTTP.Option(1) ;URL | |
return HTTP.Option(1) ;Return URL | |
} | |
;~ ;********************URI Encode string*********************************** | |
UriEncode(Uri, RE="[0-9A-Za-z]"){ | |
VarSetCapacity(Var,StrPut(Uri,"UTF-8"),0),StrPut(Uri,&Var,"UTF-8") | |
While Code:=NumGet(Var,A_Index-1,"UChar") | |
Res.=(Chr:=Chr(Code))~=RE?Chr:Format("%{:02X}",Code) | |
Return Res | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment