Jump to content

Leaderboard

Popular Content

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

  1. Jos

    Hold a key down

    That wasn't clear at all looking at your previous post, while that linked topic is pretty clear I would say! Post a replicator script else please stop bothering us with this "secret ...I can't share it". JOs
    1 point
  2. LarsJ

    Autoit variable to dot Net

    The problem with using pure AutoIt code as in your code above is that it's not possible to verify the effects of COM conversions in the internal AutoIt code, and the effects of marshalling when a safearray and a variant is passed from unmanaged AutoIt code to managed C# code. You don't know if data has been passed correctly. This can only be verified in the C# code. Without C# code, the chances of the code working is as close to zero as possible at all. To succeed with this code you will need to upgrade your lack of knowledge of C# code to a little bit of knowledge. Just enough to understand and write code as in post 2 above, which can be executed directly from AutoIt. However, there is the added complexity that you have to deal with safearrays and variants directly. In the documentation for the Connect method, isn't there an example of how to use the method in C# and how to create the required safearray and variant? If not then google. It should be possible to find examples showing how to create a safearray and a variant. In AutoIt you create a 1D safearray of variants containing strings this way: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 ;#AutoIt3Wrapper_UseX64=y Opt( "MustDeclareVars", 1 ) #include "Variant.au3" #include "SafeArray.au3" Example() Func Example() Local $i_args[3] = ["joe","mike","david"] Local $pSafeArray = ArrayOfStringsToSafeArrayOfVariantsOfBStrings( $i_args ) ConsoleWrite( "$pSafeArray = " & $pSafeArray & @CRLF ) EndFunc Func ArrayOfStringsToSafeArrayOfVariantsOfBStrings( ByRef $aArray ) Local $tsaBound = DllStructCreate( $tagSAFEARRAYBOUND ), $pSafeArray, $pSafeArrayData, $iArray = UBound( $aArray ), $iPtrSize = @AutoItX64 ? 8 : 4 DllStructSetData( $tsaBound, "cElements", $iArray ) DllStructSetData( $tsaBound, "lLbound", 0 ) $pSafeArray = SafeArrayCreate( $VT_BSTR, 1, $tsaBound ) SafeArrayAccessData( $pSafeArray, $pSafeArrayData ) For $i = 0 To $iArray - 1 DllStructSetData( DllStructCreate( "ptr", $pSafeArrayData + $iPtrSize * $i ), 1, SysAllocString( $aArray[$i] ) ) Next SafeArrayUnaccessData( $pSafeArray ) Return $pSafeArray EndFunc You create a variant of type VT_BOOL this way: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 ;#AutoIt3Wrapper_UseX64=y Opt( "MustDeclareVars", 1 ) #include "Variant.au3" Example() Func Example() Local $tVariant = DllStructCreate( $tagVARIANT ), $pVariant = DllStructGetPtr( $tVariant ) DllStructSetData( DllStructCreate( "word", $pVariant ), 1, $VT_BOOL ) DllStructSetData( DllStructCreate( "short", $pVariant + 8 ), 1, -1 ) ConsoleWrite( "$pVariant = " & $pVariant & @CRLF ) EndFunc
    1 point
  3. Thank you, I have been combing through it since my original post. I am trying to make sense of it. I will keep plugging away.
    1 point
  4. Well, it didn't exist back then, so that's irrelevant. Maybe stop blatantly advertising your UDF and I'd be more willing to try it. Personally, I'd rather create a3x files and shortcuts to the AutoIt executable. This really isn't the place for talking about it anyways. OP wanted to talk about enterprise solutions.
    1 point
  5. I have just found the solution and I want to share it with you The secret lies in passing the json data as a pointer instead of as a string. So changing these lines ... ; Post fields & size curl_easy_setopt($oCurl, $CURLOPT_POSTFIELDS, $sJson) with these: ; Post fields & size Local $stString = DllStructCreate("char v[" & StringLen($sJson) & "]") DllStructSetData($stString, 1, $sJson) curl_easy_setopt($oCurl, $CURLOPT_POSTFIELDS, DllStructGetPtr($stString)) and it works perfectly, returning this response: === Json post test === Retcode: - No error Data returned from server { "args": {}, "data": "{\"firstName\":\"Jonathan\",\"lastName\":\"Freeman\",\"loginCount\":4,\"active\": \"yes\",\"text\":\"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vel volutpat nunc. Maecenas id tempus mi. Morbi ipsum enim, ultricies ac augue sit amet, ullamcorper finibus ex. Vestibulum vel posuere nibh, nec faucibus eros. Nam malesuada non lacus a suscipit. Nulla rhoncus tempus mi quis placerat. Curabitur commodo tincidunt justo quis sollicitudin.\"}", "files": {}, "form": {}, "headers": { "Accept": "*/*", "Content-Length": "437", "Content-Type": "application/json", "Host": "httpbin.org", "X-Amzn-Trace-Id": "Root=1-5e3a9a12-f59424ee2b283d6ca7874c48" }, "json": { "active": "yes", "firstName": "Jonathan", "lastName": "Freeman", "loginCount": 4, "text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vel volutpat nunc. Maecenas id tempus mi. Morbi ipsum enim, ultricies ac augue sit amet, ullamcorper finibus ex. Vestibulum vel posuere nibh, nec faucibus eros. Nam malesuada non lacus a suscipit. Nulla rhoncus tempus mi quis placerat. Curabitur commodo tincidunt justo quis sollicitudin." }, "origin": "87.8.171.14", "url": "https://httpbin.org/post" } Attached correct version. Roy CurlJsonPostOk.au3
    1 point
  6. @BogdanNicolescu, I read both of your posts and, as one who learned AutoIt with no prior knowledge of programming, I fully understand the dire frustration you are experiencing. Below is one approach you can try. I am still learning, so I know experienced programmers will definitely find my code needs lot of improvements. But I hope my code will serve as your starting point to learn and improve your AutoIt skill. It would be best if you can collect the information with InetRead() function, which allows you to do the job without having to actually open the website. I didn't use InetRead() because I could not make out the URLs. Maybe someone with more experience and knowledge can help you out on that. My approach involves actually opening and clicking the website, so you cannot let the code run in the background and it will take considerably longer time. In Korea where I live it takes about 3~5 seconds to fetch data for one lecture. It will take less time in your country because of shorter physical distance to the server. My code does not use Excel; it rather creates a text file for the whole lectures, each line containing Denumire, Județ, Localitate and Email fields delimited with tabs. I tested this code under Windows 10 in a PC with 1920x1080 resolution. You may have to change some parts of the code if your PC's resolution is smaller. You are welcome to ask any question regarding my code. I wish you a good luck. #include <IE.au3> #include <String.au3> #include <Array.au3> Opt("WinTitleMatchMode", 2) HotKeySet("^!x", "_Exit") OnAutoItExitRegister("_Exit") While WinExists("Cartografia") WinClose("Cartografia") WEnd $oIE = _IECreate("https://www.siiir.edu.ro/carto/") _IELoadWait($oIE) WinSetState("Cartografia", "", @SW_MAXIMIZE) $tableTopColor = 0x006CB7 $tableBorderColor = 0x0058A3 $center = @DesktopWidth/2 Dim $xy1 = 0, $xy2 = 0, $xy3 = 0 While Not (IsArray($xy1) And IsArray($xy2) And IsArray($xy3)) $xy1 = PixelSearch($center, 100, $center, @DesktopHeight, $tableTopColor) $xy2 = PixelSearch($center, 500, $center, @DesktopHeight, $tableBorderColor) $xy3 = PixelSearch($center, 500, @DesktopWidth, 500, $tableBorderColor) Sleep(50) WEnd $tableTopY = $xy1[1] $tableBottomY = $xy2[1] $tableRightX = $xy3[0] $pageNumberX = $tableRightX-200 $pageNumberY = $tableBottomY-30 $fn = FileOpen("Cartografia_școlară.txt", 2+128) FileWriteLine($fn, "Denumire" & @TAB & "Județ" & @TAB & "Localitate" & @TAB & "Email") For $page = 1 To 1 ; 1860 If $page <> 1 Then ClipPut($page) MouseClick("left", $pageNumberX, $pageNumberY) Send("^a") Send("^v") _IELoadWait($oIE) EndIf For $i = 1 To 10 MouseMove($center, $i*31+$tableTopY+90) If MouseGetCursor() <> 0 Then _Exit() EndIf MouseClick("left") _IELoadWait($oIE) $h = TimerInit() While 1 $sText = _IEBodyReadHTML($oIE) If Not StringInStr($sText, 'Pagina web :') Then Sleep(100) ContinueLoop EndIf $sText = _StringBetween($sText, '</header>', 'Pagina web :')[0] $aText = StringSplit($sText, @LF, 1) ;_ArrayDisplay($aText) $nContact = 0 $sName = "" $sCounty = "" $sCity = "" $sEmail = "" For $j = 1 To $aText[0] $s = $aText[$j] If StringInStr($s, '<h4 class="modal-title ng-binding" id="myModalLabel">') Then $sName = _StringBetween($s, ">", "</h4>")[0] EndIf If StringInStr($s, '<p class="col-sm-8 ng-binding">') Then $nContact += 1 If $nContact = 1 Then $sCounty = _StringBetween($s, ">", " <")[0] ElseIf $nContact = 2 Then $sCity = _StringBetween($s, ">", " <")[0] ElseIf $nContact = 8 Then $sEmail = _StringBetween($s, ">", " <")[0] ExitLoop EndIf EndIf Next If $sCounty = "-" Then If TimerDiff($h) > 10000 Then ExitLoop Else Sleep(100) ContinueLoop EndIf Else ExitLoop EndIf WEnd FileWriteLine($fn, $sName & @TAB & $sCounty & @TAB & $sCity & @TAB & $sEmail) _IEAction($oIE, "back") While 1 If PixelGetColor($center, $tableBottomY, $oIE) = $tableBorderColor Then ExitLoop EndIf WEnd If $page <> 1 Then ClipPut($page) MouseClick("left", $pageNumberX, $pageNumberY) Send("^a") Send("^v") _IELoadWait($oIE) EndIf Next If Mod($page, 100) = 0 Then FileFlush($fn) EndIf Next Func _Exit() If IsDeclared("fn") Then FileClose($fn) EndIf Exit EndFunc
    1 point
  7. In addition to my earlier comments, AutoIt is a very forgiving and quite flexible language, that doesn't need a lot of recall or understanding of a huge bunch of concepts. Sure, knowing that stuff can improve how your use of or understanding of AutoIt is, but for many uses you can get by just fine relying on the wonderful Help file and online help and examples. I've never regretted giving up on other languages for the most part, and just relying on AutoIt. But then, I am just a hobby programmer who wants better control and usage of his PC, and I answer to no-one .... except my wife & kids & mother. I don't have to be a perfectionist, though I am very organised with structure and method. I do usually put in extra effort though, because I regularly share my work, but my comments can often be sparse, and not as many error checks as could be.
    1 point
  8. I will answer by reverse your question. I do not know C# and do not know Python. From 2004 my only one programming language is AutoIt. I have my own small bussines and I hire 3 people. AutoIt scripts which I made for my clients, are generating about 1/4 of my company incomes. Why I should use other programming language ? EDIT: currently in 2020 I hire 4 people
    1 point
  9. Did you try a forum search before posting? A simple search of Devcon shows almost 300 posts on the subject.
    1 point
×
×
  • Create New...