Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

robotgo.ActivePid panic #619

Open
1 of 3 tasks
xingcxb opened this issue Nov 4, 2023 · 0 comments
Open
1 of 3 tasks

robotgo.ActivePid panic #619

xingcxb opened this issue Nov 4, 2023 · 0 comments

Comments

@xingcxb
Copy link

xingcxb commented Nov 4, 2023

  • Robotgo version (or commit ref): v1.0.0-rc2.1
  • Go version: 1.21.1
  • Gcc version: Apple clang version 15.0.0 (clang-1500.0.40.1)
  • Operating system and bit: macos 13.6.1 arm64
  • Resolution:
  • Can you reproduce the bug at Examples:
    • Yes (provide example code)
    • No
    • Not relevant
  • Provide example code:
func main() {
	app := application.New(application.Options{
              ...
        }
       MainWindow(app *application.App)
}

func MainWindow(app *application.App) {
	actionPid := robotgo.GetPid()
        mainWindow := app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
            ....
        }
        // 自定义事件,双击卡片事件
	customEvents.HandleCardDoubleClick(app, mainWindow, actionPid)
}

func HandleCardDoubleClick(app *application.App, window *application.WebviewWindow, actionPid int) {
	app.Events.On(common.EventsHandleCardDoubleClickToCore, func(e *application.WailsEvent) {
		pasteData := db.FindPasteById(func() int {
			return int(e.Data.(float64))
		}())
		if pasteData.Id == 0 {
			return
		}
		window.Close()
		pasteContent := formatContent(pasteData.Content, pasteData.Type)
		fmt.Println("要释放的数据:", pasteContent)
		fmt.Println("要接受数据的pid:", actionPid)
		if actionPid != 0 {
			pidExists, err := robotgo.PidExists(actionPid)
			if err != nil || !pidExists {
				fmt.Println("查询程序是否存在失败", err.Error())
				return
			}
			fmt.Println(robotgo.FindName(actionPid))
			err = robotgo.ActivePid(actionPid) // 
			if err != nil {
				fmt.Println("切换到下一个程序聚焦失败", err.Error())
				return
			}
			if pasteData.Type == "text" {
				robotgo.TypeStr(pasteContent)
			}
		}

	})
}
  • Log gist:
SIGSEGV: segmentation violation
PC=0x1a7291820 m=12 sigcode=2
signal arrived during cgo execution

goroutine 48 [syscall]:
runtime.cgocall(0x1049582c4, 0x14000341c98)
        /usr/local/go/src/runtime/cgocall.go:157 +0x44 fp=0x14000341c50 sp=0x14000341c10 pc=0x10402a604
github.com/go-vgo/robotgo._Cfunc_active_PID(0x1c1, 0x0)
        _cgo_gotypes.go:333 +0x30 fp=0x14000341c90 sp=0x14000341c50 pc=0x1047fc960
...
PastePlus/core/api/customEvents.HandleCardDoubleClick.func1(0x140001ed600)
        /Users/symbol/Go/src/PastePlus/core/api/customEvents/customEvents.go:121 +0x480 fp=0x14000341fa0 sp=0x14000341d00 pc=0x1047ff530

Description

Before activating a new window, I first obtained the pid of the previous application. If pid is consistent with the pid of the current application, I will return pid=0. When I operate the current application, panic appears when activating the previous application, and I have judged Pid! =0 and also checked with pidexists, but in calling robotgo. ActivePid appeared panic
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant