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

智能F1建议 #43

Open
liyuanmeng opened this issue Dec 7, 2023 · 6 comments
Open

智能F1建议 #43

liyuanmeng opened this issue Dec 7, 2023 · 6 comments

Comments

@liyuanmeng
Copy link

在使用过程中发现有些机器开帮助文件特别慢,会造成打不开的情况,我做了下如修改,你看一下要不要合并进去

IE_GetWB(PID) { ; get the parent windows & coord from the element
  IID_IWebBrowserApp := "{0002DF05-0000-0000-C000-000000000046}"
  , IID_IHTMLWindow2 := "{332C4427-26CB-11D0-B483-00C04FD90119}"

  loop, 100
  {
    WinGet, ControlListHwnd, ControlListHwnd, ahk_pid %PID%
    for k, v in StrSplit(ControlListHwnd, "`n", "`r")
    {
      WinGetClass, sClass, ahk_id %v%
      if (sClass = "Internet Explorer_Server")
      {
        hCtl := v
        break
      }
    }
    if hCtl
    {
      break
    }
    Sleep, 1000
  }
@telppa
Copy link
Owner

telppa commented Dec 8, 2023

特别慢的原因是啥?性能不够?精简版系统?抑或是其它?

可以的话,像下面这样用 计时() 函数看看主要慢在哪一句

计时()
loop 10000
  a := 1
计时()

计时()
{
	Static
	if (CounterBefore="")
	{
		DllCall("QueryPerformanceFrequency", "Int64*", freq)
		, DllCall("QueryPerformanceCounter", "Int64*", CounterBefore)
	}
	else
	{
		DllCall("QueryPerformanceCounter", "Int64*", CounterAfter)
		, 耗时:=(CounterAfter - CounterBefore) / freq * 1000
		, CounterBefore:=""
		MsgBox, 4096, 耗时, % Format("{1} 毫秒`r`n或`r`n{2} 分 {3} 秒", 耗时, Floor(耗时/1000/60), Round(Mod(耗时/1000,60)))
	}
}

@liyuanmeng
Copy link
Author

是机器的问题,老机器上开autohotkey帮助,内容加载的慢,脚本获取不到"Internet Explorer_Server",然后就造成后续的代码失效。

@liyuanmeng
Copy link
Author

另外还有一个问题,在WINDOWS7的机器上,智能标点会造成卡顿,回头我用上面记时的代码测试一下,看看哪里可能有问题。

@telppa
Copy link
Owner

telppa commented Dec 8, 2023

是机器的问题,老机器上开autohotkey帮助,内容加载的慢,脚本获取不到"Internet Explorer_Server",然后就造成后续的代码失效。

我暂时先不合并这个代码,你自用的话,可以这样优化上述代码。

IE_GetWB(PID) { ; get the parent windows & coord from the element
  IID_IWebBrowserApp := "{0002DF05-0000-0000-C000-000000000046}"
  , IID_IHTMLWindow2 := "{332C4427-26CB-11D0-B483-00C04FD90119}"

  loop, 100
  {
    WinGet, ControlListHwnd, ControlListHwnd, ahk_pid %PID%
    for k, v in StrSplit(ControlListHwnd, "`n", "`r")
    {
      WinGetClass, sClass, ahk_id %v%
      if (sClass = "Internet Explorer_Server")
      {
        hCtl := v
        break 2
      }
    }
    Sleep, 1000
  }

@telppa
Copy link
Owner

telppa commented Dec 8, 2023

你试试这样在老机器上正常吗?

IE_GetWB(PID) { ; get the parent windows & coord from the element
  IID_IWebBrowserApp := "{0002DF05-0000-0000-C000-000000000046}"
  , IID_IHTMLWindow2 := "{332C4427-26CB-11D0-B483-00C04FD90119}"

  ; 某些老机器据说打开帮助非常缓慢,因此在这里进行等待
  WinWait ahk_pid %PID%, , 10
  WinGet ControlListHwnd, ControlListHwnd, ahk_pid %PID%
  for k, v in StrSplit(ControlListHwnd, "`n", "`r")
  {
    WinGetClass sClass, ahk_id %v%
    if (sClass = "Internet Explorer_Server")
    {
      hCtl := v
      break
    }
  }

  if !(sClass == "Internet Explorer_Server")
  ; document property will fail if no valie com object
  or !(oDoc := ComObject(9, ComObjQuery(Acc_ObjectFromWindow(hCtl), IID_IHTMLWindow2, IID_IHTMLWindow2), 1).document)
  {
    ToolTip 智能F1 失效
    return
  }

  oWin := ComObject(9, ComObjQuery(oDoc, IID_IHTMLWindow2, IID_IHTMLWindow2), 1)
  return oWB := ComObject(9, ComObjQuery(oWin, IID_IWebBrowserApp, IID_IWebBrowserApp), 1)
}

@liyuanmeng
Copy link
Author

这种是不行的,我说的慢是"Internet Explorer_Server"控件加载的慢,帮助程序是打开的,出现了窗口,但是一片空白,之后等待几秒帮助内容才会出现,所以我用循环等待这个控件加载完成。

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

2 participants