Hello,
Lets say that i want to use the CoordMode, for example as follow:
CoordMode, Mouse ,Screen
MouseGetPos, MX, MY
....SOME CODE......
Now, lets say that i want to go back to DEFAULT Coordmode mode.
How can i do it, please?
How can we go back to DEFAULT Coordmode mode?
Re: How can we go back to DEFAULT Coordmode mode?
Use Window instead of Screen.
Re: How can we go back to DEFAULT Coordmode mode?
Thank you very much,
So:
CoordMode, Mouse ,Screen
MouseGetPos, MX, MY
....SOME CODE......
CoordMode, Mouse ,Window
The last line --> CoordMode, Mouse ,Window ---> will force the SCRIPT to go back to DEFAULT state, that is to the state it was before using the CoordMode, Mouse ,Screen
But, in a case i will use the RETURN instead of the CoordMode, Mouse ,Window, for example as follow:
CoordMode, Mouse ,Screen
MouseGetPos, MX, MY
....SOME CODE......
RETURN
Will this result to the same, that is ------> will this result the SCRIPT to go back to DEFAULT state, that is to the state it was before using the CoordMode, Mouse ,Screen ?
So:
CoordMode, Mouse ,Screen
MouseGetPos, MX, MY
....SOME CODE......
CoordMode, Mouse ,Window
The last line --> CoordMode, Mouse ,Window ---> will force the SCRIPT to go back to DEFAULT state, that is to the state it was before using the CoordMode, Mouse ,Screen
But, in a case i will use the RETURN instead of the CoordMode, Mouse ,Window, for example as follow:
CoordMode, Mouse ,Screen
MouseGetPos, MX, MY
....SOME CODE......
RETURN
Will this result to the same, that is ------> will this result the SCRIPT to go back to DEFAULT state, that is to the state it was before using the CoordMode, Mouse ,Screen ?
Re: How can we go back to DEFAULT Coordmode mode?
If you want to go back to whatever the previous coord mode was without knowing what it was, you can do this:
It doesn’t matter if you use a Return or not because you’re only affecting the current thread anyway. If your code was a new thread, you didn’t affect the coord mode of the thread it interrupted.
Restoring it to the prior state is good for functions which could be called from various places in a script that could have set the coord mode differently and would like to continue as if it weren’t changed. It’s also good for writing general-use functions so that they are good citizens and don’t disrupt the script’s settings when the script may not be aware of potential changes and not expecting them to change.
Code: Select all
PrevCoordModeMouse := A_CoordModeMouse
CoordMode, Mouse ,Screen
MouseGetPos, MX, MY
....SOME CODE......
CoordMode, Mouse, % PrevCoordModeMouse
It doesn’t matter if you use a Return or not because you’re only affecting the current thread anyway. If your code was a new thread, you didn’t affect the coord mode of the thread it interrupted.
Restoring it to the prior state is good for functions which could be called from various places in a script that could have set the coord mode differently and would like to continue as if it weren’t changed. It’s also good for writing general-use functions so that they are good citizens and don’t disrupt the script’s settings when the script may not be aware of potential changes and not expecting them to change.
Re: How can we go back to DEFAULT Coordmode mode?
Thank you very much!
Who is online
Users browsing this forum: peter_ahk and 168 guests