我試圖找到一個shell命令,它將打開具有特定x和y座標的Google Chrome瀏覽器(以便可以在打開時設置窗口的位置)。有沒有可能使用命令行參數來做到這一點?使用特定的窗口座標從命令行啓動Google Chrome
我需要爲了實現這一修改以下命令:
google-chrome http://www.google.com/
我試圖找到一個shell命令,它將打開具有特定x和y座標的Google Chrome瀏覽器(以便可以在打開時設置窗口的位置)。有沒有可能使用命令行參數來做到這一點?使用特定的窗口座標從命令行啓動Google Chrome
我需要爲了實現這一修改以下命令:
google-chrome http://www.google.com/
http://peter.sh/experiments/chromium-command-line-switches/說--window位置= X,Y是你在找什麼。
更新今年以後包含一個我幾年前寫過的小shell腳本(但回答了這個問題後),它提供了一個如何使用自定義窗口大小/位置啓動chrome的例子,並且能夠創建'假'用戶數據目錄的名稱。
它可能會也可能不會繼續工作,並有一些危險的選項設置,但你明白了..不要使用這個逐字,一些標誌可能已被重命名或被完全刪除..(如襪子代理命令一樣)
#!/bin/bash -x
FAKEUSER="${1:-fake-chrome-user}"
CHROMEROOT=$HOME/.chromeroot/
mkdir -p ${CHROMEROOT}
export PROFILE="${CHROMEROOT}/${FAKEUSER}-chromium-profile"
export DISK_CACHEDIR="${CHROMEROOT}/${FAKEUSER}-chromium-profile-cache"
export DISK_CACHESIZE=4096
export MEDIA_CACHESIZE=4096
PARANOID_OPTIONS="\
--no-displaying-insecure-content \
--no-referrers \
--disable-zero-suggest \
--disable-sync \
--cipher-suite-blacklist=0x0004,0x0005,0xc011,0xc007 \
--enable-sandbox-logging >/dev/null 2>&1
"
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \
--remember-cert-error-decisions \
--ignore-certificate-errors \
--ignore-urlfetcher-cert-requests \
--allow-running-insecure-content \
--window-position=2400,400 \
--window-size=1500,1000 \
--no-pings \
--user-data-dir=${PROFILE} \
--disk-cache-dir=${DISK_CACHEDIR} \
--disk-cache-size=${DISK_CACHESIZE} \
--media-cache-size=${MEDIA_CACHESIZE} \
2>&1
#--proxy-server="socks4://localhost:30604" \
#--host-resolver-rules="MAP * 0.0.0.0 , EXCLUDE localhost" \
我用這個:
google-chrome "data:text/html;charset=ISO-8859-1,<html>
<head></head><body><script language=\"javascript\">
window.open('http://perso.f-hauri.ch/~felix/svg/dustin_w_Clock_autonom.svg',
'clock','toolbar=0,location=0,status=0,menubar=0,scrollbars=1,'
+'resizable=1,width=600,height=600,top=100,left=120');</script>"
但谷歌鉻塊彈出窗口,所以這樣的:
google-chrome "data:text/html;charset=ISO-8859-1,<html><head></head><body>
<button onclick=\"javascript:window.open(
'http://perso.f-hauri.ch/~felix/svg/dustin_w_Clock_autonom.svg',
'clock','toolbar=0,location=0,status=0,menubar=0,scrollbars=1,'
+'resizable=1,width=600,height=600,top=100,left=120');\"> clock </button>"
給出一個很好的方法來做到這一點。
注意:這項工作也與Firefox一樣。
如果你通過'onfocus'替換'onclick',只需點擊'
要建立在@ synthesizerpatel的答案上,--window-position
將不會在它自己的工作。
你需要啓動它,因爲它是使用--user-data-dir
或--chrome-frame
喜歡自己的新實例:
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --user-data-dir=XXXXXXXXXX --window-size=800,600 --window-position=580,240 --app="http://www.google.com/"
or
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --chrome-frame --window-size=800,600 --window-position=580,240 --app="http://www.google.com/"
可惜對我來說,有它作爲一個新的實例意味着它不會在會話/ cookie的攜帶從其他實例/等信息,所以我有正常(只有在--app
參數)打開它,然後在我打開做頁面的javascript:
window.moveTo(580,240);
window.resizeTo(800,600);
我想,如果你打開擁有的網頁由別人,你c應該打開擁有上述js的自己的網頁,然後導航到他們的網頁。
當你使用谷歌的Chrome,有一個較短的方式:
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
--profile-directory="Default"
--app="data:text/html,<html><body><script>window.moveTo(580,240);window.resizeTo(800,600);window.location='http://www.test.de';</script></body></html>"
臨:
缺點:
另一個「專業版」 - 它適用於Chrome 51以及普通的瀏覽器配置文件;另一個答案顯然不是。 –
絕對是一種解決方法。 –
太好了,非常感謝你!這是爲我工作的唯一解決方案。 – cronfy
隨着我的最新版本的Chrome測試 - 我只需要以下。每當我關閉應用程序,它都會記住我的窗口大小和位置。
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --chrome-frame --app=https://mightytext.net/web8/?exp=1
此版本爲我工作48.0.2564.48的β-M(64位) 和版本48.0.2564.48的β-M(64位)
問題是它需要先手動調整位置和大小;他們不能被納入啓動command.com – Synetech
可它也可用於Firefox和IE做?我在這裏發佈了一個問題:http://stackoverflow.com/questions/26626884/chrome-app-equivalent-in-firefox-ie – liorafar
可悲的是,這並不總是奏效。請參閱http://stackoverflow.com/questions/14592020/google-chrome-new-window-switch-ignores-window-position-and-window-size#comment30263659_14592020 –
它可以工作,@GregBray,但您需要設置'--user-data-dir'標誌。 –