Leaderboard
Popular Content
Showing content with the highest reputation on 06/30/2020 in all areas
-
About AutoIt-API-WS AutoIt-API-WS is a light weight web server with expressive syntax, with the sole purpose of wrapping your existing AutoIt app with little to no effort. With AutoIt-API-WS you can send and receive data between any application or framework, as long they can handle HTTP requests, which is an industry standard today. Like my other communcations UDF AutoIt-Socket-IO AutoIt-API-WS is heavily inspired from the big boys, but this time its Laravel and Ruby on Rails. Features Highlights No external or internal dependencies required RESTful mindset when designed Expressive syntax Small codebase Heavy use of Michelsofts Dictionary object Limitations Not complient with any RFC, so something important could be missing. Time will tell! One persons slow loris attack will kill the process forever. Example of implemetnation (With screenshots) This is a basic cRud operation with the RESTful mindset in use. #include "API.au3" #include <Array.au3> _API_MGR_SetName("My APP DB adapter") _API_MGR_SetVer("1.0 BETA") _API_MGR_SetDescription("This adapter allows you to get this n that") _API_MGR_Init(3000) _API_MGR_ROUTER_GET('/users', CB_GetUsers, 'string sortBy', 'Get all users, sortBy can be either asc or desc. asc is default') _API_MGR_ROUTER_GET('/users/{id}', CB_GetUsersById, 'int id*', 'Get user by id') While _API_MGR_ROUTER_HANDLE() WEnd Func DB_GetUsers() Local $userA = ObjCreate("Scripting.Dictionary") Local $userB = ObjCreate("Scripting.Dictionary") $userA.add('id', 1) $userA.add('name', 'TarreTarreTarre') $userA.add('age', 27) $userB.add('id', 2) $userB.add('name', @UserName) $userB.add('age', 22) Local $aRet = [$userA, $userB] Return $aRet EndFunc Func CB_GetUsers(Const $oRequest) Local $aUsers = DB_GetUsers() If $oRequest.exists('sortBy') Then Switch $oRequest.item('sortBy') Case Default Case 'asc' Case 'desc' _ArrayReverse($aUsers) EndSwitch EndIf Return $aUsers EndFunc Func CB_GetUsersById(Const $oRequest) Local Const $aUsers = DB_GetUsers() Local $foundUser = Null For $i = 0 To UBound($aUsers) -1 Local $curUser = $aUsers[$i] If $curUser.item('id') == $oRequest.item('#id') Then $foundUser = $curUser ExitLoop EndIf Next If Not IsObj($foundUser) Then Return _API_RES_NotFound(StringFormat("Could not find user with ID %d", $oRequest.item('#id'))) EndIf return $foundUser EndFunc When you visit http://localhost:3000 you are greeted with this pleasent view that will show you all your registred routes and some extra info you have provided. When you visit http://localhost:3000/users the UDF will return the array of objects as Json And here is an example of http://localhost:3000/users/1 More examples can be found here (NEWEST 2020-09-21) Autoit-API-WS-1.0.3-beta.zip OLD VERSIONS Autoit-API-WS-1.0.0-beta.zip Autoit-API-WS-1.0.1-beta.zip1 point
-
1 point
-
need help to create a treeview linked with array
nacerbaaziz reacted to MesterPerfect for a topic
good morning this is the first post here in the autoit forums i hope that you can help me in my problem i have a JSON encoded it a map of my forums where i want to make a treeview that have the same type of map e.g a system (as category) windows (as sub category) software (as an child item in the windows category) ..... i don't know how to do that so, i know that i can do that using the json functions but i need your help about how we can do it as the type that i told you by the way i need to put the sub info for each item in an array that give me the ability to manage my items e.g can post thread can reply message cound ... you just give me a small example and i can continue. am sorry if this against the rules of the forum. but i realy searched a lot but i couldn't i hope some one give me the way. thank you very much in advance here is the link of json forum https://www.autoitscript.com/forum/topic/148114-a-non-strict-json-udf-jsmn/ and here is my encoded json file { "tree_map": { "0": [ 1, 5, 6, 7 ], "1": [ 2 ], "2": [ 4 ], "5": [ 3 ], "6": [ 8 ], "8": [ 9, 10 ] }, "nodes": [ { "breadcrumbs": [], "description": "", "display_in_list": true, "display_order": 1, "node_id": 1, "node_name": null, "node_type_id": "Category", "parent_node_id": 0, "title": "Main category", "type_data": {} }, { "breadcrumbs": [ { "node_id": 1, "title": "Main category", "node_type_id": "Category" } ], "description": "", "display_in_list": true, "display_order": 1, "node_id": 2, "node_name": null, "node_type_id": "Forum", "parent_node_id": 1, "title": "Main forum", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [ { "node_id": 1, "title": "Main category", "node_type_id": "Category" }, { "node_id": 2, "title": "Main forum", "node_type_id": "Forum" } ], "description": "", "display_in_list": true, "display_order": 1, "node_id": 4, "node_name": null, "node_type_id": "Forum", "parent_node_id": 2, "title": "my forums1", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [], "description": "", "display_in_list": true, "display_order": 2, "node_id": 5, "node_name": null, "node_type_id": "Category", "parent_node_id": 0, "title": "Perfect", "type_data": {} }, { "breadcrumbs": [ { "node_id": 5, "title": "Perfect", "node_type_id": "Category" } ], "description": "", "display_in_list": true, "display_order": 2, "node_id": 3, "node_name": null, "node_type_id": "Forum", "parent_node_id": 5, "title": "ahmed", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [], "description": "", "display_in_list": true, "display_order": 3, "node_id": 6, "node_name": null, "node_type_id": "Forum", "parent_node_id": 0, "title": "autoit", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [ { "node_id": 6, "title": "autoit", "node_type_id": "Forum" } ], "description": "", "display_in_list": true, "display_order": 3, "node_id": 8, "node_name": null, "node_type_id": "Forum", "parent_node_id": 6, "title": "examples", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [ { "node_id": 6, "title": "autoit", "node_type_id": "Forum" }, { "node_id": 8, "title": "examples", "node_type_id": "Forum" } ], "description": "", "display_in_list": true, "display_order": 3, "node_id": 9, "node_name": null, "node_type_id": "Forum", "parent_node_id": 8, "title": "GUI", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [ { "node_id": 6, "title": "autoit", "node_type_id": "Forum" }, { "node_id": 8, "title": "examples", "node_type_id": "Forum" } ], "description": "", "display_in_list": true, "display_order": 31, "node_id": 10, "node_name": null, "node_type_id": "Forum", "parent_node_id": 8, "title": "windowEX", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [], "description": "", "display_in_list": true, "display_order": 4, "node_id": 7, "node_name": null, "node_type_id": "Category", "parent_node_id": 0, "title": "vbs", "type_data": {} } ] }1 point -
For someone who is obviously so new to scripting, I don't understand your requirement that the comparison of the valid values be a one-liner. I would think that it is more important to learn the different ways that it can be done, regardless of the number of lines. The example below, using Nine's suggestion to use an array for your valid values, does the reading of the value and the comparison for valid values all in one line (Go1). Go2 & Go3 show other ways to do the same thing. #include <GUIConstantsEx.au3> #include <Constants.au3> #include <Array.au3> Const $aValues = ["1012", "1221", "1411"] Global $Form1 = GUICreate("Form1", 376, 197, 192, 124) Global $Input1 = GUICtrlCreateInput("", 80, 64, 193, 21) Global $Go = GUICtrlCreateButton("GO", 80, 120, 113, 33) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Go Go1() ;Using _ArraySearch ;Go2() ;Using If ;Go3() ;Using Switch EndSwitch WEnd Func Go1() If _ArraySearch($aValues, GUICtrlRead($input1)) <> -1 Then MsgBox(0,'','YES') Else MsgBox(0,'','NO') EndIf EndFunc Func Go2() Local $sInput = GUICtrlRead($input1) If $sInput = "1012" Or $sInput = "1221" Or $sInput = "1411" Then MsgBox(0,'','YES') Else MsgBox(0,'','NO') EndIf EndFunc Func Go3() Switch GUICtrlRead($input1) Case "1012", "1221", "1411" MsgBox(0,'','YES') Case Else MsgBox(0,'','NO') EndSwitch EndFunc1 point
-
need help to create a treeview linked with array
nacerbaaziz reacted to MesterPerfect for a topic
Guys I need your help as soon as possible. I hope you can help me get what I want.1 point -
Added by @water to WIKI: https://www.autoitscript.com/wiki/User_Defined_Functions#Hardware1 point
-
I use the standard SciTE source, so when it is part of it and I feel like doing an update, it will also be part of SciTE4AutoIt3. Jos1 point
-
I have released 1.0.1-beta Bugfixes Empty array/object responses would not serialize properly Empty strings keys would not get serialized propertly Changes The router now lazily accepts appended slashes (example: http:/localhost:4545/route/) New Added some lousy tests, see "Testing.au3" for more info1 point
-
@Andreik somehow this problem has never left me. I didn't want to use a loop to check step by step the best fit for the text. #include <GDIPlus.au3> #include <GUIConstantsEx.au3> Local $hGUI, $hGraphic, $hBrush, $hFormat, $hFamily, $hFont, $tLayout, $sString, $iFontSize Local $iW = @DesktopWidth / 2, $iH = @DesktopHeight / 2 $hGUI = GUICreate("GDI+", $iW, $iH) ;, 0, 0, 0x80000000) GUISetState(@SW_SHOW) $sString = 'Take this kiss upon the brow!' & @CRLF $sString &= 'And, in parting from you now,' & @CRLF $sString &= 'Thus much let me avow--' & @CRLF $sString &= 'You are not wrong, who deem' & @CRLF $sString &= 'That my days have been a dream;' & @CRLF $sString &= 'Yet if hope has flown away,' & @CRLF $sString &= 'In a night, or in a day,' & @CRLF $sString &= 'In a vision, or in none,' & @CRLF $sString &= 'Is it therefore the less gone?' & @CRLF $sString &= 'All that we see or seem' & @CRLF $sString &= 'Is but a dream within a dream.' _GDIPlus_Startup() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) $hBrush = _GDIPlus_BrushCreateSolid(0xFFFFFFFF) $hFormat = _GDIPlus_StringFormatCreate() _GDIPlus_StringFormatSetAlign($hFormat, 1) _GDIPlus_StringFormatSetLineAlign($hFormat, 1) $hFamily = _GDIPlus_FontFamilyCreate("Arial") $tLayout = _GDIPlus_RectFCreate(20, 20, $iW - 40, $iH - 40) $iFontSize = Measure($sString, $iW - 40, $iH - 40) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $iFontSize = ' & $iFontSize & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $hFont = _GDIPlus_FontCreate($hFamily, $iFontSize ) ; <<< Adjust font size _GDIPlus_GraphicsClear($hGraphic) _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $tLayout, $hFormat, $hBrush) $hPen = _GDIPlus_PenCreate(0xFF00F000) _GDIPlus_GraphicsDrawRect($hGraphic, $tLayout.x, $tLayout.y, $tLayout.width, $tLayout.height, $hPen) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE _GDIPlus_PenDispose($hPen) _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() Func Measure($sString, $iW, $iH, $sFont = "Arial", $iStyle = 0, $iFormat = 0) Local Const $hFormat = _GDIPlus_StringFormatCreate($iFormat) Local Const $hFamily = _GDIPlus_FontFamilyCreate($sFont) Local Const $iFontSize = 1 Local Const $hFont = _GDIPlus_FontCreate($hFamily, $iFontSize, $iStyle) Local Const $hGraphics = _GDIPlus_GraphicsCreateFromHDC(_WinAPI_GetWindowDC(0)) Local $tLayout = _GDIPlus_RectFCreate(0, 0, $iW, $iH) Local Const $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $sString, $hFont, $tLayout, $hFormat) _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_GraphicsDispose($hGraphics) If ($iH / $aInfo[0].height) * $aInfo[0].width > $iW Then Return ($iW / $aInfo[0].width) Return ($iH / $aInfo[0].height) EndFunc I made several test and it worked properly so far. Can you check please again? Thx.1 point
-
Autoit-Socket-IO - Networking in AutoIt made simple!
Trong reacted to tarretarretarre for a topic
I have updated the UDF to 2.0.0 Version 2.0.0 (This update break scripts. Please consult the upgrade.md for guidance) All global internal variables has been renamed. Added a bunch of new API methods: _Io_RegisterMiddleware, _Io_whoAmI, _Io_IsClient, _Io_IsServer, _Io_getAllByProperty and _Io_getFirstByProperty and some more. Read more about these in the documentation. _Io_socketGetProperty now has a setter method called _Io_socketSetProperty which can be used to set custom properties. _Io_socketGetProperty now has a third parameter "default" which is used when a property is not found Removed _Io_setEventPostScript and _Io_setEventPretScript in favor of _Io_RegisterMiddleware Improved documentation (It still needs some love though) Improved the verbosity of _Io_DevDebug1 point -
#Region ???
Professor_Bernd reacted to BrewManNH for a topic
Another use for the #Region/#EndRegion tags are if you use Tidy on your script and you use the sort functions by name options. If you want to keep certain functions together, and still sorted, you would put them in between the region tags. What this does is it will sort the functions like this #Region 1st region Func A1 Func B1 Func C1 #EndRegion #Region 2nd Region Func A2 Func B2 Func C2 #EndRegion Normally they would all be sorted like A1->A2->B1->B2 etc. Handy if you have a GUI with tabs and want to keep the control functions together so it's easier to find them instead of having to search for them.1 point