Ii) Move the window to that screen and put it in the middle of the screen by resizing it.Ĭ) If the window is NOT on this screen, increment the Local_screencounter so we can check the next screen on the next loop iteration. Add 1 to Local_screencounter to get to the next screen (to the right), but if the result is >SCREENCOUNTER() wrap back to screen 1. I) Compute the screen to move the window to. I decided to do it this way because I wasn’t sure what I wanted to do with moving a window that overlapped two screens between the screens…you might want to modify to suit your needs, perhaps by defining the screen a window is in by where the top left corner is. Note the present code requires that the entire window must be contained on the screen if a window overlaps two screens this condition will not be met. Loop through each screen (SCREENCOUNT() times):Ī) Check the listed conditions to see if the window (“frame”) is in the current screen. It runs from to 1 to SCREENCOUNT() the value 0 is always the Main screen but I ignore that as the main screen ALSO has an index in the above range. The variable Local_screencounter tracks which screen I am looking at in the subsequent loop. With this, I know where in the coordinate space that includes ALL screens the window is located. Saving this as text in a variable allows the elements of the frame (Left, Top, Right, Bottom) to be extracted in calculations. Get the “frame” of the front window (which is presumably the one I want to move). Note that the top left corner of the main screen is at (0,0). I don’t know how left to right is determined for vertically stacked screens, but seems to relate to the screen with the smaller coordinate for its left border (my external monitor above my laptop is much larger than the laptop screen which is centered below it and so its left border is at -872. Note that it is my understanding that in KM, the main screen is always index 0, and then the screens are numbered from left to right from 1 to SCREENCOUNT(). I am wondering if there is a way to determine this via AppleScript? I have found no function or token that returns the screen a given window is on, as of yet. I can think of kludgy ideas like trying to get the dimensions of the screen the window is on and comparing to the dimensions of very screen to figure out where the window is, but obviously that is not a robust solution and of course fails if you have two screens with the same dimension. However, I would also like to be able to shift windows from one screen to another, and I have not been able to find a method for doing this.Īs far as I have been able to discover thus far, KM provides the facility to find out the number of screen, and to specify a screen to move a window to (either by number or by keyword tokens such as Main, External, Front, etc), but I cannot find a way to find out which screen a window is currently on to thereby determine what screen to move it to. I have the macros do said movement on the screen that the window is currently on. I put together a series of macros (a la David S) to move windows around - left side, right side, top, bottom, the four corners.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |