Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/15/2021 in all areas

  1. Depends on the selected solution. For example, with UIAutomation, some actions cannot be done on a minimized window. Of course, send and mouseClick will not work...Unfortunately, there is no general guidelines. Just use the solution that works on that specific installer.
    2 points
  2. Considering your post count, you'll probably know the following info already . Furthermore, this has been mentioned numerous times in this and other threads. Just in case it has escaped your attention until now, here is a brief summary (simplified) : Compile your scripts in a3x format instead of exe. To execute a3x scripts on the target machine, there are several ways, e.g. : Install AutoIt, then you can execute a3x scripts similar to .exe by double-clicking. However, this option is often not desired by the recipient. If the scripts should only run on your own computer this is irrelevant, because an AutoIt installation already exists. Copy the appropriate file(s) AutoIt3.exe or AutoIt3_x64.exe to the target computer. Associate the extension a3x with the interpreter (AutoIt3.exe). Execution of a3x scripts by double-clicking possible. Since this requires a change in the registry of the target computer, it may also be undesirable. Copy the appropriate file(s) AutoIt3.exe or AutoIt3_x64.exe to the target computer. a3x files can be executed e.g. via a .cmd or a shortcut. This is the least invasive variant. I have switched all my scripts to the a3x format and since then virtually no problems with virus software anymore . Regarding security : au3 scripts will be embedded as a3x when compiling an .exe, so there are no differences. ==> Definitely worth a look is the solution from @Exit , see : au3tocmd-avoid-false-positives
    2 points
  3. Hello everyone Happy belated new year, I am here to give you the monthly update on the progress, but unfortunately I don't have much to show besides 650+ new lines of code that I am working on, presenting C code is not easy, especially if it is still a work in progress. The work on the expression parse is going strong, I have already added support for the basic binary infix operations (+, -, *, / etc.) and some others, I am currently working on parsing comparison operations, logical conjunction (And & Or) is next. This new parsing algorithm is a lot more flexible and powerful compared to my last implementation, so this should allow me to implement all sorts of expressions that we will ever need Here is a snippet of the new code, related to expression parsing: struct Expression expression_get(struct Token *tokens, size_t count) { struct Expression expression = {.op = OP_NOP}; // Calculate the number of actual tokens (anything not a whitespace) size_t actual_count = 0; struct Token *actual_tokens = tokens; for (size_t i = 0; i < count; ++i) if (tokens[i].type != TOK_WHITESPACE) ++actual_count; if (actual_count == count) goto skip_strip; // Allocate a new array with only actual tokens actual_tokens = malloc(sizeof(struct Token) * actual_count); if (!actual_tokens) raise_mem("collecting actual tokens"); size_t actual_i = 0; for (size_t i = 0; i < count; ++i) if (tokens[i].type != TOK_WHITESPACE) actual_tokens[actual_i++] = tokens[i]; skip_strip:; enum Precedence precedence = PRE__START; bool success; do { success = expression_parse(actual_tokens, actual_count, precedence--, &expression); if (expression.op == OP_ERR) raise_error("Unable to parse expression", false); } while (!success); return expression; } bool expression_parse(struct Token *token, size_t count, enum Precedence precedence, struct Expression *expression) { static char *err_mem_ctx = "parsing expression"; size_t operand_count; if (count == 1) { expression->op = OP_NOP; struct Operand *term = malloc(sizeof(struct Operand)); if (!term) raise_mem(err_mem_ctx); term->type = OPE_PRIMITIVE; term->value = malloc(sizeof(struct Primitive)); if (!term->value) raise_mem(err_mem_ctx); *term->value = primitive_get(token); expression->operands = term; } else { bool success; switch (precedence) { case PRE_INV: if (token->type != TOK_OPERATOR || token->op_info.sym != OPR_SUB) return false; expression->op = OP_INV; expression->operands = expression_alloc_operands(operand_count = 1); *expression->operands[0].expression = expression_get(token + 1, count - 1); break; case PRE_NEG: if (token->type != TOK_WORD || token->keyword != KWD_NOT) return false; expression->op = OP_NOT; expression->operands = expression_alloc_operands(operand_count = 1); *expression->operands[0].expression = expression_get(token + 1, count - 1); break; case PRE_EXP: success = expression_parse_infix_binary(token, count, (enum Operator []){OPR_EXP}, 1, false, expression); if (!success) return false; operand_count = 2; break; case PRE_MUL_DIV: success = expression_parse_infix_binary(token, count, (enum Operator []){OPR_MUL, OPR_DIV}, 2, true, expression); if (!success) return false; operand_count = 2; break; case PRE_ADD_SUB: success = expression_parse_infix_binary(token, count, (enum Operator []){OPR_ADD, OPR_SUB}, 2, true, expression); if (!success) return false; operand_count = 2; break; case PRE_CAT: success = expression_parse_infix_binary(token, count, (enum Operator []){OPR_CAT}, 1, true, expression); if (!success) return false; operand_count = 2; break; case PRE_COMP: success = expression_parse_comp(token, count); if (!success) return false; operand_count = 2; break; default: expression->op = OP_ERR; return false; } // Flatten expression operands for (size_t i = 0; i < operand_count; ++i) { if (expression->operands[i].expression->op == OP_NOP) { struct Expression *wrapped_expression = expression->operands[i].expression; expression->operands[i] = wrapped_expression->operands[0]; free(wrapped_expression); } } } return true; } bool expression_parse_infix_binary(struct Token *tokens, size_t count, enum Operator opr_list[], size_t opr_count, bool left, struct Expression *expression) { if (count < 3) return false; struct Token *op_token = find_token_by_opr(tokens, count, opr_list, opr_count, left); if (!op_token) return false; expression->op = opr_to_op(op_token->op_info.sym); expression->operands = expression_alloc_operands(2); *expression->operands[0].expression = expression_get(tokens, op_token - tokens); *expression->operands[1].expression = expression_get(op_token + 1, count - (op_token - tokens) - 1); return true; } bool expression_parse_comp(struct Token *tokens, size_t count) { if (count < 3) return false; struct Token *op_token = find_token_by_opr(tokens, count, (enum Operator []){OPR_GRT, OPR_LES, OPR_EQU}, 3, true); if (!op_token) return false; if (op_token == tokens || op_token == &tokens[count - 1]) return false; } struct Operand *expression_alloc_operands(size_t count) { static char *err_mem_ctx = "adding operands to an operation"; // Allocate space for operand array struct Operand *operands = malloc(sizeof(struct Operand) * count); if (!operands) raise_mem(err_mem_ctx); // Initialize each element with an empty expression for (size_t i = 0; i < count; ++i) { operands[i].type = OPE_EXPRESSION; operands[i].expression = malloc(sizeof(struct Expression)); if (!operands[i].expression) raise_mem(err_mem_ctx); } return operands; } struct Token *find_token_by_opr(struct Token *tokens, size_t count, enum Operator opr_list[], size_t opr_count, bool left) { size_t open_brackets = 0; size_t i = left ? 0 : count - 1; while (true) { if (tokens[i].type == TOK_BRACKET && tokens[i].data[0] == '(') { ++open_brackets; goto next; } if (open_brackets) { if (tokens[i].type == TOK_BRACKET && tokens[i].data[0] == ')') --open_brackets; goto next; } if (tokens[i].type == TOK_OPERATOR) { for (size_t opr = 0; opr < opr_count; ++opr) if (tokens[i].op_info.sym == opr_list[opr]) return tokens + i; } // Iterate next: if (left) {if (i == count) break; ++i;} else {if (i == 0) break; --i;} } return NULL; } I wish I had something more pretty to show you, but that's all I've got for the moment and I am working to complete this. Once expression parsing is done I can focus on parsing statements and then eventually implement a backend to actually execute the code, the proof of concept would be complete by that time -- I have been pretty busy with all sorts of stuff, so I haven't been able to dedicate as much time as I wished to work on this, so the progress is somewhat slow. However I have been changing my routine to allow me to work on a faster pace, so hopefully the next update will come sooner than a month! That's it for now folks, peace! ✌️
    2 points
  4. From MiniMax to Machine Learning ... Tic Tac Toe is a good game for studying AI algorithm because it's simple! I use Tabular Q Learning to implement this game, Every time a game finished, it will use the Q function to update the score of each steps it played. Q(S,A) = Q(S,A) + α ∗ (γ ∗ maxaQ(S′,a) − Q(S,A)) S being the current state, A the current action, S′ the state after doing A, α being the learning rate, γ being the discount factor, and maxaQ(S′,a) the highest Q value of any move in the next state S′, i.e. the Q value of the best move in the following state. It's funny to see that it plays better and better. That's why people were charmed by Machine Learning! Thank you! Download: tic_tac_toe.zip
    1 point
  5. i would do something like this: #include <Array.au3> #include <String.au3> Func Writ ($datafromuser) if StringLeft($datafromuser,2) <> @crlf Then $datafromuser=@CRLF & $datafromuser EndIf if StringRight($datafromuser,2) <> @crlf Then $datafromuser= $datafromuser & @crlf EndIf Local $a=_StringBetween($datafromuser,@CRLF,@CRLF) ;_ArrayDisplay($a) Cw ("Last Item is: " & $a[UBound($a)-1]) EndFunc Writ("test" & @crlf & "line1" & @crlf & "line2" & @crlf & "line3" & @crlf & "line4") Func cw($txt) ConsoleWrite ($txt & @crlf) EndFunc
    1 point
  6. Func Write ($datafromuser) Local $a[0], $count = 0 While $count <= 20 _ArrayAdd ($a, $datafromuser, '', @CRLF) $a[$count] = StringStripWS ($a[$count], 2) If Not $a[$count] Then MsgBox(0, "title", "a[" & $count & "]=" & $a[$count]) $count+= 1 WEnd EndFunc
    1 point
  7. Nine

    Combo Box search type

    Try : $oEdit1.SetFocus() BTW, you do not need that ValuePattern portion of your code if you are not using .setValue method...
    1 point
  8. Nine

    Combo Box search type

    I see. Then remove the whole setValue line and replace it with : Send("myText") It is not the nicest way to set a field but this should work in your situation...
    1 point
  9. Nine

    Combo Box search type

    You are doing the same error. Remove the whole Send line, as it returns 1 like I already told you. And use : $oValuePattern1.SetValue("myText")
    1 point
  10. Yep, there is a simplicity and complexity to GoTo, and I still use it now and then in VBA and the odd Batch file. There has only ever been the odd rare moment when I have kind of missed it in AutoIt, but not really. I have this recollection that GoTo may have existed in early AutoIt.
    1 point
  11. I don’t even know what application you want to minimize or hide so how could I give you an example?
    1 point
  12. What about just minimizing the window? I haven't tried this, but maybe that could be an option.
    1 point
  13. Nine

    Combo Box search type

    Normal. Send("anything") returns 1. So it seems that it is working but you do not use it properly. Next time, please post a runable code so we do not have to guess what you are trying to achieve...
    1 point
  14. Here one way to create a JS object in IE : #include <Constants.au3> #include <IE.au3> Global $oIE = _IECreate("about:blank") $oIE.Document.parentWindow.execScript("document.body.oAutoIt = eval;") Global $eval = Execute("$oIE.Document.body.oAutoIt") If Not IsObj($eval) Then Exit MsgBox ($MB_SYSTEMMODAL,"","Error creating JS object") MsgBox($MB_SYSTEMMODAL, "Eval", $eval('typeof 5')) ; execute js and get return $eval("alert('Test');")
    1 point
  15. What is your end goal? Please describe what you want to accomplish with this code. Where did you find this Javascript code? There are issues with the Javascript code. You can test it in one of the online sites like https://js.do/
    1 point
  16. Yes, we’re lucky to have Autoit where On Error Goto 0 is built-in to every line
    1 point
  17. 1 point
  18. Growing up without GoTo**, it confuses me. It seems to make the logic less linear and harder to follow... plus I always forget if the code just jumps to the target, or if it acts like a function and returns at some point. If I think about it long enough, I eventually realize that makes no sense, but it's confusing as heck. I'd rather use another function, a bool, or nested Ifs. Funny... I opened a particularly stubborn jar of salsa with a flat head today ** Not entirely true, they're kind of used in VBA for error handling, but I hate them. I was taught to avoid them at all costs. Especially On Error GoTo 0, which "ignores" all errors Disclaimer: I've never programmed in C
    1 point
  19. Hi guys today we're prepare new custom checkbox in autoit (modern checkbox) there're used some icon files with type of icons that you want install. If anybody interesting, Full Source code: https://cloud.mail.ru/public/fp2y/35K2983HE (from cloud storage) Screenshot:
    1 point
  20. TheXman

    Call to JSON REST API

    The example below should work also. It's a bit longer because it has comments, error checking, and several ConsoleWrites to see the progress, response, and any errors that may occur. Since you were using COM before, the syntax below should be familiar to you. post_authentication_test() Func post_authentication_test() Local $oHttp = Null, _ $oComErr = Null Local $iHttpStatus = 0 Local $sResponse = "", _ $sPostData = "" ConsoleWrite(@CRLF & "Executing API" & @CRLF) ;Set COM error handler $oComErr = ObjEvent("AutoIT.Error", "com_error_handler") ;Create a HTTP COM object $oHttp = ObjCreate("winhttp.winhttprequest.5.1") If @error Then ConsoleWrite("Unable to create http request object." & @CRLF) Exit -1 EndIf ConsoleWrite("WinHttpRequest object created." & @CRLF) With $oHttp ;Open POST request .Open("POST", "http://localhost/ARXivarNextWebApi/api/Authentication", False) ;Set request headers and options .SetRequestHeader("Content-Type", "application/json") ;Send request .Send('{"username":"admin","password":"123","clientId":"AUTOIT_TEST","clientSecret":"E5AE290AB76A4B1E"}') If @error Then ConsoleWrite(StringFormat("SEND ERROR: (0x%X) %s", $oComErr.Number, $oComErr.Description) & @CRLF) Return EndIf ;Get status code and response $iHttpStatus = .Status $sResponse = .ResponseText ;If status code isn't okay If $iHttpStatus <> 200 Then ConsoleWrite("HTTP Status : " & String($iHttpStatus) & @CRLF) ConsoleWrite("HTTP Response: " & @CRLF & $sResponse & @CRLF) Return EndIf EndWith ConsoleWrite("API Response:" & @CRLF & $sResponse & @CRLF) EndFunc Func com_error_handler($oError) #forceref $oError Return EndFunc
    1 point
  21. Or...you could do it as you're the one asking for help.
    1 point
×
×
  • Create New...