andrewz Posted May 21, 2015 Posted May 21, 2015 (edited) Hi,I am currently using a pdf converter to turn checkboxes from a document, written in word, into a pdf whichcan be filled out. Now I got like 100's of checkboxes and the programm only provides a manual drag anddrop field for them. So I quickly made this: expandcollapse popupHotKeySet("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 leftand 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 onewhether 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 towork 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 Edited May 21, 2015 by andrewz
spudw2k Posted May 21, 2015 Posted May 21, 2015 I can appreciate the accuracy required to do this task (measuring pixels), but I'd say one quick way to improve the speed would be to pre-measure the checkbox dimensions. I'm making an assumption that the checkboxes are standard controls and don't very in shape and size. Now, the layout and dpi may vary between systems, but hopefully this type if task is a "quick n dirty" solution you only have to run from one machine. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
AndyG Posted May 22, 2015 Posted May 22, 2015 Hi,can you post a screenshot to explain the whole workflow?What do you mean by "really slow"? After placing the mousecursor into a checkbox and pressing the "c"-key, the script is looking for (and find) the borders and finally "drag&drop" within 200milliseconds...
andrewz Posted May 22, 2015 Author Posted May 22, 2015 (edited) I can appreciate the accuracy required to do this task (measuring pixels), but I'd say one quick way to improve the speed would be to pre-measure the checkbox dimensions. I'm making an assumption that the checkboxes are standard controls and don't very in shape and size. Now, the layout and dpi may vary between systems, but hopefully this type if task is a "quick n dirty" solution you only have to run from one machine.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.) Hi,can you post a screenshot to explain the whole workflow?What do you mean by "really slow"? After placing the mousecursor into a checkbox and pressing the "c"-key, the script is looking for (and find) the borders and finally "drag&drop" within 200milliseconds... 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 besolved in a different, + faster way. All I need the script to do is search for two opposing edges in the squares and save the coordinatesfor 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 Edited May 22, 2015 by andrewz
Zedna Posted May 22, 2015 Posted May 22, 2015 (edited) To speed up MouseMove/MouseClick look at my MouseClickFast, MouseMoveFast Edited May 22, 2015 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
andrewz Posted May 22, 2015 Author Posted May 22, 2015 (edited) To speed up MouseMove/MouseClick look at my MouseClickFast, MouseMoveFast 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 ... Edited May 22, 2015 by andrewz
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now