Griffin0001 Posted March 16, 2015 Posted March 16, 2015 Hi everyone, i have just finished my script, but when i run it on a different PC with a different size click coords change. I did an adjustment for clicking into the window, took the relative coords of the window i want it to click like that example: AutoItSetOption("MouseCoordMode",0) WinWait("program name") WinActivate("program name") MouseClick("primary", 211,322,1,5) But nothing changes so im just wondering what can be wrong.... i tryed many different things and nothing..... Can someone help me please???
TheSaint Posted March 17, 2015 Posted March 17, 2015 Welcome to the forum. However, you have posted in the wrong section, you want General Help & Support (GH&S). I have reported it to be relocated, so don't start another topic the same there, just wait for this to be relocated. P.S. meanwhile, you could look at WinGetPos, @DesktopHeight and @DesktopWidth etc in the Help file. Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)
Griffin0001 Posted March 17, 2015 Author Posted March 17, 2015 (edited) Thanks for your answer. But i tryed this options and still dont work, The strangest thing is that the width is adjusted but the height is not.... i dont understand why. Edited March 17, 2015 by Griffin0001
Sori Posted March 17, 2015 Posted March 17, 2015 (edited) I'll see if I can find some of my old code, but what I had previously done was, instead of using coordinates, I used the % of screen, for example... my laptop resolution is 1600x900, so instead of saying center is 800, 450. I would put 0.5 * @desktopWidth, 0.5 * @desktopHeight Another thing to make sure of, is that the program is running the same resolution on both computers. If you could provide us with the script that you're having issues with, that is a great help as well. Edited March 17, 2015 by Sori If you need help with your stuff, feel free to get me on my Skype. I often get bored and enjoy helping with projects.
Griffin0001 Posted March 17, 2015 Author Posted March 17, 2015 Thanks for the tip, I will try that but how to get the % of my screen?
Sori Posted March 17, 2015 Posted March 17, 2015 It's all in the mathematics for that one. You would have to do something like... "What % is coordinate of screen_resolution?" is % of 100 let's say 400 of my screen's width (1600) What % is_400 of_1600? 400 ? 1600 100 cross multiply 400 * 100 = 40,000 then divide 40,000 / 1600 = 25 25% or 0.25 If you need help with your stuff, feel free to get me on my Skype. I often get bored and enjoy helping with projects.
JohnOne Posted March 17, 2015 Posted March 17, 2015 A pixel is a pixel whatever resolution you are on. If you use positions relative to a window you should not have problems. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Griffin0001 Posted March 17, 2015 Author Posted March 17, 2015 Thanks for the answer, John i use positions realtive to a window and even that i still have that problem..... the problem is the hight of the window, thats the only thing that is not adjustet and cant understand why....
Griffin0001 Posted March 17, 2015 Author Posted March 17, 2015 Got the % but how to set it as a click ? can you write me an example please?
JohnOne Posted March 17, 2015 Posted March 17, 2015 If the height of the window is different, can you not just set the height to what you want? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Griffin0001 Posted March 17, 2015 Author Posted March 17, 2015 When i set it on my pc, it runs perfectly and has no problems, but when i use it on diferent pc the problem appears and cant find a solution and need the scripts running on friday..... dont know what to do to solve that.
JohnOne Posted March 17, 2015 Posted March 17, 2015 It's a really poor way of scripting application windows. What is the app, there is 99.99% chance of better way. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Griffin0001 Posted March 17, 2015 Author Posted March 17, 2015 Thats one of the script codes, im really new at that so dont laugh at the bad syntax and coding of the things but may help you to get me a solution. I really apreciate help. #RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseUpx=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** HotKeySet("{F2}", "stop") #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=c:usersform1.kxf $name = GUICreate("name", 663, 342, 192, 124) $Here = GUICtrlCreateButton("Here", 104, 296, 57, 33, $WS_GROUP) $Press = GUICtrlCreateLabel("Press", 32, 296, 54, 29) GUICtrlSetFont(-1, 15, 400, 0, "MS Sans Serif") $F2 = GUICtrlCreateButton("F2", 440, 296, 57, 33, $WS_GROUP) $Auto = GUICtrlCreateLabel("Auto", 32, 24, 75, 41) GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif") $name = GUICtrlCreateLabel("name", 128, 24, 156, 41) GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif") $to = GUICtrlCreateLabel("to", 176, 296, 20, 29) GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif") $START = GUICtrlCreateLabel("START", 208, 296, 71, 29) GUICtrlSetFont(-1, 15, 400, 0, "MS Sans Serif") $Label1 = GUICtrlCreateLabel("to", 524, 297, 20, 29) GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif") $STOP = GUICtrlCreateLabel("STOP", 568, 296, 60, 29) GUICtrlSetFont(-1, 15, 400, 0, "MS Sans Serif") $Pic1 = GUICtrlCreatePic("C:Users($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Here Func start () EndFunc While 1 AutoItSetOption("MouseCoordMode",0) WinWait("window name") WinActivate("window name") MouseClick("primary", 211,320,1,5) WinWait("window name") WinActivate("window name") MouseClick("primary", 377,326,1,5) Sleep(1500) Func stop () Exit 1 EndFunc WEnd Case $F2 "{F2}" Exit 1 EndSwitch WEnd
JohnOne Posted March 17, 2015 Posted March 17, 2015 First, you should not declare functions in a loop. Nor Options Here are some corrections to your code., but still you have not answered my question about your ultimate goal. This sort of messing around with mouse clicks is really for last resort coding, but if you insist upon it, you might also want to look at the option PixelCoordMode too. expandcollapse popup#RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseUpx=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** HotKeySet("{F2}", "stop") #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=c:\users\form1.kxf $name = GUICreate("name", 663, 342, 192, 124) $Here = GUICtrlCreateButton("Here", 104, 296, 57, 33, $WS_GROUP) $Press = GUICtrlCreateLabel("Press", 32, 296, 54, 29) GUICtrlSetFont(-1, 15, 400, 0, "MS Sans Serif") $F2 = GUICtrlCreateButton("F2", 440, 296, 57, 33, $WS_GROUP) $Auto = GUICtrlCreateLabel("Auto", 32, 24, 75, 41) GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif") $name = GUICtrlCreateLabel("name", 128, 24, 156, 41) GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif") $to = GUICtrlCreateLabel("to", 176, 296, 20, 29) GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif") $START = GUICtrlCreateLabel("START", 208, 296, 71, 29) GUICtrlSetFont(-1, 15, 400, 0, "MS Sans Serif") $Label1 = GUICtrlCreateLabel("to", 524, 297, 20, 29) GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif") $STOP = GUICtrlCreateLabel("STOP", 568, 296, 60, 29) GUICtrlSetFont(-1, 15, 400, 0, "MS Sans Serif") $Pic1 = GUICtrlCreatePic("C:\Users($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### AutoItSetOption("MouseCoordMode", 0); This does not belong in a loop like below While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Here While 1 WinWait("window name") WinActivate("window name") MouseClick("primary", 211, 320, 1, 5) WinWait("window name") WinActivate("window name") MouseClick("primary", 377, 326, 1, 5) Sleep(1500) WEnd Case $F2 ;"{F2}" Unsure what this is supposed to do Exit 1 EndSwitch WEnd Func stop() Exit 1 EndFunc ;==>stop Func start() EndFunc ;==>start What is the app, there is 99.99% chance of better way? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Griffin0001 Posted March 17, 2015 Author Posted March 17, 2015 Well the scripts im doing are for severall programs which need multiple daily clicking, so to avoid that we want to set a script to do it. But as it needs to run on several pcs we need to do that auto screen size set, so the clicks we make are at the same coords dispite the size change. Id just want to know if theres even a different way to do that program, maybe with the color od the buttons pressed or something. Ik that in java it can be made an option to automatically click dispite the resolution or the screen size but dont know how to set that func here.
JohnOne Posted March 17, 2015 Posted March 17, 2015 ControlClick etc... AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
mpower Posted March 23, 2015 Posted March 23, 2015 (edited) What sort of application are you trying to automate with Clicks? There might be an easier and more reliable way as Simulated Clicks and Key Presses are least accurate and not very reliant most of the time. Edited March 23, 2015 by mpower
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