Leaderboard
Popular Content
Showing content with the highest reputation on 01/02/2020 in all areas
-
Well, it seems that it is the trendy solution right now....2 points
-
Or create your own user-defined function (or should I say use something like my example below) . Everything doesn't have to be a regular expression.2 points
-
I'm creating a WebDriver tutorial
SkysLastChance reacted to water for a topic
Internet Explorer is nearly dead, newer versions of Firefox can't any longer be automated using Stilgar's FF UDF. Hence more and more users (including me) need to look at automating Webbrowsers using WebDriver. That's why I have started to create a tutorial in the wiki. It should describe all necessary steps from intallation to usage. I'm still collecting ideas for the tutorial - that's where you come into play. What do you expect to see in such a tutorial? Which browsers should be covered (Firefox, Chrome and Edge are settled)? Any questions for the FAQ? Which (high level) coding examples do you expect (like "How to attach to a running browser instance") ... Like to see your comments ToDo-List: Add "Tools" section and add ChroPath plugin. Done. FAQ: "How to attach to a running browser instance". Done. Explain the difference between iuiautomation, iaccessible, autoit, webdriver. Done. The AutoIt FAQ 40 has been extended. Detailed description of each function. Done Example for "how to deal with downloading". Use function _WD_DownloadFile. Example for "how to deal with popups (alerts, print or save dialog). Use function_WD_AlertRespond to respond to a user prompt. Example for "how to deal with multiple tabs". Use functions _WD_NewTab (create a new tab), _WD_Window (close or switch to a tab) and _WD_Attach (attach to existing tab).1 point -
An example on how to inject jQuery into a web page It can be useful to manage the page from AutoIt using jQuery. Idea from here: http://www.learningjquery.com/2009/04/better-stronger-safer-jquerify-bookmarklet Suggestions and improvements are welcome #include <ie.au3> Example() Func Example() Local $oIE = _IECreate("www.google.com") Local $jQuery = _jQuerify($oIE) MsgBox(0, "Version", "jQuery version: " & $jQuery.fn.jquery) MsgBox(0, "Example", "click ok to exit." & @CRLF & "Google logo will fade out by jQuery...") $jQuery('#hplogo').fadeOut(3000) ; jQuery will fade out the google logo EndFunc ;==>Example ; #FUNCTION# ==================================================================================================================== ; Name ..........: _jQuerify ; Description ...: ; Syntax ........: _jQuerify(Byref $oIE) ; Parameters ....: $oIE - Object variable of an InternetExplorer.Application. ; Return values .: an object variable pointing to the jQuery library ; Author ........: Chimp ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; =============================================================================================================================== Func _jQuerify(ByRef $oIE) Local $jsEval, $jQuery, $otherlib = False ; create a reference to the javascript eval() function $oIE.document.parentWindow.setTimeout('document.head.eval = eval', 0) Do Sleep(250) $jsEval = Execute('$oIE.Document.head.eval') Until IsObj($jsEval) ; if jQuery is not already loaded then load it If $jsEval("typeof jQuery=='undefined'") Then ; check if the '$' (dollar) name is already in use by other library If $jsEval("typeof $=='function'") Then $otherlib = True Local $oScript = $oIE.document.createElement('script'); $oScript.type = 'text/javascript' ; If you want to load jQuery from a disk file use the following statement ; where i.e. jquery-1.9.1.js is the file containing the jQuery source ; (or also use a string variable containing the whole jQuery listing) ;~ $oScript.TextContent = FileRead(@ScriptDir & "\jquery-1.9.1.js") ; <--- from a file ; If you want to download jQuery from the web use this statement $oScript.src = 'https://code.jquery.com/jquery-latest.min.js' ; <--- from an url $oIE.document.getElementsByTagName('head').item(0).appendChild($oScript) Do Sleep(250) Until $jsEval("typeof jQuery == 'function'") EndIf Do Sleep(250) $jQuery = $jsEval("jQuery") Until IsObj($jQuery) If $otherlib Then $jsEval('jQuery.noConflict();') Return $jQuery EndFunc ;==>_jQuerify1 point
-
1 point
-
The same with one loop only #include <date.au3> $iNum = 1 $sYear = 2016 For $iCC = 1 To 100 $m = Mod($iCC, 12) $sMonth = _DateToMonth(($m = 0) ? 12 : $m, 0) $sString_PartOne = "(" & $iNum & ")" $sString_PartTwo = $sMonth $sString_PartThree = $sYear $sStringFinal = $sString_PartOne & " " & $sString_PartTwo & " " & $sString_PartThree ConsoleWrite($sStringFinal & @CRLF) $iNum += 1 If $m = 0 Then $sYear += 1 Next1 point
-
Like this maybe? #include <date.au3> $iNum = 1 $sYear = 2016 For $iCC = 1 To 13 For $i = 1 To 12 $sMonth = _DateToMonth($i, 0) $sString_PartOne = "(" & $iNum & ")" $sString_PartTwo = $sMonth $sString_PartThree = $sYear $sStringFinal = $sString_PartOne & " " & $sString_PartTwo & " " & $sString_PartThree ConsoleWrite($sStringFinal & @CRLF) $iNum += 1 If Mod($iCC, 12) = 0 Then $sYear += 1 Next $sYear += 1 Next1 point
-
I'm creating a WebDriver tutorial
Danp2 reacted to JLogan3o13 for a topic
One thing you could include, as something of a tertiary tool, would be the ChroPath plugin for all major browsers. It makes finding an element by XPath, ID or CSS incredibly easy.1 point -
AutoIT including WebHooks for Discord
FrancescoDiMuro reacted to Puls3 for a topic
Wow, it has been a long time since I've written in AutoIt, and a long time since I commented here. Don't worry @Trying2Hard it wasn't working when I tried it either, the issue was that Discord modified their Webhook requirements and were sending an Error 404; Bad Request. I've now modified the code to work after Discord's changes by setting the header to json seeing as we're sending a json object. Took me hours to figure that out. Also side note, as I said in the last comment it's pure AutoIt, no UDFs. As I said before, remember to switch out the Discord webhook URL for your own. This requires nothing but an up to date AutoIt, cheers!  Webhook("Awesome") Func Webhook($Message) Local $Url = "https://discordapp.com/api/webhooks/sensitive-data-goes-here" Local $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") Local $Packet = '{"content": "' & $Message & '"}' $oHTTP.open('POST',$Url) $oHTTP.setRequestHeader("Content-Type","application/json") $oHTTP.send($Packet) EndFunc1 point -
Fastest way to send multiple HTTP requests
paradox109 reacted to moimon for a topic
Example multi request 10 pages website: Local $Thread = 10 Local $oWH[$Thread] Local $ThreadCompleted[$Thread] Local $CheckCompleted = 0 Local $AsyncMode = True For $i = 0 To $Thread - 1 $oWH[$i] = ObjCreate('WinHttp.WinHttpRequest.5.1') $oWH[$i].Open('GET', 'http://autoitvn.com/forums/thao-luan-hoi-dap/page-' & ($i + 1), $AsyncMode) $oWH[$i].Send() Next Do For $i = 0 To $Thread - 1 If $ThreadCompleted[$i] = 0 And $oWH[$i].WaitForResponse(0) = True Then ;$ThreadCompleted[$i] variable condition to prevent loop result ConsoleWrite('>Page ' & $i & ' completed:' & @CRLF & $oWH[$i].GetAllResponseHeaders & @CRLF) $ThreadCompleted[$i] = 1 $CheckCompleted += 1 EndIf Next Until $CheckCompleted = $Thread MsgBox(0, 'Hi', 'Completed') This method works very fast and do not use as much CPU and RAM resources as multi process1 point -
Eambo, I would use an algorithm to draw the button positions and then run through the buttons that need to be drawn. Here is a short example of the sort of thing I mean: #include <GUIConstantsEx.au3> Global $cStart, $cEnd ; Simulate different buttons to be drawn Global $aArray_Full[] = ["Button 1", "Button 2", "Button 3", "Button 4", "Button 5", "Button 6", "Button 7", "Button 8", "Button 9"] Global $aArray_Less[] = ["Button 1", "Button 2", "Button 4", "Button 5", "Button 6", "Button 8", "Button 9"] ; This bit is only needed to show the dymanic change Global $fFull = True $aDisplay = $aArray_Full $hGUI = GUICreate("Test", 300, 300) $cChange = GUICtrlCreateButton("Change", 110, 210, 80, 30) _DrawButtons() GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cChange ; Delete exiting buttons For $i = $cStart To $cEnd GUICtrlDelete($i) Next ; Adjust input arrays Switch $fFull Case True $aDisplay = $aArray_Less Case False $aDisplay = $aArray_Full EndSwitch $fFull = Not($fFull) ; draw the new buttons _DrawButtons() EndSwitch WEnd Func _DrawButtons() $cStart = GUICtrlCreateDummy() ; Set the bounds of the buttons to delete later For $i = 0 To UBound($aDisplay) - 1 ; Run through the buttons to draw ; Determine the position of the next button $iX = (Mod($i, 3) * 100) + 10 ; Move over 3 times... $iY = (Int($i / 3) * 50) + 10 ; ...and then move down a row GUICtrlCreateButton($aDisplay[$i], $iX, $iY, 80, 30) Next $cEnd = GUICtrlCreateDummy() ; Same here EndFunc Please ask if you have any questions. M231 point
-
Yes... though RE can be useful sometimes $str = 'This list is non-exhaustive - the Moderating team reserve the right to close any thread that they fe' _ & 'el is contrary to the ethos of the forum.' & @LF & @CRLF $str &= '2. Do not post material that could be considered pornographic, violent or explicit - or express pers' _ & 'onal opinions that would not be acceptable in a civilized society. Do not post any copyrighted mater' _ & 'ial unless the copyright is owned by you or by this site.' & @LF & @CRLF $str &= '3. To protect this community, any files posted by you are subject to checks to ensure that they do n' _ & 'ot contain malware. This includes, but is not limited to, decompilation and reverse engineering.' & @LF & @CRLF $str &= '4. Do not flame or insult other members - and just report the thread to a Moderator (see below) if y' _ & 'ou are so attacked.' & @LF & @CRLF $str &= '5. Do not PM other users asking for support - that is why the forum exists, so post there instead.' & @LF & @CRLF $str &= '6. Do not create multiple accounts - if you inadvertently created multiple accounts then contact a M' _ & 'oderator to close the unwanted ones.' & @LF & @CRLF $str &= '7. Do not repost the same question if the previous thread has been locked - particularly if you mere' _ & 'ly reword the question to get around one of the prohibitions listed above.' & @LF & @CRLF $str &= '8. Do not delete your posts, nor completely remove their content, if doing so will interrupt the flo' _ & 'w of the thread.' & @LF & @CRLF $str &= '9. Do not post in a thread while the Moderating team are actively trying to determine whether it is ' _ & 'legal.' & @LF & @CRLF $str &= 'The Moderation team will do their best to act in fair and reasonable manner. Sanctions will only be ' _ & 'applied as a last resort and any action taken will be explained in the relevant thread.' & @LF & @CRLF $str &= 'If moderation action is taken, you will need to acknowledge this through a dialog or you will be una' _ & 'ble to post further in the forum. Please note that this dialog is not an agreement that the warning ' _ & 'was justified - it is only there so that members are aware that moderation action has been taken and' _ & ' that they may have certain restrictions applied to their account.' & @LF & @CRLF $str &= 'If you feel that you have been unfairly moderated then contact the Moderator concerned - using a PM ' _ & 'or the "Report" button is preferable to opening a new thread (although new members may have to do th' _ & 'is). But do be aware that the Moderation team has the final word - the rules are set out by the site' _ & ' owner and you are only welcome here if you respect his wishes.' ;MsgBox(0,"", extract_lines($str, "protect", "posts")) ;MsgBox(0,"", extract_lines($str, "non-exhaustive", "ethos")) ;MsgBox(0,"", extract_lines($str, "protect", "")) ;MsgBox(0,"", extract_lines($str, "", "posts")) MsgBox(0,"", extract_lines($str, "protect", "?")) Func extract_lines($txt, $sStart, $sEnd) Return StringRegExpReplace($txt, '(?s)(?:^|.*\R)(\N*?' & $sStart & '.*' & $sEnd & '\N*).*', "$1") EndFunc1 point
-
what is your aim ? DDoS ?1 point
-
How to do image searching with multi-threading
pixelsearch reacted to Musashi for a topic
I am convinced, that your intentions are honorable. By definition, a bot (robot) is a computer program that executes repetitive tasks largely automatically without the need for interaction with a human user. You are right when you say, that there should be a separation between good and malicious bots. The problem is, that the whole subject is ambivalent and therefore often a damn grey zone. For example, some substances can be both, a drug (prohibited) and a medicine (beneficial). Fortunately, we have moderators who are making the right decisions (mostly ). I am sure no one here is naive enough to believe, that we can prevent malicious bots in general. We can only try to keep our own house clean. Any idiot can type some obvious search terms into Google and find the relevant sources.1 point -
How to do image searching with multi-threading
FrancescoDiMuro reacted to Musashi for a topic
Neither do I !!1 point -
Just use AdLibRegister after GuiSetState and remove calling _Imagen from the loop, I would also recommend checking to see if the $aCInfo[4] has changed, basic example: #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <ListViewConstants.au3> #include <EditConstants.au3> #include <GUIConstants.au3> Global $g_iCInfo = Null DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 1) Global $g_hForm = GUICreate("Form1", 615, 437, 192, 124) GUISetBkColor(0x7a7a7a) Global $g_idCheckbox1 = GUICtrlCreateCheckbox("Checkbox1", 40, 56, 97, 13) Global $g_idCheckbox2 = GUICtrlCreateCheckbox("Checkbox2", 40, 80, 97, 13) Global $g_idCheckbox3 = GUICtrlCreateCheckbox("Checkbox3", 40, 104, 97, 13) Global $g_idCheckbox4 = GUICtrlCreateCheckbox("Checkbox4", 40, 128, 97, 13) Global $g_idCheckbox5 = GUICtrlCreateCheckbox("Checkbox5", 40, 152, 97, 13) Global $g_idCheckbox6 = GUICtrlCreateCheckbox("Checkbox6", 40, 176, 97, 33) Global $g_idCheckbox7 = GUICtrlCreateCheckbox("Checkbox7", 40, 200, 97, 33) Global $g_idCheckbox8 = GUICtrlCreateCheckbox("Checkbox8", 40, 224, 97, 33) Global $g_idPic = GUICtrlCreatePic(@ScriptDir & "\0.jpg", 360, 64, 217, 249) Global $g_idEdit = GUICtrlCreateEdit("", 160, 64, 140, 100, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_READONLY), 0) GUICtrlSetData(-1, StringFormat("EDIT1\r\nASDFASDASDSADSAAS\r\nSADASDAS\r\nASDSADSA")) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, 0xFFFFFF) GUISetState(@SW_SHOW) AdlibRegister("_Imagen", 100) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _Imagen() Local $aCInfo = GUIGetCursorInfo($g_hForm) If $aCInfo[4] = $g_iCInfo Then Return Switch $aCInfo[4] Case $g_idCheckbox1 GUICtrlSetData($g_idEdit, StringFormat("EDIT1\111111111")) GUICtrlSetImage($g_idPic, @ScriptDir & "\1.bmp") GUICtrlSetColor($g_idCheckbox2, 0x000000) GUICtrlSetColor($g_idCheckbox3, 0x000000) GUICtrlSetColor($g_idCheckbox4, 0x000000) GUICtrlSetColor($g_idCheckbox5, 0x000000) GUICtrlSetColor($g_idCheckbox1, 0x00FF00) Case $g_idCheckbox2 GUICtrlSetImage($g_idPic, @ScriptDir & "\2.bmp") GUICtrlSetData($g_idEdit, StringFormat("EDIT1\2222222")) GUICtrlSetColor($g_idCheckbox3, 0x000000) GUICtrlSetColor($g_idCheckbox4, 0x000000) GUICtrlSetColor($g_idCheckbox5, 0x000000) GUICtrlSetColor($g_idCheckbox1, 0x000000) GUICtrlSetColor($g_idCheckbox2, 0x00FF00) Case $g_idCheckbox3 GUICtrlSetImage($g_idPic, @ScriptDir & "\3.bmp") GUICtrlSetData($g_idEdit, StringFormat("EDIT1\33333333")) GUICtrlSetColor($g_idCheckbox2, 0x000000) GUICtrlSetColor($g_idCheckbox4, 0x000000) GUICtrlSetColor($g_idCheckbox5, 0x000000) GUICtrlSetColor($g_idCheckbox1, 0x000000) GUICtrlSetColor($g_idCheckbox3, 0x00FF00) Case $g_idCheckbox4 GUICtrlSetImage($g_idPic, @ScriptDir & "\4.jpg") GUICtrlSetData($g_idEdit, StringFormat("EDIT1\4444444")) GUICtrlSetColor($g_idCheckbox3, 0x000000) GUICtrlSetColor($g_idCheckbox2, 0x000000) GUICtrlSetColor($g_idCheckbox5, 0x000000) GUICtrlSetColor($g_idCheckbox1, 0x000000) GUICtrlSetColor($g_idCheckbox4, 0x00FF00) Case $g_idCheckbox5 GUICtrlSetImage($g_idPic, @ScriptDir & "\5.jpg") GUICtrlSetData($g_idEdit, StringFormat("EDIT1\555555555")) GUICtrlSetColor($g_idCheckbox3, 0x000000) GUICtrlSetColor($g_idCheckbox2, 0x000000) GUICtrlSetColor($g_idCheckbox4, 0x000000) GUICtrlSetColor($g_idCheckbox1, 0x000000) GUICtrlSetColor($g_idCheckbox5, 0x00FF00) EndSwitch $g_iCInfo = $aCInfo[4] Return EndFunc1 point
-
Thats part 1, how to get it set up. The indepth tutorial on multi-threading is Part 2, here:1 point
-
I tried that, but it went too overboard ... way too many keys per section. Keys are not that relevant to the issue, and neither is file size. Here is my simpler version, which is one key per section. #include <Array.au3> IniWriteTEST_2() Exit Func IniWriteTEST_2() Local $inifle = @ScriptDir & "\Testing_2.ini" Local $file = FileOpen($inifle, 1) If $file <> -1 Then For $i = 1 To 3000 ;IniWrite($inifle, "Section_" & $i, "key", "1234567890abcdef") FileWrite($file, "[Section_" & $i & "]" & @CRLF) FileWrite($file, "key=1234567890abcdef" & @CRLF) ConsoleWrite("Section_" & $i & @CRLF) Next FileClose($file) Local $value = IniRead($inifle, "Section_3000", "key", "") MsgBox(262192, "Last Section", "key = " & $value) Local $sections = IniReadSectionNames($inifle) _ArrayDisplay($sections) MsgBox(262192, "Last Section Name Reported", $sections[0]) ; NOTE - Limit for IniReadSectionNames is 32767 characters. Local $count = StringLen(_ArrayToString($sections, "|", 1)) MsgBox(262192, "Character Count", $count & " characters in Section Names!") EndIf EndFunc ;==>IniWriteTEST_2 Of those 3,000 sections, only the first 2,605 were returned for me in _ArrayDisplay, where the count [0] was also 2,605. This is with Windows 7 32 Bit. So IniReadSectionNames is definitely limited. 32,757 characters was returned, as the next section name would have taken it over the 32,767 limit. File size is 441 Kb. Opening the 'Testing_2.ini' file with SciTE, you can see that all 3,000 sections and keys exist. So it is only that one INI function that appears to be limited. Writing and Reading still work.1 point
-
I figured it out. The scripts will work with a small modification at the top. You need to comment out "#NoAutoIt3Execute" from each of the scripts and replace it by the following. ;#NoAutoIt3Execute ; Refer to this forum post for the following change: ; https://www.autoitscript.com/forum/topic/161004-autoit-v33102-runautoitexe-autoit3executeline-issue/?do=findComment&comment=1168605 #pragma compile(AutoItExecuteAllowed, true) The fix mentioned above is necessary and in accordance with the "Change Log": I tested one of the Utility Functions from CommUtilities.au3 and it ran perfectly. After you have made the change, try the following: #include <CommUtilities.au3> Local $sCommPorts = _CommAPI_GetCOMPorts() ConsoleWrite("COM Ports:" & @LF & $sCommPorts & @LF) I hope this helps. The scripts were copied from here: https://www.autoitscript.com/wiki/CommAPI and then corrected.1 point