Jump to content

andrewz

Active Members
  • Posts

    41
  • Joined

  • Last visited

andrewz's Achievements

  1. ​Wow thanks! That will probably fix the problem, as I am checking roughly 1000 pixels each run, which leads to a total sleep of 10.000 ?! That's exactly the delay I am talking about! God thanks there are geniuses like you, otherwise I would have never known about the hardcoded sleep nor how to fix it. Edit: Just realized if I had spent a little more time getting it to work without mousemove (Just checking the variable of the coordinates and look at each pixel by pixel, like "Do variable+1 until pixelgetcolor", I somehow messed up with the array mousegetpos resturns) it would have worked perfectly fine and I wouldnt have the trouble with the harcoded sleep ...
  2. ​The checkboxes are in fact all the same size, but the checkboxes are widely spread across the pdf, and on top of that I also gotta do textfields which vary in size which makes it impossible to pre measure. And regarding the accuracy, 1-2 pixels too much and it overlaps in the pdf viewer Dunno why this program doesnt have the auto selection-wand photoshop has, would be so useful! God thanks I gotta leave a little space to the borders with the textboxes, so I dont have to be as accure as 1 pixel on 800% zoom like I do with the checkboxes. (That's why it's so slow to make checkboxes, gotta view it on 800% zoom to be accure..., same goes to textfields which I view on 100% but they are 10 times bigger.) ​I attached a screen of a small part of the document including both check/text boxes. By really slow I mean like 10 - 15 seconds, depending on size. I'm already done with all the documents by now (actually a few hours after posting the thread), but I was interested in if this could be solved in a different, + faster way. All I need the script to do is search for two opposing edges in the squares and save the coordinates for the drag and drop tool. BTW, I don't actually need this anymore *for now*, it's all out of interest! If anyone knows an easier way of coding this, would appreciate any hint Thanks in advance & best regards, (Excuse my confusing English) Andrewz
  3. Hi, I am currently using a pdf converter to turn checkboxes from a document, written in word, into a pdf which can be filled out. Now I got like 100's of checkboxes and the programm only provides a manual drag and drop field for them. So I quickly made this: HotKeySet("c","Checkpixel") HotKeySet("{ESC}", "Terminate") While 1 Sleep(10) WEnd Func Checkpixel() Do MouseMove(MouseGetPos(0)-1,MouseGetPos(1),0) Until PixelGetColor(MouseGetPos(0),MouseGetPos(1)) = 0x000000 MouseMove(MouseGetPos(0)+1,MouseGetPos(1),0) Do MouseMove(MouseGetPos(0),MouseGetPos(1)-1,0) Until PixelGetColor(MouseGetPos(0),MouseGetPos(1)) = 0x000000 MouseMove(MouseGetPos(0)-1,MouseGetPos(1),0) Local $aPos = MouseGetPos() MouseMove(MouseGetPos(0)+1,MouseGetPos(1)+1,0) Do MouseMove(MouseGetPos(0)+1,MouseGetPos(1),0) Until PixelGetColor(MouseGetPos(0),MouseGetPos(1)) = 0x000000 MouseMove(MouseGetPos(0)-1,MouseGetPos(1),0) Do MouseMove(MouseGetPos(0),MouseGetPos(1)+1,0) Until PixelGetColor(MouseGetPos(0),MouseGetPos(1)) = 0x000000 MouseMove(MouseGetPos(0)+1,MouseGetPos(1),0) MouseMove(MouseGetPos(0)+1,MouseGetPos(1)+1,0) Local $bPos = MouseGetPos() MouseMove($aPos[0],$aPos[1],5) MouseDown("left") sleep(200) MouseMove($bPos[0],$bPos[1],5) MouseUp("left") sleep(200) MouseUp("left") sleep(100) WinWaitActive("Ankreuzfeld-Eigenschaften") ControlClick("Ankreuzfeld-Eigenschaften", "", "Button2") EndFunc Func Terminate() Exit EndFunc What it does: First you place the mouse inside a checkbox, then press the key and it will first move to the very left and then up to determine the starting point, then do the same to set the end-point. Finally drag and drop the checkbox field. Dunno if this solution is good, but atleast it works. Sadly it's rlly slow, probably cuz it's checking each pixel one by one whether or not it's black and continue... Is there any way to speed this up? I tried it without moving the mouse, just looking at the pixels, but couldnt get it to work so I just used the current solution because I didnt have time to figure it out at this point. (Dont have adobe acrobat pro here, neither am I allowed to install any other programms, autoit portable ftw) Thanks in advance & best regards, Andrewz
  4. Wow thank you! Your code looks 100x better than mine. It's so neat and perfect I didnt think that the _IELoadWait function would wait long enought, but apparently it does with the sanity pause you included, love it as it is also sooo fast now. And yeah I understand that creating an IE window every time, as well with the files is totally uneffective and slow, and really unreliably, as IE often prints errors in AutoIT on this older computer, dunno why. Will probably be a long way to go untill my code looks as neat as yours, but it's a fun doing this stuff in AutoIT raher than sitting here and doing this hotel exporting manually. (Damn school-forced-internship) The last thing I appreciate is the way you solved the thing with the Links.txt file. It seemed a bit complicated so I used the easy, but bad methode ^^. Best regards, Andrewz
  5. 1.+ 2. Because of the way this website loads, some kind of javascript or whatever - I don't know. Both of these wouldnt work. I solved it the way I did it in the above code. 3.) The sleep is for it to competly load. The website fully loads. Then there is a small loading popup with the mentioned way from step 1. and 2. . 4.) Because it doesnt matter if I overwrite them and I go through all pages, and then filter each page for the hotel links. Here is the full WORKING code: (If it is optimizable, feel free to correct me , thanks! ) #NoTrayIcon #include <IE.au3> #include <MsgBoxConstants.au3> #include <File.au3> #include <Inet.au3> FileDelete("Links.txt") _FileCreate("Edited.txt") _FileCreate("Links.txt") $timesran = 0 Do Global $url = "http://www.yelp.de/search?find_desc=Hotel&find_loc=Frankfurt+am+Main%2C+Hessen&cflt=hotels#start="&$timesran _IECreate($url) Sleep(5000) Local $oIE = _IECreate($url,1,1) Local $oLinks = _IELinkGetCollection($oIE) Local $iNumLinks = @extended Local $sTxt = $iNumLinks & " links found" & @CRLF & @CRLF For $oLink In $oLinks $sTxt &= $oLink.href & @CRLF Next FileWrite("Links.txt",$sTxt) $file = "Links.txt" FileOpen($file, 0) For $i = 1 to _FileCountLines($file) $line = FileReadLine($file, $i) If StringInStr($line,"http://www.yelp.de/biz/") = true Then $content = FileRead("Edited.txt") If StringInStr($content,$line) = false Then FileWrite("Edited.txt",$line & @CRLF) EndIf EndIf Next FileClose($file) FileOpen($file, 2) FileClose($file) WinKill("Suche in Hotel für Hotel – Frankfurt am Main, Hessen | Yelp - Internet Explorer") sleep(500) $timesran += 10 Until $timesran = "710" $msg=_FileCountLines ("Edited.txt") MsgBox(0,"",$msg)
  6. Doesnt make a difference, the displayed results are the same, I also tried it with : http://www.yelp.de/search?find_desc=Hotel&find_loc=Frankfurt+am+Main%2C+Hessen&cflt=hotels#start=10 which showed the same results and still didnt work. Might also be the PC here which uses some older IE version, and is kinda slow. The programm also opens all the links perfectly fine, but the collected links are always hotels 1 - 10 , dunno why it doesnt grab the ones which load after a few seconds. EDIT: Got it to work by removing the filedelete and filecreate function each time it repeats! It's screwing everything up The intention of deleting and recreating it was to lower the search time in the links file. Now I will just make it empty the file. Thanks for the ideas/help tho Just added this: FileOpen($file, 2) FileClose($file)
  7. Oh I still got "until timeran = 1000" from berlin, I switched to frankfurt tho. Frankfurth has 704 listed hotels on the site. http://www.yelp.de/search?find_desc=&find_loc=Frankfurt+am+Main%2C+Hessen&ns=1#find_desc=Hotel&start=0&cflt=hotels The order doesnt matter, aslong as all the links from page 1-71 are saved into a txt file. Yelp.de however has this different way of loading the results, why the usual collect link function didnt work untill I changed it to first run IE and load it, then take it if it already exists and grab all the links. Somehow this worked yesterday, and today suddently stopped working . &start=0 means page 1 &start=10 means page 2 and so on...you probably already understood that.
  8. Hmm I edited my last post with the full code, dunno why it worked yesterday. :/ Am I missing something ? Thanks in advance
  9. Did it display you the hotels 1-10 or 11-20 ? Maybe I should have posted more code: #NoTrayIcon #include <IE.au3> #include <MsgBoxConstants.au3> #include <File.au3> #include <Inet.au3> FileDelete("Links.txt") _FileCreate("Edited.txt") $timesran = 0 Do _FileCreate("Links.txt") Global $url = "http://www.yelp.de/search?find_desc=&find_loc=Frankfurt+am+Main%2C+Hessen&ns=1#find_desc=Hotel&start="&$timesran&"&cflt=hotels" _IECreate($url) Sleep(5000) Local $oIE = _IECreate($url,1,1) Local $oLinks = _IELinkGetCollection($oIE) Local $iNumLinks = @extended Local $sTxt = $iNumLinks & " links found" & @CRLF & @CRLF For $oLink In $oLinks $sTxt &= $oLink.href & @CRLF Next FileWrite("Links.txt",$sTxt) $file = "Links.txt" FileOpen($file, 0) For $i = 1 to _FileCountLines($file) $line = FileReadLine($file, $i) If StringInStr($line,"http://www.yelp.de/biz/") = true Then $content = FileRead("Edited.txt") If StringInStr($content,$line) = false Then FileWrite("Edited.txt",$line & @CRLF) EndIf EndIf Next FileClose($file) FileDelete("Links.txt") sleep(1000) $timesran += 10 Until $timesran = "1000" $msg=_FileCountLines ("Edited.txt") MsgBox(0,"",$msg)
  10. So I used it like this: Global $url = "http://www.yelp.de/search?find_desc=Hotels&find_loc=Berlin&ns=1#start="&$timesran&"&cflt=hotels" _IECreate($url) Sleep(5000) Local $oIE = _IECreate($url,1,1) Local $oLinks = _IELinkGetCollection($oIE) Local $iNumLinks = @extended I first use _IECreate to open the window cuz "yelp.de" doesnt load the items immediately, it first shows hotel 1-10 and then after a few seconds displays the ones from the next page. So if the variable $timesran would be "10" (That means page 2) , it would first completly load the page, then take the current, already opened IE window and store it inside the variable, and finally collect all the links. But, as of today this doesnt seem to work Is there any workaround to this, so that the programm would first wait for the page to not only load completly, but also load the items completly which are loaded usually 2-3 seconds afterwards. Try : http://www.yelp.de/search?find_desc=Hotels&find_loc=Berlin&ns=1#start=10&cflt=hotels Thanks in advance
  11. Doesnt matter which browser, I could use any. But thanks, will look into it
  12. Hello! I am currently facing a problem which I can't seem to be able to solve. What do I want to do with the script ? Extract all the links of the hotels on this website: http://www.yelp.de/search?cflt=hotels&find_loc=Berlin%2C+Germany For example the first link to the first hotel would be: http://www.yelp.de/biz/novum-hotel-city-b-berlin-zentrum-berlin - changes sometimes, so the link will be different. To start off, I tried to export only one hotel at first. I am using this code to read the content from the source and then get the content between two "functions" or whatever these are called: #NoTrayIcon #include <Inet.au3> #include <Array.au3> #include <String.au3> #include <AutoItConstants.au3> #include <MsgBoxConstants.au3> Global $url = "http://www.yelp.de/search?find_desc=Hotels&find_loc=Berlin&ns=1" Global $content = _INetGetSource($url) Global $string_A = _StringBetween($content, '<div class="media-avatar">', '</div>') MsgBox(0,"",$string_A[0]) It's part of an older project, which did almost the same thing, with the exeption that this one is not as easy The link is saved differently, and I can't find a way to export it. After it's saved into an array, I am going to save the links into a variable with a do - until function. But first I need this step working. Please, if anyone has an idea how to solve this, even the smallest help is appreciated!
  13. U could also do it this way: Count lenght --> divide it by 8 = x --> StringTrimRight by 8 x times and StringTrimLeft by times ran--> substract 1 from x -> Save into Array --> Do untill x = 0. There are so many possible ways, tho Malkey's solution looks like the "cleanest" and maybe is even the best resource wise. EDIT: Here u go, just with a massagebox tho... : #include <Array.au3> $string = "42383298472398472389472398472389" $lenght = StringLen($string) $timestorun = $lenght/8 $timesran = 0 Do $timestorun -= 1 $cut_A = $timestorun *8 $cut_B = $timesran *8 $string_A = StringTrimRight($string,$cut_A) $string_B = StringTrimLeft($string_A,$cut_B) $timesran += 1 MsgBox(0,"",$string_B) Until $timestorun = 0
×
×
  • Create New...