duanjue2576 2014-01-28 05:31
浏览 60

转到-如何检测Windows或Mac桌面屏幕是横向还是纵向模式?

With Go, how can i detect if the Windows or Mac PC is in landscape or portrait mode please? here is a following example where i need to read the action for layout if its landscape or portrait.

package main

import "os/exec"
import "runtime"
import "fmt"

const url = "http://localhost:8080/demo1?action=landscape"


func main() {      
  myos := runtime.GOOS
  /////------------------> Detect the landscape or portrait of the screen???


  if myos == "windows" {
    chrome := "C:/Program Files/Google/Chrome/Application/chrome.exe"
    cmd := exec.Command(chrome, "--chrome-frame", "--kiosk", url)
    err := cmd.Start()
    if err != nil {
      // 64-bit
      //println("Failed to start chrome:", err)
      chrome := "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"
      cmd := exec.Command(chrome, "--chrome-frame", "--kiosk", url)
      cmd.Start()       
    } 

  } else if myos == "darwin" {
    // open -b com.google.Chrome --args <which args to pass to Chrome>
    // "/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome"
    //chrome := "/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome"
    cmd := exec.Command("open", "-b" , "com.google.Chrome", "--args", "--chrome-frame", "--kiosk", url)
    err := cmd.Start()
    if err != nil {
      fmt.Println("failed")
    } 

  } else {
    //Linux    
    chrome := "google-chrome"
    cmd := exec.Command(chrome, "--chrome-frame", "--kiosk", url)
    err := cmd.Start()
    if err != nil {
      fmt.Println("failed")
    }

  }

}
  • 写回答

1条回答 默认 最新

  • doufuxi7093 2014-01-31 04:01
    关注

    Once again, not a direct answer to your question, but may solve your problem.

    See this for a description. All you really need to do is check the dimensions of the window via javascript and reload the page with the correct args.

    if height > width, it's portrait mode, otherwise it's landscape

    评论

报告相同问题?

悬赏问题

  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 Macbookpro 连接热点正常上网,连接不了Wi-Fi。
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程
  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果