Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/02/2020 in all areas

  1. Recently I was working on TeamVierwer API . I had a little break, and wanted to check out another platform. Here is the result of my attempt: #include "GHAPI.au3" _GHAPI_AccessToken('b3e8.....de..........bdc3a0c.....bd27c6f') _GHAPI_GetUser("users/mLipok") _GHAPI_GetUserOrganizations("users/mLipok") _GHAPI_RootEndpoints() and GHAPI.au3 #include-once #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7 #Tidy_Parameters=/sort_funcs /reel #Region GHAPI.au3 - Header ; #INDEX# ======================================================================================================================= ; Title .........: GHAPI UDF ; AutoIt Version : 3.3.10.2++ ; Language ......: English ; Description ...: This is an UDF for for communicate with https://api.github.com via GitHub RESTful API ; Author(s) .....: mLipok ; Modified ......: ; =============================================================================================================================== #cs Title: GHAPI UDF Filename: GHAPI.au3 Description: This is an UDF for for communicate with https://api.github.com via GitHub RESTful API Author: mLipok Modified: Last Update: 2017/05/23 Requirements: AutoIt 3.3.10.2 or higher #ce #EndRegion GHAPI.au3 - Header #Region GHAPI.au3 - Include #include <array.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3> #EndRegion GHAPI.au3 - Include #Region GHAPI.au3 - Declarations Global $oErrorHandler = ObjEvent("AutoIt.Error", "_GHAPI_ErrFunc") Global $__g_sGitHubAPI_BaseUrl = "https://api.github.com" ; URL of the GitHub API Global $__g_sGitHubAPI_Version = "v3" ; Put the current API version in here Global Enum _ $GHAPI_ERR_SUCCESS, _ $GHAPI_ERR_GENERAL, _ $GHAPI_ERR_COMERROR, _ $GHAPI_ERR_STATUS, _ $GHAPI_ERR_COUNTER Global Enum _ $GHAPI_EXT_DEFAULT, _ $GHAPI_EXT_PARAM1, _ $GHAPI_EXT_PARAM2, _ $GHAPI_EXT_PARAM3, _ $GHAPI_EXT_COUNTER Global Enum _ $GHAPI_RET_SUCCESS, _ $GHAPI_RET_FAILURE, _ $GHAPI_RET_COUNTER #EndRegion GHAPI.au3 - Declarations #Region GHAPI.au3 - API Functions Func _GHAPI_ErrFunc($oError) ; Do anything here. ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_GHAPI_ErrFunc Func _GHAPI_AccessToken($sParam = Default) ; https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/ ; https://github.com/settings/tokens Local Static $sAccessToken = '' If $sParam <> Default Then $sAccessToken = $sParam Return $sAccessToken EndFunc ;==>_GHAPI_AccessToken Func _GHAPI_GetUser($sUser) Local $oHTTP = __GHAPI_HTTP_Open("GET", $sUser) Local $oJSON = __GHAPI_HTTP_Send($oHTTP) If @error Then Return SetError(@error, @extended, False) #forceref $oJSON EndFunc ;==>_GHAPI_GetUser Func _GHAPI_GetUserOrganizations($sUser) Local $oHTTP = __GHAPI_HTTP_Open("GET", $sUser & '/orgs') Local $oJSON = __GHAPI_HTTP_Send($oHTTP) If @error Then Return SetError(@error, @extended, False) #forceref $oJSON EndFunc ;==>_GHAPI_GetUserOrganizations Func _GHAPI_RootEndpoints() Local $oHTTP = __GHAPI_HTTP_Open("GET", '') Local $oJSON = __GHAPI_HTTP_Send($oHTTP) If @error Then Return SetError(@error, @extended, False) #forceref $oJSON EndFunc ;==>_GHAPI_RootEndpoints #EndRegion GHAPI.au3 - API Functions #Region GHAPI.au3 - INTERNAL Functions Func __GHAPI_HTTP_Open($sMethod, $sCommand, $sURLParameters = '') Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1") Local $sURL = $__g_sGitHubAPI_BaseUrl & "/" & $sCommand & $sURLParameters ;~ __GHAPI_DebugOut("> $sURL=" & $sURL & @CRLF) $oHTTP.Open($sMethod, $sURL, False) If @error Then Return SetError(@error, @extended, Null) $oHTTP.setRequestHeader("Authorization", "Bearer " & _GHAPI_AccessToken()) ; Accept: application/vnd.github.v3+json $oHTTP.setRequestHeader("Accept", "application/vnd.github." & $__g_sGitHubAPI_Version & "+json") ; User-Agent: Awesome-Octocat-App $oHTTP.setRequestHeader("User-Agent", "AutoIt UDF") Return $oHTTP EndFunc ;==>__GHAPI_HTTP_Open Func __GHAPI_HTTP_Send(ByRef $oHTTP, $sSendParameter = Default) If $sSendParameter = Default Then $oHTTP.Send() Else $oHTTP.Send($sSendParameter) EndIf ConsoleWrite('+' & $oHTTP.Status & @CRLF) ConsoleWrite('>' & $oHTTP.StatusText & @CRLF) ConsoleWrite($oHTTP.ResponseText & @CRLF) ConsoleWrite(@CRLF) If @error Then Return SetError(@error, @extended, $GHAPI_RET_FAILURE) ;~ Return SetError($GHAPI_ERR_SUCCESS, $oJSON.Size, $oJSON) EndFunc ;==>__GHAPI_HTTP_Send #EndRegion GHAPI.au3 - INTERNAL Functions #Region GHAPI.au3 - HOWTO / DOCS / HELP #CS https://developer.github.com/v3/ https://developer.github.com/v3/guides/ https://developer.github.com/program/ https://github.com/contact?form%5Bsubject%5D=New+GitHub+Integration https://developer.github.com/ http://stackoverflow.com/questions/28796941/github-api-authentication-with-msxml2-xmlhttp #CE #EndRegion GHAPI.au3 - HOWTO / DOCS / HELP REMARKS: This is just a modest start up and not a whole fully workable UDF, just so for a try, but maybe someone will be useful Regards, mLipok EDIT 1: If you need to make it workable just ask about specyfic feature. EDIT 2: Some changes in using word "GitHub" - to meet this rules: https://github.com/logos
    1 point
  2. lol, you got the easy way. Just change one little thing and your script won't work anymore. But if you are happy with your pixel approach, well I must say I am happy. Because you have use the best programming language to do simple thing like you did ! FYI, I was able to get volume level of a session using MMDevice interface by using IAudioMeterInformation class, but it is not that clear how you could figure the 50% thing.
    1 point
  3. pseakins

    IPRange Extractor

    For others, here is the contents of Test.au3; Global $g_sRegexPattern_T = "#.+?\t\t(.+)\t\t(.+)" Global $g_asFR_T = StringSplit(FileRead(@ScriptDir & "\1.txt"), @CRLF, 3) For $i In $g_asFR_T ConsoleWrite(StringRegExpReplace($i, $g_sRegexPattern_T, "$1:$2") & @CRLF) Next
    1 point
  4. jchd

    Numeric Lotto Prediction help.

    Another skin for this cat: Local $N = 99 Local $a[$N] For $i = 0 To $N - 1 $a[$i] = $i + 1 Next For $i = 1 To 8 _ArrayShuffle($a) ; display 6 random numbers without dups ConsoleWrite(_ArrayToString($a, " ", 0, 5, " ") & @LF) Sleep(1000) Next
    1 point
  5. Ontosy

    AutoCamo - 98.18b

    It is released as beta.
    1 point
  6. Another simple way: #include <Array.au3> _ArrayDisplay(lotto_numbers(), "Lotto Numbers") Func lotto_numbers() Local $aAvailableNumbers[0], $aSelectedNumbers[0] Local $iRandomIndex ;Load available numbers For $i = 1 To 90 _ArrayAdd($aAvailableNumbers, $i) Next ;Select 6 random, non-repeating, numbers from available numbers For $i = 1 To 6 $iRandomIndex = Random(0, UBound($aAvailableNumbers) - 1, 1) ;Random available number index _ArrayAdd($aSelectedNumbers, $aAvailableNumbers[$iRandomIndex]) ;Add available number to selected numbers _ArrayDelete($aAvailableNumbers, $iRandomIndex) ;Remove selected number from available numbers Next Return $aSelectedNumbers EndFunc
    1 point
  7. Nine

    Search in a file

    I know the message is misleading, but it also says (in other words) that your variable is not an 1D array. Try this instead : #include <Constants.au3> #include <Array.au3> $FilePath = 'Testing9.txt' $Source = FileRead($FilePath) Local $FirstChunks[0][3] _ArrayAdd($FirstChunks, $Source, 0, ",", @CRLF) For $i = 0 to UBound($FirstChunks, 1) - 1 For $j = 0 to UBound($FirstChunks, 2) - 1 ConsoleWrite($FirstChunks[$i][$j] & @CRLF) Next Next
    1 point
  8. Here a simple way : Func _RandomNum() For $N = 0 To 5 $Num[$N] = Random(1, 90, 1) For $C = 0 To 5 If $C = $N Then ContinueLoop If $Num[$C] = $Num[$N] Then $N -= 1 ;ConsoleWrite ("Found duplicate" & @CRLF) ContinueLoop 2 EndIf Next GUICtrlSetData($I[$N], $Num[$N]) Next EndFunc ;==>_RandomNum
    1 point
  9. Use an array to store the currently generated numbers and check against it to make sure there are no duplicates.
    1 point
  10. Also for dmob: I noticed that the help file for _AddArray includes statements for testing the difference.
    1 point
  11. Yes it is, as detailed in this post, where I was lucky to exchange some ideas with jpm in the same thread.
    1 point
  12. You can also use the new AutoIt Map datatype supported by the beta. All quirks have been fixed and Maps work better than scripting dictionaries: #include <Array.au3> Local $m[] ; $m is a Map $m[0x12345678] = "This 32-bit key works" $m[0x1234567812345678] = "But does this 64-bit key work?" ; yes! _ArrayDisplay(MapKeys($m)) Local $d = ObjCreate("Scripting.Dictionary") $d.Add(0x12345678, "This 32-bit key works") $d.Add(0x1234567812345678, "But does this 64-bit key work?") ; no!
    1 point
  13. Hello @Borje, I think that the solution with entering an A3X file is better than entering an EXE file, because the "Autoit3.exe" file is accepted as trustworthy by most virus scanners. Hello @t0nZ,, unfortunately the way via a zip file is inevitable, as ADS files cannot be sent via FTP or email. and that's why I recommended Borje to use the A3X variant.
    1 point
  14. James

    C4 - C in four functions

    https://github.com/rswier/c4/blob/master/c4.c Pretty darn neat.
    1 point
×
×
  • Create New...