555444447777 Posted September 15, 2015 Share Posted September 15, 2015 Hi guys, so after hours of research i found an example and i made it work for me.It basically uses pixelsearch to find three different buttons and clicks it one after each other.I am asking for help, for two different functioncs i wasnt able to implement:Adding a hotkey: for example i can press button in the windows, or let say: F1 and it will do the same thing.Other one: after i click button YES it clicks my 3buttons on website, and then can my mouse pointer return to the same position ? i mean to button YESI found some details on wiki, but when i add extra lines script stops working. expandcollapse popup; A simple custom messagebox that uses the OnEvent mode #include <Constants.au3> #include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) Global $g_idExit _Main() Func _Main() Local $idYes GUICreate("Custom MsgBox", 210, 80) GUICtrlCreateLabel("Please click a button!", 10, 10) $idYes = GUICtrlCreateButton("Yes", 10, 50, 50, 20) GUICtrlSetOnEvent($idYes, "OnYes") $g_idExit = GUICtrlCreateButton("Exit", 150, 50, 50, 20) GUICtrlSetOnEvent($g_idExit, "OnExit") GUISetOnEvent($GUI_EVENT_CLOSE, "OnExit") GUISetState() ; display the GUI While 1 Sleep(1000) WEnd EndFunc ;==>_Main ; --------------- Functions --------------- Func OnYes() ; Pirmas klikas $coord = PixelSearch(1050, 400, 1088, 723, 0xB8A688, 5) If Not @error Then MouseClick("primary", $coord[0], $coord[1], 1, 0) EndIf ; Antras klikas Sleep ( 25 ) $coord = PixelSearch(1050, 510, 1088, 723, 0xB8A688, 5) If Not @error Then MouseClick("primary", $coord[0], $coord[1], 1, 0) EndIf ; Trecias klikas Sleep ( 25 ) $coord = PixelSearch(700, 510, 900, 723, 0xB8A688, 5) If Not @error Then MouseClick("primary", $coord[0], $coord[1], 1, 0) EndIf EndFunc ;==>OnYes Func OnExit() If @GUI_CtrlId = $g_idExit Then Else EndIf Exit EndFunc ;==>OnExit Link to comment Share on other sites More sharing options...
Jfish Posted September 15, 2015 Share Posted September 15, 2015 (edited) Have you looked at the help file for the word "hotkey"?HotKeySet ( "key" [, "function"] )Your "Yes" button looks like it is wired to the OnYes() function. If there is no error then it will click the "primary" mouse button (left unless swapped) at the coordinates it got from the PixelSearch. The coordinates will only be returned on a successful search (where you get a 2d array back). If you error on that function you get an error flag. You can add what happens if the pixelsearch works and what happens if it did not. You can use mousemove to move the mouse wherever you want. MouseGetPos can get you the info on where the starting position is for the mouse before you start to move it.All of these things are in the help file. Edited September 15, 2015 by Jfish Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt Link to comment Share on other sites More sharing options...
555444447777 Posted September 15, 2015 Author Share Posted September 15, 2015 (edited) When i add hotkeyset function it doest work, but i found an example which i edited and it works:i just dont get it why i doesnt work when i add in my script. why is ther an include function here?#include <MsgBoxConstants.au3> ; Press Esc to terminate script, Pause/Break to "pause" Global $g_bPaused = False HotKeySet("{TAB}", "HotKeyPressed") HotKeySet("{ESC}", "HotKeyPressed") HotKeySet("+!d", "HotKeyPressed") ; Shift-Alt-d While 1 Sleep(100) WEnd Func HotKeyPressed() ; Pirmas klikas $coord = PixelSearch(1050, 400, 1088, 723, 0xB8A688, 5) If Not @error Then MouseClick("primary", $coord[0], $coord[1], 1, 0) EndIf ; Antras klikas Sleep ( 25 ) $coord = PixelSearch(1050, 510, 1088, 723, 0xB8A688, 5) If Not @error Then MouseClick("primary", $coord[0], $coord[1], 1, 0) EndIf ; Trecias klikas Sleep ( 25 ) $coord = PixelSearch(700, 510, 900, 723, 0xB8A688, 5) If Not @error Then MouseClick("primary", $coord[0], $coord[1], 1, 0) EndIf EndFunc ;==>HotKeyPressed Edited September 15, 2015 by sHarma Link to comment Share on other sites More sharing options...
Jfish Posted September 15, 2015 Share Posted September 15, 2015 All three of the hotkeys you are using call the same function which will do nothing except return an @error code if the pixel is not found. The #include is for MsgBoxConstants (look at MsgBox in the help file). The first parameter of a message box dictates the type of message box and the buttons. That include is mapping those numeric values that don't make sense in the abstract (i.e. 0) to something that is human readable (i.e. $MB_OK). Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt Link to comment Share on other sites More sharing options...
555444447777 Posted September 15, 2015 Author Share Posted September 15, 2015 I am sorry but please talk in a simple language, i am not a programmer and i simply dont understand why you are saying. Let say i have two scripts, they are working, when i put them together in one script it doesnt work why??here i post the script:expandcollapse popup; A simple custom messagebox that uses the OnEvent mode #include <Constants.au3> #include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) Global $g_idExit _Main() Func _Main() Local $idYes GUICreate("Custom MsgBox", 210, 80) GUICtrlCreateLabel("Please click a button!", 10, 10) $idYes = GUICtrlCreateButton("Yes", 10, 50, 50, 20) GUICtrlSetOnEvent($idYes, "OnYes") $g_idExit = GUICtrlCreateButton("Exit", 150, 50, 50, 20) GUICtrlSetOnEvent($g_idExit, "OnExit") GUISetOnEvent($GUI_EVENT_CLOSE, "OnExit") GUISetState() ; display the GUI While 1 Sleep(1000) WEnd EndFunc ;==>_Main ; --------------- Functions --------------- Func OnYes() ; Pirmas klikas $coord = PixelSearch(1050, 400, 1088, 723, 0xB8A688, 5) If Not @error Then MouseClick("primary", $coord[0], $coord[1], 1, 0) EndIf ; Antras klikas Sleep ( 25 ) $coord = PixelSearch(1050, 510, 1088, 723, 0xB8A688, 5) If Not @error Then MouseClick("primary", $coord[0], $coord[1], 1, 0) EndIf ; Trecias klikas Sleep ( 25 ) $coord = PixelSearch(700, 510, 900, 723, 0xB8A688, 5) If Not @error Then MouseClick("primary", $coord[0], $coord[1], 1, 0) EndIf EndFunc ;==>OnYes Func OnExit() If @GUI_CtrlId = $g_idExit Then Else EndIf Exit EndFunc ;==>OnExit #include <MsgBoxConstants.au3> ; Press Esc to terminate script, Pause/Break to "pause" Global $g_bPaused = False HotKeySet("{TAB}", "HotKeyPressed") HotKeySet("{ESC}", "HotKeyPressed") HotKeySet("+!d", "HotKeyPressed") ; Shift-Alt-d While 1 Sleep(100) WEnd Func HotKeyPressed() ; Pirmas klikas $coord = PixelSearch(1050, 400, 1088, 723, 0xB8A688, 5) If Not @error Then MouseClick("primary", $coord[0], $coord[1], 1, 0) EndIf ; Antras klikas Sleep ( 25 ) $coord = PixelSearch(1050, 510, 1088, 723, 0xB8A688, 5) If Not @error Then MouseClick("primary", $coord[0], $coord[1], 1, 0) EndIf ; Trecias klikas Sleep ( 25 ) $coord = PixelSearch(700, 510, 900, 723, 0xB8A688, 5) If Not @error Then MouseClick("primary", $coord[0], $coord[1], 1, 0) EndIf EndFunc ;==>HotKeyPressed Link to comment Share on other sites More sharing options...
Jfish Posted September 15, 2015 Share Posted September 15, 2015 Language barriers aside, my answers were in direct response to your questions. I am not going to re-write it for you. I think you should start by learning some of the basics. I would read the help file (I think I may have mentioned that in each of my responses). I have never done this before, to reference this link in a response, but I will let you know that there is a book in my signature that is for beginners - to teach you how to code. If you want to understand the solution you need to invest a little bit of effort. Somebody else might just do it for you and show you how to get it working but most people would want to see you at least try to understand the concepts.To answer your last question - all you did was include the same function again with a different name and tie them to hotkeys instead of buttons. The same exact thing will happen when you push a button or a hotkey. If it does not find the pixel that thing will be nothing (aside from producing an error code). Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt Link to comment Share on other sites More sharing options...
555444447777 Posted September 15, 2015 Author Share Posted September 15, 2015 I understand what you are saying, but as i said i have no programming experence i spent two days researching and i have a code working for me what i need, i am not going to be a programmer, am not going to asociate my life with it, i work in completely different field, and just asking for a minute to look around. Ask me about woodworking and i i will tell you all the answers in a minute. Yes, i just copied and put two scripts in one file, when i press the button the script works, but when i press the HOTKEY it doesnt? why is that? you said yourself that it should work. Link to comment Share on other sites More sharing options...
Jfish Posted September 15, 2015 Share Posted September 15, 2015 You don't think I have been responsive to all your questions? Really? you said yourself that it should work.Where did I say that?Let me ask this: which program you are trying to automate with that script? There may be a better way. Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt Link to comment Share on other sites More sharing options...
555444447777 Posted September 15, 2015 Author Share Posted September 15, 2015 I dont say you dont response to my questions, lets not make it a drama okay?I mean that you are writing very technical things which simply i dont get, because this type of area is not mine, i work with different things, thats what i know.Its simply a website, which is very uncomfortable, and its made for goverment taxes to fill up, so i want to automate instead of searching for blanks to fill, autoit will find it and click i fill them and go next.Again, do you know why in my script it doesnt work this way as you said: The same exact thing will happen when you push a button or a hotkey. Link to comment Share on other sites More sharing options...
Jfish Posted September 15, 2015 Share Posted September 15, 2015 What is the URL to the site? Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt Link to comment Share on other sites More sharing options...
555444447777 Posted September 16, 2015 Author Share Posted September 16, 2015 (edited) It's a closed website which you can access only logging in. Edited September 16, 2015 by sHarma Link to comment Share on other sites More sharing options...
Jfish Posted September 16, 2015 Share Posted September 16, 2015 A closed website for government taxes? That is strange. What is the URL to log into it? I only ask because you can automate websites a whole different way. It could be much easier than you current approach. Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt Link to comment Share on other sites More sharing options...
algiuxas Posted September 17, 2015 Share Posted September 17, 2015 Hi guys, so after hours of research i found an example and i made it work for me.It basically uses pixelsearch to find three different buttons and clicks it one after each other.I am asking for help, for two different functioncs i wasnt able to implement:Adding a hotkey: for example i can press button in the windows, or let say: F1 and it will do the same thing.Other one: after i click button YES it clicks my 3buttons on website, and then can my mouse pointer return to the same position ? i mean to button YESI found some details on wiki, but when i add extra lines script stops working. expandcollapse popup; A simple custom messagebox that uses the OnEvent mode #include <Constants.au3> #include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) Global $g_idExit _Main() Func _Main() Local $idYes GUICreate("Custom MsgBox", 210, 80) GUICtrlCreateLabel("Please click a button!", 10, 10) $idYes = GUICtrlCreateButton("Yes", 10, 50, 50, 20) GUICtrlSetOnEvent($idYes, "OnYes") $g_idExit = GUICtrlCreateButton("Exit", 150, 50, 50, 20) GUICtrlSetOnEvent($g_idExit, "OnExit") GUISetOnEvent($GUI_EVENT_CLOSE, "OnExit") GUISetState() ; display the GUI While 1 Sleep(1000) WEnd EndFunc ;==>_Main ; --------------- Functions --------------- Func OnYes() ; Pirmas klikas $coord = PixelSearch(1050, 400, 1088, 723, 0xB8A688, 5) If Not @error Then MouseClick("primary", $coord[0], $coord[1], 1, 0) EndIf ; Antras klikas Sleep ( 25 ) $coord = PixelSearch(1050, 510, 1088, 723, 0xB8A688, 5) If Not @error Then MouseClick("primary", $coord[0], $coord[1], 1, 0) EndIf ; Trecias klikas Sleep ( 25 ) $coord = PixelSearch(700, 510, 900, 723, 0xB8A688, 5) If Not @error Then MouseClick("primary", $coord[0], $coord[1], 1, 0) EndIf EndFunc ;==>OnYes Func OnExit() If @GUI_CtrlId = $g_idExit Then Else EndIf Exit EndFunc ;==>OnExit You should look at ControlClick. After switching years ago to Linux, sadly I don't use AutoIt anymore. Link to comment Share on other sites More sharing options...
555444447777 Posted September 17, 2015 Author Share Posted September 17, 2015 (edited) A closed website for government taxes? That is strange. What is the URL to log into it? I only ask because you can automate websites a whole different way. It could be much easier than you current approach.Its not closed, i mean you need a log in to access it, you wont see anything until you log on. What other ways are there possible? thanks Algiuxs i saw that there is a possibility for autoit to click on button with certain idi found this script:$oBtn = _IEGetObjById($oIE, "MyButton") _IEAction($oBtn, "click")Is right? somehow it gives me an error. Edited September 17, 2015 by sHarma Link to comment Share on other sites More sharing options...
ViciousXUSMC Posted September 17, 2015 Share Posted September 17, 2015 sHarma - As mentioned for web automation there are much better ways, but they are not really simple. As a "passer by" trying to take blocks of code from different examples and put them together into a working script you probably will not have much luck.Even though this is not your thing, its going to take some considerable time/effort to learn enough to really work with it. Just like if I wanted to carve a wood statue, it may only be the one time I ever do it but I am still going to have to take the time and acquire those skills before it can be done.I have no idea how "dynamic" this page is. As if the fields are always in the same order, with the same number of them. If so I think you may find Send() easier to work with than any kind of PixelSearch() even for buttons you should be able to use keyboard shortcuts to navigate and interact with the page. Last block of code I saw was 3 hotkeys, you assigned all 3 of them the same function "HotKeyPressed" thats the issue that was pointed out. To get from where you are to where you want to be, the more information you can provide the better. What is the interaction your trying to do? (simple clicks, some typing, etc) maybe a screenshot of the site can be post, or maybe even the source code of the site itself. Take care to not expose anything that you can't legally or morally post but without something to look at, you wont get much help from a blind programmer. Link to comment Share on other sites More sharing options...
555444447777 Posted September 17, 2015 Author Share Posted September 17, 2015 Hi there.I spend all day today searching, and i found something that could help me:Three different image buttons in the website, in different areas everytime, click one by one on all three of them, i found such function as IEimgclick and controclick, its in the browser, as i understand the AutoIT script can find a button by ID on the website click it, then click sencond button, then third button thats it.I tired this script: without any luck:Local $oIE = "Internet Explorer_Server" _IEImgClick($oIE, "ctl00$contentPlaceholder$CurrentSalesList$gvCurrentSales$ctl02$btnEdit", "id") ; "name" is still equivalent for HTML5 pagesBasically there are 3 images that work as button, they have unique ids, is it possible to click on them? I press TAB button on keyboard and i get three click on the image button with ids i wrote. Link to comment Share on other sites More sharing options...
Jfish Posted September 17, 2015 Share Posted September 17, 2015 (edited) @sHarma - I would encourage you to post the link that you sent to me in an PM on this thread. It appears to be for access to the Lithuanian Ministry of the Environment and is a lumber trading platform for auctions (not a government tax site). It would be helpful if everyone could see the page - they can even look at the source code and guide you as to what information would be helpful to assist you. I also agree 100% with this (which is what I have been saying):Even though this is not your thing, its going to take some considerable time/effort to learn enough to really work with it. Just like if I wanted to carve a wood statue, it may only be the one time I ever do it but I am still going to have to take the time and acquire those skills before it can be done. Edited September 17, 2015 by Jfish Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt Link to comment Share on other sites More sharing options...
555444447777 Posted September 17, 2015 Author Share Posted September 17, 2015 If you would come to asking for that help, i would give few videos, explain how its done, and even let you borrow tools. I would never say: you go alone and try to find what you need, you need to put some work in it.I am asking a different question here, please dont state your personal opinion, its not an emotional discussion board.Three different image buttons in the website, in different areas everytime, click one by one on all three of them, i found such function as IEimgclick and controclick, its in the browser, as i understand the AutoIT script can find a button by ID on the website click it, then click sencond button, then third button thats it.I tired this script: without any luck:Local $oIE = "Internet Explorer_Server" _IEImgClick($oIE, "ctl00$contentPlaceholder$CurrentSalesList$gvCurrentSales$ctl02$btnEdit", "id") ; "name" is still equivalent for HTML5 pagesBasically there are 3 images that work as button, they have unique ids, is it possible to click on them? I press TAB button on keyboard and i get three click on the image button with ids i wrote. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 17, 2015 Moderators Share Posted September 17, 2015 sHarma,People are trying to help - responding like that is not going to help your case.Why not post the page link? What harm can it do? If you want help, offering as much information as possible is usually a good idea.M23 555444447777 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
555444447777 Posted September 17, 2015 Author Share Posted September 17, 2015 Its a html page, thats all, i want to use on different pages, so it simply doesnt matter. I am asking for the main thing, rest i will do myself. thank you.its a goverment page, i cant post it.What i am trying to achieve:I keep my website open, when i click TAB button on keyboard, autoit find the image button with id:opa then clicks it, then find image button with id:popa clicks it, then find image button with id: pup clicks it. thats it. Link to comment Share on other sites More sharing options...
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