dryift6733 2014-01-26 14:20
浏览 360
已采纳

Go-我如何在go代码中执行此python代码?

How can i do this in Go language please? I have used Python 2.7, pywin32 for the win32com and the following code which works to trigger virtual keyboard press.

Python code works:

import time
import win32com
import win32com.client

shell = win32com.client.Dispatch('WScript.Shell')
shell.Run('chrome')    
time.sleep(0.1)

shell.AppActivate('chrome')
shell.SendKeys("www.stackoverflow.com", 0)
shell.SendKeys("{Enter}", 0)

time.sleep(4)
shell.SendKeys("{F11}", 0)

i am actually trying the same Python code in Go (for Windows and Mac), can anyone give me any example how exactly this can be done with Go?

enter image description here

  • 写回答

1条回答 默认 最新

  • dougai2427 2014-01-26 15:17
    关注

    This doesn't answer the win32 calls part, I assume you can do that via the syscall package, as in https://github.com/AllenDang/w32

    As for launching chrome in full screen mode, you can do from a shortcut or if you really want to do it from go, you can do: Play (can't run there)

    package main
    
    import "os/exec"
    
    func main(){
        chrome := "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"
        cmd := exec.Command(chrome,"--chrome-frame","--kiosk","http://www.ibm.com")
        err := cmd.Start()
        if err != nil {
            println("Failed to start chrome:", err)
        }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料