Kenshi Posted May 29, 2019 Posted May 29, 2019 (edited) Hello, im trying to make a code that will open my notepad and then right click in the notepad client area accordingly to my coords (x and y) If i use : ControlClick($hWnd, "","","Right",1,245, 155) that works perfectly, script opens notepad and right clicks in the client area at the specified coords. However what if i want the x and y coords to be variables ? Because if something that im looking for is consistently changing inside the notepad client area i want to use variables for x and y coords so the controlclick always clicks correctly. I honestly just dont know how can i use ControlClick coords parameters as in variables. I managed to do that with MouseClick and its working but i want to use ControlClick. I tried this and its not working : ControlClick($hWnd, "","","Right",1,x$pos y$pos) This is whole script : Example() Func Example() ; Run Notepad Run("notepad.exe") ; Wait 3 seconds for the Notepad window to appear. WinWait("[CLASS:Notepad]", "", 3) Local $hWnd = WinGetHandle("[CLASS:Notepad]") MsgBox(0,"Alert","Move mouse to desired location") $pos = MouseGetPos() Sleep(5000) ControlClick($hWnd, "","","Right",1,x$pos y$pos) ; Wait for 5 seconds. Sleep(5000) ; Close the Notepad window using the handle returned by WinWait. WinClose($hWnd) EndFunc ;==>Example Can someone help ? Spoiler Edited May 29, 2019 by Kenshi
BrewManNH Posted May 29, 2019 Posted May 29, 2019 Don't post screenshots of your code, that helps no one, post the text of the code, use the "< >" in the editor to add code to a post. Second, you forgot the $ before the variable names in your controlclick. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
Kenshi Posted May 29, 2019 Author Posted May 29, 2019 I did try to put the $at variables but it didnt work either.. Thanks for the info about the "<>", edited the post too many times (i think ? ) and i cant delete the screenshots now lol
BrewManNH Posted May 29, 2019 Posted May 29, 2019 ControlClick($hWnd, "","","Right",1,$pos[0], $pos[1]) If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
Kenshi Posted May 29, 2019 Author Posted May 29, 2019 So that actually works but it seems that everytime i run the script it clicks 3-4cm on screen left to where my mouse is. Thats pretty weird..
Developers Jos Posted May 29, 2019 Developers Posted May 29, 2019 30 minutes ago, Kenshi said: So that actually works but it seems that everytime i run the script it clicks 3-4cm on screen left to where my mouse is. Thats pretty weird.. How do you know as you are clicking on controls unless it is still about the previous topic which I closed and trying to deal with an Browser window. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Kenshi Posted May 29, 2019 Author Posted May 29, 2019 1 minute ago, Jos said: How do you know as you are clicking on controls unless it is still about the previous topic which I closed and trying to deal with an Browser window. Jos I created a variable that reads my mouse position = $pos = MouseGetPos And i know because i keep the window open because i purely just want to see how controlclick works, and i dont have any mean dark terrible thoughts that you might think of. Its not about the other topic, however i do not understand why you sometimes force the truth of the users that come here and ask for help, you go deep in why they want to create this and that so that you are sure they are not trying any game automation. I think its good that you do not offer support/help for someone that tries to violate rules, but in the same time you should not deny a user the opportunity of simply asking for help and wanting to know how the language works. (this is my opinion based on several posts i have seen in this forum) Speaking of controls, i also tried to click the "Edit" button in notepad but it didnt work, i spend like 30 minutes on it then opened Autoit Windows Info, hovered over the edit button adn realised that the tool doesnt read anything, so it s probably why it didnt work in the first place...so i changed to client area. (Would appreciate help on the Controls if you can give any) Thanks !
BrewManNH Posted May 29, 2019 Posted May 29, 2019 Add this to the top of the script, and see where it clicks now. opt("MouseCoordMode", 0) Why are you trying to use the mouse to navigate the menus, there are functions specifically for those. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
Kenshi Posted May 29, 2019 Author Posted May 29, 2019 (edited) 9 minutes ago, BrewManNH said: Add this to the top of the script, and see where it clicks now. opt("MouseCoordMode", 0) Why are you trying to use the mouse to navigate the menus, there are functions specifically for those. That made it much better, now it didnt click 3-4 cm to left but like 1-2 cm down of the mouse. But i think that was because MouseCoordMode 0 gives relative coords to the active windows ( didnt know until u came up with this idea and i googled the function ). So i changed that to 2 and now it right clicks in the same spot i have my mouse Thank you ! Edit: I didnt know i have special functions for menu navigation, will sure look into that ! Thanks again ! Edited May 29, 2019 by Kenshi
Developers Jos Posted May 29, 2019 Developers Posted May 29, 2019 1 hour ago, Kenshi said: Its not about the other topic, however i do not understand why you sometimes force the truth of the users that come here and ask for help, you go deep in why they want to create this and that so that you are sure they are not trying any game automation. I seem to remember that it was you whom said it was for a game without asking, so really fail to understand this attack towards me... and let's face it, this questions isn't much different so why would I not think it is simply a rephrased question similar to that thread? So let's not play this "game" here nor try to assume the victim role as it is not appropriate in this case. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Kenshi Posted May 29, 2019 Author Posted May 29, 2019 It's not really an attack, i just stated my opinion...and if u read the paranthesis again, i said that is my opinion based on the several posts i have seen in this forum, not mine. My case was different : I acknowledged my mistake for not reading the rules and for requesting support for a game automation script. Moreover, what if i actually wanted to learn how the ControlClick command works ? Maybe i wanted to see how it does differ from MouseClick or from whatever else command. Maybe, since we all think diffrently, it is of very much help to me if i know something more in-depth about the respective command that it is for you, maybe i get different ideas and i create something totally different as opposed to what i would have created otherwise, without your help. Thats what i saw in other posts as well : Nitpicking someone so you can get every thought of what how and why they're doing it. By "you" i dont mean necessarily only you, and this is purely my opinion. Since i did stay respectful when i broke the rules, admitted it and stated that we got off on a wrong foot. I wont continue this and i would like to get the same respect back. This topic can be closed, i thank BrewManNH once again for the help he actually gave me ! Thank you !
Developers Jos Posted May 29, 2019 Developers Posted May 29, 2019 Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
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