Autoit v3 and Websocket

in utopian-io •  7 years ago  (edited)

Autoit Websocket
In this article I want to show you how to connect to the websockets of Steem via Autoit.
At the First you most download the 3 UDF´s from my Github Project Websocket
Create a Folder and Move the files to it:

like this:

Step 1

now we create a new au3 file and open it.
we write now in the first 2 line´s:

#include <WinHttp.au3>
#include <JSON.au3>

Now we have to start a session and establish a connection.
for this step we wirte now this:

$hSession = _WinHttpOpen()
$hConnect = _WinHttpConnect($hSession, "gtg.steem.house",8090)

like this

now we can send the Command to the websocket:

$name = "killerfreak"
$sPost = _WinHttpSimpleSSLRequest($hConnect, "POST", "", "", '{"jsonrpc": "2.0","id": 7, "method": "get_accounts", "params": [["'&$name&'"]]}')

and this

at last we write now the Output to see the Result and close the Handle

MsgBox(0,"Output",$sPost)
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hSession)

final

Result:
Result

i you want see the Result in a Array you must include the array.au3

for this write under the

#include <JSON.au3>

this

#include <Array.au3>

now you can write the script so:

#include <WinHttp.au3>
#include <JSON.au3>
#include <Array.au3>
$hSession = _WinHttpOpen()
$hConnect = _WinHttpConnect($hSession, "gtg.steem.house",8090)
$name = "killerfreak"
$sPost = _WinHttpSimpleSSLRequest($hConnect, "POST", "", "", '{"jsonrpc": "2.0","id": 7, "method": "get_accounts", "params": [["'&$name&'"]]}')
$t = _JSONDecode($sPost)
$sPostResult = $t[2][1]
_ArrayDisplay($sPostResult[0])
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hSession)

now show the Result better^^
Result

Complet Script:

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.14.2
 Author:         Killerfreak

 Script Function:
    Connect to a Steem Websocket

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
#include <WinHttp.au3>
#include <JSON.au3>
#include <Array.au3>
$hSession = _WinHttpOpen()
$hConnect = _WinHttpConnect($hSession, "gtg.steem.house",8090)
$name = "killerfreak"
$sPost = _WinHttpSimpleSSLRequest($hConnect, "POST", "", "", '{"jsonrpc": "2.0","id": 7, "method": "get_accounts", "params": [["'&$name&'"]]}')
$t = _JSONDecode($sPost)
$spostresult = $t[2][1]
_ArrayDisplay($spostresult[0])
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hSession)

At the moment i work at a UDF for the websocket.

I Hope you enjoy this Tutorial



Posted on Utopian.io - Rewarding Open Source Contributors

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Your contribution cannot be approved because it does not refer to or relate to an open-source repository. See here for a definition of "open-source."

Hi, these are the reasons your contribution was rejected

  • AutoIt is closed source software, thus not an open-source project.
  • If you create a GitHub repository with additional material (like code samples), make sure to choose the repository of the project your tutorial is about and not your own repository. You can provide links to your repository in your post.
  • Tutorials must be technical instructions that teach non-trivial aspects of an open-source project. You don't really teach anything, you just provide code samples.

I recommend you read the rules before contributing again in the future.

You can contact us on Discord.
[utopian-moderator]

You got a 16.61% upvote from @upboater courtesy of @killerfreak!