Jump to content

Faalamva

Active Members
  • Posts

    59
  • Joined

Everything posted by Faalamva

  1. @JLogan3o13 : Yup but I need an autoit solution. (NB : dunno how I did insert, and how I can remove the blue tag with your name on post above
  2. @Danp2 : Thank you, works like a charm ! @JLogan3o13
  3. Thank you, but unfortunately it's not enough. It seems the new content is not visible until some kind of refresh, because the log file is opened by another application. I can tell because I've already tried the code you linked (something similar). EDIT : I've found a workaround, just before getting the FileSize, I do a FileCopy into a TMP file, then I work on the TMP file. It works, but it's VERY resource-consuming since I need to create that TMP file on a regular basis (every x seconds), and that means duplicating the whole file every x seconds... I really need something lighter and faster.
  4. Hi, I'm trying to read a log file on Windows 7, opened and constantly updated by another application. So far, I'm using a combination of FileGetSize to detect the apparition of new lines in the log (i.e. when the filesize changes), then FileOpen and FileSetPos to retrieve the new data starting from the last known end-position. It works, HOWEVER I need to refresh (F5) the directory containing the file in Windows, otherwise the new content is not yet "seen" by my program. I've found some solutions like here : https://stackoverflow.com/questions/4400517/how-can-i-read-a-file-even-when-getting-an-in-use-by-another-process-exception But I don't know how to implement that in autoit. I've also figured out that the solution may imply WinAPI. I'm pretty sure this kind of problem has already been treated before (monitoring logs in real-time seems a very classical problem to me) but I haven't been able to find an example so far (except the link above). Would you please be kind enough to provide me with a very simple example ? Thanks !
  5. Hello, I'm a beginner in this specific area of coding and I need some help for a specific task. I have this URL : http://poe.trade/search/uugebetaodubar It returns a list of items for a game. I can display the HTML content of this page by using my browser (menu "show source code"), and it gives something like this : <!DOCTYPE html> <!--[if IE 8]> <html class="no-js lt-ie9" lang="en" > <![endif]--> <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <title>search results</title> <script>DOMAIN = "poe.trade";</script> <script type="text/javascript" src="/static/gen/packed.4fad197e.js"></script> <script type="text/javascript" src="/static/gen/explicit.d47a5c47.js"></script> <link rel="stylesheet" href="/static/gen/packed_dark.7cdcca18.css"> <script async='async' src='https://www.googletagservices.com/tag/js/gpt.js'></script> <script> window.VM_API = window.VM_API || []; window.biddr360 = window.biddr360 || {}; window.biddr360.eu = false; ... Now, I'd like to write a small code in autoit to automatically read the URL and return the content of the HTML in a string. Question 1 : How can I do that (I've tried with wget but all I could get was garbage/unreadable text) ? Question 2 : How can I manage correcty the UTF characters (some IGN are in korean as you can see in the items list) ? Thank you !
  6. Thank you, I could find this very useful thread (with all the explanations) thanks to your hint : https://www.autoitscript.com/forum/topic/98970-and/ As far as I'm concerned, this topic can now be closed.
  7. Hi, This code will give you the last row of column 1, and the last column on row 1 of your Excel file : $MaxRow = $oWorkbook.Sheets($SheetName).Range("A99999").End(-4162).Row $MaxCol = $oWorkbook.Sheets($SheetName).Range("ZZ1").End(-4159).Column -4162 is the internal Excel code for "XlUp" and -4159 the one for "XlToLeft". Make sure to adapt the 99999 and ZZ if necessary (i.e. if not high enough).
  8. Hello, A strange behaviour occured in my code, so I've stripped and stripped again its content, until I could confine and identify the very cause of the malfunction. Put under its simplest form, here it is : this kind of comparison is working, although at first sight it's no so evident why it is : If "338a" = 338 Then MsgBox(0, "", "Why oh why ?") EndIf I understand that comparing a string with an integer is a bit odd, however in the original code, I'm comparing variables from an array, and this array if filled from an Excel file through the _Excel_RangeRead function. The column of the Excel file can contain random values : some of them are 338 (interpreted as integer) and some others are 338a (interpreted as string). Now I can solve the problem by forcing the comparison like this : String(variable1) = String(variable2) where variable1 and variable2 can be of any type (coming from the Excel file). However I'd like to know the very reason why this comparison is working in the first place ? Please enlighten me ! Faalamva
  9. Thank you, I managed to create a working example with your hint. Here it is below : #include <IE.au3> $oIE = _IECreate("http://www.york.ac.uk/teaching/cws/wws/webpage1.html") WinSetState("", "", @SW_MAXIMIZE) $oElements = _IETagNameAllGetCollection($oIE) For $oElement In $oElements If $oElement.innerText = "EXERCISE" Then $oIE.document.parentwindow.scroll(0, 500) MsgBox(0, "", "WebPage elements have been parsed. Let's move the mouse to EXERCISE for example.") MouseMove($oElement.getBoundingClientRect().left + $oIE.document.parentwindow.screenleft, $oElement.getBoundingClientRect().top + $oIE.document.parentwindow.screentop) EndIf Next MsgBox(0, "", "Now let's simulate a click to the ""lesson two"" link at the bottom of the page.") _IELinkClickByText($oIE, "lesson two") MsgBox(0, "", "Now let's try to locate FONT ATTRIBUTES in the new webpage.") ; Stupid WinGetTitle adds " - Internet Explorer" after the real window title, so we have to remove it otherwise the attachment won't work ;MsgBox(0, "", WinGetTitle("[ACTIVE]")) $oIE2 = _IEAttach(StringReplace(WinGetTitle("[ACTIVE]"), " - Internet Explorer", "")) $oElements2 = _IETagNameAllGetCollection($oIE2) For $oElement2 In $oElements2 ;ConsoleWrite("Tagname: " & $oElement2.tagname & @CRLF & "innerText: " & $oElement2.innerText) If $oElement2.innerText = " FONT ATTRIBUTES" And $oElement2.tagName = "FONT" Then MsgBox(0, "", "New WebPage elements have been parsed. Let's move the mouse to FONT ATTRIBUTES for example."); MouseMove($oElement2.getBoundingClientRect().left + $oIE2.document.parentwindow.screenleft, $oElement2.getBoundingClientRect().top + $oIE2.document.parentwindow.screentop) EndIf Next Do you know if there's a simpler way to attach the new webpage (for example, by using its URL) ? I would be very interested in using the new URL instead of the webpage title.
  10. Hello, Let's take a simple example to illustrate my case. I open a webpage with the command _IECreate and I parse all its elements : #include <IE.au3> $oIE = _IECreate("http://www.york.ac.uk/teaching/cws/wws/webpage1.html") $oElements = _IETagNameAllGetCollection($oIE) For $oElement In $oElements ConsoleWrite("Tagname: " & $oElement.tagname & @CRLF & "Id: " & $oElement.id & @CRLF & "InnerText: " & $oElement.innerText & @CRLF & "--------------------------------" & @CRLF) Next Now let's imagine I simulate a click with MouseClick to the link "lesson two" at the bottom of this webpage. A new webpage will open : http://www.york.ac.uk/teaching/cws/wws/webpage2.html I'd like to get the elements (tagname, id, innertext) of this new webpage, just like I got them for the first webpage. But for this, I presume I would have to get a new $oIE2 Object variable of an InternetExplorer.Application, in order to be able to use the _IETagNameAllGetCollection once again. How am I supposed to do this ? Thank you !
  11. Very interesting Chimp, it seems we're heading in the right direction ! EDIT : I managed to adapt your code to get exactly what I need (i.e. using displayed labels instead of "H4") : #include <IE.au3> $oIE = _IECreate("http://www.york.ac.uk/teaching/cws/wws/webpage1.html") WinSetState("", "", @SW_MAXIMIZE) Local $myElement $oElements = _IETagNameAllGetCollection($oIE) For $oElement In $oElements If $oElement.innerText = "EXERCISE" Then $myElement = $oElement Next MsgBox(0, "", "Let's locate EXERCISE") MouseMove($myElement.getBoundingClientRect().left + $oIE.document.parentwindow.screenleft, $myElement.getBoundingClientRect().top + $oIE.document.parentwindow.screentop) MsgBox(0, "", "Let's scroll the webpage 200 pixels down") $oIE.document.parentwindow.scroll(0, 200) MsgBox(0, "", "Let's locate EXERCISE again") MouseMove($myElement.getBoundingClientRect().left + $oIE.document.parentwindow.screenleft, $myElement.getBoundingClientRect().top + $oIE.document.parentwindow.screentop) EDIT 2 : Tested "for real" in dynamic webpages. Works perfectly, and much simpler/shorter than the original code. Case solved, thank you !
  12. #include <IE.au3> #include <MsgBoxConstants.au3> ;~ Local $oIE = _IE_Example("basic") $oIE = _IECreate("http://www.york.ac.uk/teaching/cws/wws/webpage1.html") Local $oElements = _IETagNameAllGetCollection($oIE) For $oElement In $oElements ConsoleWrite("Tagname: " & $oElement.tagname & @CRLF & " id: " & $oElement.id & @CRLF & " innerText: " & $oElement.innerText & @CRLF) Next _IEQuit($oIE) Result in console : We're still drifting away from topic...
  13. Your example won't work, it will display "Something went wrong here..." everytime the element checked isn't "EXERCISE". Please remember that this is just an example I wrote in a few minutes to illustrate the case, it may not be state-of-the-art of course. But it's working as a standalone program, just copy/paste and run it to see by yourself. Let's stick to the topic please
  14. Thank you for your answer, unfortunately, I've already tried and it doesn't work. Here is a full example to illustrate my problem. Just copy/paste and run it and you'll understand what I'm trying to achieve. #include <IE.au3> ; ---------------------------------------------------------------------- ; Main ; ---------------------------------------------------------------------- $oIE = _IECreate("http://www.york.ac.uk/teaching/cws/wws/webpage1.html") WinSetState("","",@SW_MAXIMIZE) $windowleft = $oIE.document.parentwindow.screenLeft $windowtop = $oIE.document.parentwindow.screenTop $oElements = _IETagNameAllGetCollection($oIE) For $oElement In $oElements If $oElement.innerText = "EXERCISE" Then $oElementPosX = $windowleft + _IEfindPosX($oElement) $oElementPosY = $windowtop + _IEfindPosY($oElement) MsgBox(0, "", "Mouse will be moved to ""EXERCISE"" position") MouseMove($oElementPosX, $oElementPosY) EndIf Next MsgBox(0, "", "Let's scroll the webpage 200 pixels down") $oIE.document.parentwindow.scroll(0, 200) ; Trying to "refresh the elements positions" --> it doesn't work $oElements = _IETagNameAllGetCollection($oIE) For $oElement In $oElements If $oElement.innerText = "EXERCISE" Then $oElementPosX = $windowleft + _IEfindPosX($oElement) $oElementPosY = $windowtop + _IEfindPosY($oElement) MsgBox(0, "", "Mouse will be moved again to ""EXERCISE"" position") MouseMove($oElementPosX, $oElementPosY) EndIf Next MsgBox(0, "", "Positions of webpage elements haven't been refreshed, the mouse was moved to the former EXERCISE position...") ; ---------------------------------------------------------------------- ; Functions ; ---------------------------------------------------------------------- Func _IEfindPosX($o_object) Local $curleft = 0 Local $parent = $o_object If IsObj($parent) Then While IsObj($parent) $curleft += $parent.offsetLeft $parent = $parent.offsetParent WEnd Else Local $objx = $o_object.x If IsObj($objx) Then $curleft += $objx EndIf Return $curleft EndFunc Func _IEfindPosY($o_object) Local $curtop = 0 Local $parent = $o_object If IsObj($parent) Then While IsObj($parent) $curtop += $parent.offsetTop $parent = $parent.offsetParent WEnd Else Local $objy = $o_object.y If IsObj($objy) Then $curtop += $objy EndIf Return $curtop EndFunc
  15. Hi, I'm using the IE.au3 library to parse elements in a webpage and get their (x,y) coordinates. Main commands I'm using are : $oIE = _IECreate($myWebPage) $oElements = _IETagNameGetCollection($oIE, "label") $windowleft = $oIE.document.parentwindow.screenLeft $windowtop = $oIE.document.parentwindow.screenTop $oElementPosX = $windowleft + _IEfindPosX($oElement) $oElementPosY = $windowtop + _IEfindPosY($oElement) Now things become a bit tricky when i simulate a scroll in my webpage : $oIE.document.parentwindow.scroll(0, $myScrollY) Because once this is done, the coordinates of the elements are still what they were before the scroll. I can manage this problem by keeping track of the number of pixels I have scrolled, and compute the new "real" ($oElementPosX, $oElementPosY). But I'm pretty sure there's a more efficient / more elegant way to do it. What's more in some situations, when I click some controls in the webpage, the webpage adds new elements and shifts the controls below by a random number of pixel, so my workaround can't be used... So here's my question : Is there a way to "refresh" the calculation of label coordinates ($oElementPosX, $oElementPosY) after a scroll ? Thank you ! EDIT : I forgot to post the _IEfindPosX and _IEfindPosY functions (found somewhere on this forum) : Func _IEfindPosX($o_object) Local $curleft = 0 Local $parent = $o_object If IsObj($parent) Then While IsObj($parent) $curleft += $parent.offsetLeft $parent = $parent.offsetParent WEnd Else Local $objx = $o_object.x If IsObj($objx) Then $curleft += $objx EndIf Return $curleft EndFunc Func _IEfindPosY($o_object) Local $curtop = 0 Local $parent = $o_object If IsObj($parent) Then While IsObj($parent) $curtop += $parent.offsetTop $parent = $parent.offsetParent WEnd Else Local $objy = $o_object.y If IsObj($objy) Then $curtop += $objy EndIf Return $curtop EndFunc
  16. Thank you for these new hints, I'll take a look eventually. I have tested your first fix in my main program and checked with a large set of series and clicking : everything's working as expected.
  17. I have added 4 screenshots in the ZIP file, corresponding to each click as described in my original post. You can now easily see what my display looks like after each click.
  18. Yeah that's weird but I'm not totally surprised. My screen resolution is 1920x1080, is it the same for you ? I suspect that the behaviour might change if the resolution is different because I've had a correct behaviour when changing the GUI size (parent and child). I'm 99% sure this problem comes from the horizontal scrollbar being triggered for whatever reason. But I'll try your suggestion and let you know. EDIT : Ok, with this suggestion, it works indeed (adding the third line in this portion of code) : _GUIScrollBars_Init($RightChildGUI) _GUIScrollBars_Generate($RightChildGUI, 0, $RightImageYPos[$NbReferenceImages] + $RightImageHeight[$NbReferenceImages]) _GUIScrollBars_ShowScrollBar($RightChildGUI, $SB_HORZ, False) But I'm still surprised that I actually have to force the horizontal scrollbar to be hidden. What's more, the horizontal scrollbar only appears with the first series (click 1 and 2) but doesn't appear at all with the second series, although all images are supposed to be displayed with the same width. What I mean is that no horizontal scrollbar should ever be needed, so I don't understand what makes the library think it has to show it eventually. Anyway, for now I can consider that this is a decent fix, thank you !
  19. Hi, I'm having an annoying display bug, I think I've found it (it's related to the use of scrollbars), but I'm unable to understand and fix it properly, so I hope you guys will enlighten me ! I have stripped my original program down to a minimal 80-lines version. It is available here for download : http://sagel.free.fr/BugTest.zip (just change the value of $Folder in line 4). The purpose of this program is very simple : select a series of stamp numbers in the list on the left, and their corresponding images will be displayed on the right. Normally, all stamps should be properly displayed with a 15 pixel interval between them, however you will see that it's not always the case. The bug can be reproduced like this : Click on the first series (the spacing is incorrect : the space between image 1 and image 2 is too thin)Click again on the first series (the spacing is now correct)Click on the second series (the spacing is incorrect : the space between image 1 and image 2 is too large)Click again on the second series (the spacing is now correct)If I comment the lines 74 and 75 (_GUIScrollBars instructions) then the spacing is correctly displayed, but of course I can't scroll the second series properly anymore... What's more, I'd like to get rid of that annoying horizontal scrollbar. I don't need it, and I'm fairly sure this is the cause of my problem. I need only the vertical scrollbar, because as you can see, all the images (whatever their original size) are proportionally reduced to a 360-pixel width for display. Thank you !
  20. OK, I managed to understand most of the code, but I still have a few questions : 1) Why are you using GUICtrlCreateInput over GUICtrlCreateEdit ? I guess it is more appropriate, but could you tell me why ? 2) I never really used accelerators/hotkeys until now, but I've read some documentation about HotKeySet. Why are you using an accelerator, wouldn't HotKeySet("key"[,"function"]) be able to link directly the ENTER key to _MyFunc ? 3) The $ES_NUMBER input style is pretty clever, but I'd like to input floating numbers as well (3.25 for example). Is there a similar "short" way to do it (involving a style) ? Thank you !
  21. Now that's funny, sorry for the mistake (edited by the way) Topic marked as solved, thank you !
  22. @Terenz : tested and looks pretty good, thank you for your quick answer and also for providing a full-code example.
  23. Hi, I know how to read an Edit control, check and process its content accordingly. But what I'm trying to achieve today is format the input of the control as soon as its content is validated (by getting the focus out of the Edit control). Let me explain with a few examples : 1) At first, my edit zone is empty. Enter the price : [ ] 2) The user inputs some correct value, then clicks another control OR presses ENTER. Enter the price : [ 3 ] I want the post-processing to do this as soon as the user selects another control : Enter the price : [ 3.00 € ] 3) The user inputs some incorrect value, then clicks another control OR presses ENTER. Enter the price : [ x ] I want the post-processing to display a MsgBox "Incorrect value" and put the focus back the the control Any idea how to automatically trigger this post-processing ? Thank you ! Faalamva
  24. I tested your example and it works just fine. I may be able to adapt my own programs to use it, thank you . (I will also check ff.au3 for comparison's sake).
×
×
  • Create New...