Gadoz Posted December 30, 2017 Share Posted December 30, 2017 (edited) Hey, I have a problem, which I can't solve yet... I want build a script, which allows me to save the mouse coordinates as a variable to work with them, if I'm pressing the Hotkey. My script won't start, If I'm pressing F5 on the SciTE Editor, no errors or something. Could someone help me? #RequireAdmin HotKeySet("{F9}", "Position") HotKeySet("{F8}", "Start") HotKeySet("{F11}", "End") Global $aPos = 0 Func Position() while 1 $aPos = MouseGetPos() wend EndFunc Func Start() MouseClick("Left", $aPos[0], $aPos[1]) EndFunc Func End () Exit EndFunc Edited December 30, 2017 by Gadoz Link to comment Share on other sites More sharing options...
Developers Jos Posted December 30, 2017 Developers Share Posted December 30, 2017 Let me guess: It does start but ends right away without doing anything... right? #RequireAdmin HotKeySet("{F9}", "Position") HotKeySet("{F8}", "Start") HotKeySet("{F11}", "End") Global $aPos = 0 Func Position() While 1 $aPos = MouseGetPos() WEnd EndFunc ;==>Position Func Start() MouseClick("Left", $aPos[0], $aPos[1]) EndFunc ;==>Start Func End() Exit EndFunc ;==>End Have a close look again at your script again! There is nothing to be done and it will reach the end right away. 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. Link to comment Share on other sites More sharing options...
Gadoz Posted December 30, 2017 Author Share Posted December 30, 2017 But why? I don't see the problem ... My logical way is: I start the Script. Now it is waiting for user actions. So if F9 is pressed, it saves the mousecoordinates through mousegetpos, under $aPos Everytime If I press F8, my mouse will go on the position which is saved under $aPos. Link to comment Share on other sites More sharing options...
Developers Jos Posted December 30, 2017 Developers Share Posted December 30, 2017 Where are you waiting? There is NO Func called at all! Jos Gadoz 1 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. Link to comment Share on other sites More sharing options...
Gadoz Posted December 30, 2017 Author Share Posted December 30, 2017 (edited) Thank you, this works now #RequireAdmin HotKeySet("{F9}", "Position") HotKeySet("{F8}", "Start") HotKeySet("{F11}", "End") Global $aPos = 0 Func Position() $aPos = MouseGetPos() EndFunc Func Start() MouseClick("Left", $aPos[0], $aPos[1]) EndFunc while 1 Sleep(50) WEnd Func End () Exit EndFunc Edited December 30, 2017 by Gadoz Link to comment Share on other sites More sharing options...
Gadoz Posted December 30, 2017 Author Share Posted December 30, 2017 (edited) Is this possible to get the MouseGetPos from the actual window and not from my whole resolution (1920x1080)? So the coordinates will always same, even I move the window. If yes, how can I do it, you can link me the help files Edited December 30, 2017 by Gadoz Link to comment Share on other sites More sharing options...
Developers Jos Posted December 30, 2017 Developers Share Posted December 30, 2017 Maybe: https://www.autoitscript.com/autoit3/docs/functions/AutoItSetOption.htm#MouseCoordMode Jos Gadoz 1 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. Link to comment Share on other sites More sharing options...
rudi Posted December 30, 2017 Share Posted December 30, 2017 @Jos may I ask, what "relative coords to the *client area* of the active window" means? Regards, Rudi. Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
Developers Jos Posted December 30, 2017 Developers Share Posted December 30, 2017 Just run this script and see the difference AutoItSetOption("MouseCoordMode",0) $ph=Run("Notepad.exe") Sleep(500) $aPos= WinGetPos("[ACTIVE]") ConsoleWrite("X-Pos: " & $aPos[0] & " Y-Pos: " & $aPos[1] & " Width: " & $aPos[2] & " Height: " & $aPos[3] & @CRLF) MouseMove(0,0) MsgBox(0,"MouseCoordMode 0","Pos (0,0)") AutoItSetOption("MouseCoordMode",2) MouseMove(0,0) MsgBox(0,"MouseCoordMode 2","Pos (0,0)") ProcessClose($ph) Jos Earthshine 1 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. Link to comment Share on other sites More sharing options...
Gadoz Posted December 30, 2017 Author Share Posted December 30, 2017 Is this possible to store 2-3 mousegetpos as variable with one Hotkeyset? I mean, evertime If I have pressed F9, mousegetpos will save the current position of my mouse. My script is actually doing: its just take only one mousegetpos - the always last one. Maybe I'm thinking logical wrong, and this is not working on autoit expect I create a new hotkey.. #RequireAdmin HotKeySet("{F9}", "Position") HotKeySet("{F8}", "Start") HotKeySet("{F11}", "End") Global $aPos = 0 Global $aPos1 = 0 Func Position() $aPos = MouseGetPos() $aPos1 = MouseGetPos() EndFunc Func Start() MouseClick("Left", $aPos[0], $aPos[1], 2) MouseClick("Left", $aPos1[0], $aPos1[1], 2) EndFunc while 1 Sleep(50) WEnd Func End () Exit EndFunc Link to comment Share on other sites More sharing options...
DynamicRookie Posted December 31, 2017 Share Posted December 31, 2017 ¡Hi Gadoz! Seems you're having problems? Try locating the While loop right after the HotKeySet statements. When you run the script, it saves the MousePosition before you ask for it, that's why you're having problems when saving the wanted coordenates. Try this script: #RequireAdmin Global $aPos = 0 Global $aPos1 = 0 HotKeySet("{F9}", "Position") HotKeySet("{F8}", "Start") HotKeySet("{F11}", "End") Call ("SleepForUser") Func SleepForUser() While 1 Sleep (100) WEnd EndFunc Func Position0() MsgBox (0, "Waiting for user", "Put your mouse at the wanted position to save Pos0" ) $aPos = MouseGetPos() MsgBox (0, "Waiting for user", "Put your mouse at the wanted position to save Pos1" ) $aPos1 = MouseGetPos() MsgBox(0, "Success", "Sucessfully saved mouse locations") Call("SleepForUser") EndFunc Func Start() MouseClick("Left", $aPos[0], $aPos[1], 2) MouseClick("Left", $aPos[0], $aPos1[], 2) Call ("SleepForUser") EndFunc Func End () Exit EndFunc It saves 2 different mouse locations: Generates 2 MSGBOXes After saving aPos functions it waits for user response. Hope that's what you need ¡Good luck and happy scripting! Gadoz 1 Link to comment Share on other sites More sharing options...
DynamicRookie Posted December 31, 2017 Share Posted December 31, 2017 3 minutes ago, DynamicRookie said: #RequireAdmin Global $aPos = 0 Global $aPos1 = 0 HotKeySet("{F9}", "Position") HotKeySet("{F8}", "Start") HotKeySet("{F11}", "End") Call ("SleepForUser") Func SleepForUser() While 1 Sleep (100) WEnd EndFunc Func Position0() MsgBox (0, "Waiting for user", "Put your mouse at the wanted position to save Pos0" ) $aPos = MouseGetPos() MsgBox (0, "Waiting for user", "Put your mouse at the wanted position to save Pos1" ) $aPos1 = MouseGetPos() MsgBox(0, "Success", "Sucessfully saved mouse locations") Call("SleepForUser") EndFunc Func Start() MouseClick("Left", $aPos[0], $aPos[1], 2) MouseClick("Left", $aPos[0], $aPos1[], 2) Call ("SleepForUser") EndFunc Func End () Exit EndFunc You may say: How i am suppossed to click the OK Button without moving my mouse? Simple, press ENTER key to press the OK button without the mouse. May sound obvious but some people dont know Hope it helped you Gadoz 1 Link to comment Share on other sites More sharing options...
careca Posted January 1, 2018 Share Posted January 1, 2018 (edited) On 12/30/2017 at 4:02 PM, Gadoz said: Is this possible to store 2-3 mousegetpos as variable with one Hotkeyset? I mean, evertime If I have pressed F9, mousegetpos will save the current position of my mouse. ;HotKeySet("{F9}", "Position") Position() Func Position() $aPos = MouseGetPos() $aPos1 = MouseGetPos() $aPos2 = MouseGetPos() MsgBox(64, '', $aPos[0]&' - '&$aPos[1]&@CRLF&$aPos1[0]&' - '&$aPos1[1]&@CRLF&$aPos2[0]&' - '&$aPos2[1]) EndFunc Sure but have no idea why store 2 or 3. Edited January 1, 2018 by careca Gadoz 1 Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
Earthshine Posted January 1, 2018 Share Posted January 1, 2018 Maybe he’s automating something on steam My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
DynamicRookie Posted January 3, 2018 Share Posted January 3, 2018 On 1/1/2018 at 3:43 PM, Earthshine said: Maybe he’s automating something on steam Maybe, but is better to don't assume anything without "IsArray = True" statements Link to comment Share on other sites More sharing options...
Earthshine Posted January 3, 2018 Share Posted January 3, 2018 (edited) Edited January 3, 2018 by Earthshine My resources are limited. You must ask the right questions 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