Skip to main content
deleted 8 characters in body
Source Link
user3439894
  • 59.8k
  • 10
  • 112
  • 135

I want to move the position of a current window 5 pixels up, and 5 pixels right.

I do not have RStudio, however, here is an example using Google Chrome.

Example AppleScript code:

if not running of application "Google Chrome" then
    return
tell application "System Events"
        tell application process "Google Chrome"
            if not (exists window 1) then
        return
        set |position| to position of window 1
                set position of window 1 to ¬
                    {((item 1 of |position|) + 5), ((item 2 of |position|) - 5)}
            end if
        end tell
    end tell
end if

Notes:

Since you didn't state how you intended to implement the AppleScript code, I've included some error handling that may not be necessary, e.g. if not running of application "Google Chrome" then return block. (Or whichever application you set it for.)

Once a window had been repositioned to where it meets the bottom of the menu bar, or top of the screen if the menu bar is hidden, it will no longer move upwards and will only continue to move to the right.



Note: The example AppleScript code is just that and sans any included error handling does not contain any additional error handling as may be appropriate. The onus is upon the user to add any error handling as may be appropriate, needed or wanted. Have a look at the try statement and error statement in the AppleScript Language Guide. See also, Working with Errors. Additionally, the use of the delay command may be necessary between events where appropriate, e.g. delay 0.5, with the value of the delay set appropriately.

I want to move the position of a current window 5 pixels up, and 5 pixels right.

I do not have RStudio, however, here is an example using Google Chrome.

Example AppleScript code:

if running of application "Google Chrome" then
    tell application "System Events"
        tell application process "Google Chrome"
            if exists window 1 then
                set |position| to position of window 1
                set position of window 1 to ¬
                    {((item 1 of |position|) + 5), ((item 2 of |position|) - 5)}
            end if
        end tell
    end tell
end if

Notes:

Since you didn't state how you intended to implement the AppleScript code, I've included some error handling that may not be necessary, e.g. if running of application "Google Chrome" then block. (Or whichever application you set it for.)

Once a window had been repositioned to where it meets the bottom of the menu bar, or top of the screen if the menu bar is hidden, it will no longer move upwards and will only continue to move to the right.



Note: The example AppleScript code is just that and sans any included error handling does not contain any additional error handling as may be appropriate. The onus is upon the user to add any error handling as may be appropriate, needed or wanted. Have a look at the try statement and error statement in the AppleScript Language Guide. See also, Working with Errors. Additionally, the use of the delay command may be necessary between events where appropriate, e.g. delay 0.5, with the value of the delay set appropriately.

I want to move the position of a current window 5 pixels up, and 5 pixels right.

I do not have RStudio, however, here is an example using Google Chrome.

Example AppleScript code:

if not running of application "Google Chrome" then return
tell application "System Events"
    tell application process "Google Chrome"
        if not (exists window 1) then return
        set |position| to position of window 1
        set position of window 1 to ¬
            {((item 1 of |position|) + 5), ((item 2 of |position|) - 5)}
    end tell
end tell

Notes:

Since you didn't state how you intended to implement the AppleScript code, I've included some error handling that may not be necessary, e.g. if not running of application "Google Chrome" then return (Or whichever application you set it for.)

Once a window had been repositioned to where it meets the bottom of the menu bar, or top of the screen if the menu bar is hidden, it will no longer move upwards and will only continue to move to the right.



Note: The example AppleScript code is just that and sans any included error handling does not contain any additional error handling as may be appropriate. The onus is upon the user to add any error handling as may be appropriate, needed or wanted. Have a look at the try statement and error statement in the AppleScript Language Guide. See also, Working with Errors. Additionally, the use of the delay command may be necessary between events where appropriate, e.g. delay 0.5, with the value of the delay set appropriately.

added 489 characters in body
Source Link
user3439894
  • 59.8k
  • 10
  • 112
  • 135

I want to move the position of a current window 5 pixels up, and 5 pixels right.

I do not have RStudio, however, here is an example using Google Chrome.

Example AppleScript code:

if running of application "Google Chrome" then
    tell application "System Events"
        tell application process "Google Chrome"
            if exists window 1 then
                set |position| to position of window 1
                set position of window 1 to ¬
                    {((item 1 of |position|) + 5), ((item 2 of |position|) - 5)}
            end if
        end tell
    end tell
end if

Notes:

Since you didn't state how you intended to implement the AppleScript code, I've included some error handling that may not be necessary, e.g. if running of application "Google Chrome" then block. (Or whichever application you set it for.)

Once a window had been repositioned to where it meets the bottom of the menu bar, or top of the screen if the menu bar is hidden, it will no longer move upwards and will only continue to move to the right.



Note: The example AppleScript code is just that and sans any included error handling does not contain any additional error handling as may be appropriate. The onus is upon the user to add any error handling as may be appropriate, needed or wanted. Have a look at the try statement and error statement in the AppleScript Language Guide. See also, Working with Errors. Additionally, the use of the delay command may be necessary between events where appropriate, e.g. delay 0.5, with the value of the delay set appropriately.

I want to move the position of a current window 5 pixels up, and 5 pixels right.

I do not have RStudio, however, here is an example using Google Chrome.

Example AppleScript code:

if running of application "Google Chrome" then
    tell application "System Events"
        tell application process "Google Chrome"
            if exists window 1 then
                set |position| to position of window 1
                set position of window 1 to ¬
                    {((item 1 of |position|) + 5), ((item 2 of |position|) - 5)}
            end if
        end tell
    end tell
end if


Note: The example AppleScript code is just that and sans any included error handling does not contain any additional error handling as may be appropriate. The onus is upon the user to add any error handling as may be appropriate, needed or wanted. Have a look at the try statement and error statement in the AppleScript Language Guide. See also, Working with Errors. Additionally, the use of the delay command may be necessary between events where appropriate, e.g. delay 0.5, with the value of the delay set appropriately.

I want to move the position of a current window 5 pixels up, and 5 pixels right.

I do not have RStudio, however, here is an example using Google Chrome.

Example AppleScript code:

if running of application "Google Chrome" then
    tell application "System Events"
        tell application process "Google Chrome"
            if exists window 1 then
                set |position| to position of window 1
                set position of window 1 to ¬
                    {((item 1 of |position|) + 5), ((item 2 of |position|) - 5)}
            end if
        end tell
    end tell
end if

Notes:

Since you didn't state how you intended to implement the AppleScript code, I've included some error handling that may not be necessary, e.g. if running of application "Google Chrome" then block. (Or whichever application you set it for.)

Once a window had been repositioned to where it meets the bottom of the menu bar, or top of the screen if the menu bar is hidden, it will no longer move upwards and will only continue to move to the right.



Note: The example AppleScript code is just that and sans any included error handling does not contain any additional error handling as may be appropriate. The onus is upon the user to add any error handling as may be appropriate, needed or wanted. Have a look at the try statement and error statement in the AppleScript Language Guide. See also, Working with Errors. Additionally, the use of the delay command may be necessary between events where appropriate, e.g. delay 0.5, with the value of the delay set appropriately.

Source Link
user3439894
  • 59.8k
  • 10
  • 112
  • 135

I want to move the position of a current window 5 pixels up, and 5 pixels right.

I do not have RStudio, however, here is an example using Google Chrome.

Example AppleScript code:

if running of application "Google Chrome" then
    tell application "System Events"
        tell application process "Google Chrome"
            if exists window 1 then
                set |position| to position of window 1
                set position of window 1 to ¬
                    {((item 1 of |position|) + 5), ((item 2 of |position|) - 5)}
            end if
        end tell
    end tell
end if


Note: The example AppleScript code is just that and sans any included error handling does not contain any additional error handling as may be appropriate. The onus is upon the user to add any error handling as may be appropriate, needed or wanted. Have a look at the try statement and error statement in the AppleScript Language Guide. See also, Working with Errors. Additionally, the use of the delay command may be necessary between events where appropriate, e.g. delay 0.5, with the value of the delay set appropriately.