I have a problem with positioning and moving on-screen keyboard (osk.exe). I used SetWindowsPos to do this, but it takes no effect. I also tried use MoveWindow instead of SetWindowsPos but it takes no effect too. I used SetWindowsPos on Mozilla Firefox and it works fine. I have no idea why it only works with some programs.
It is my code:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Sub SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
Private Sub ResizeOsk()
Dim retval As Long
Dim OskHandle As Long
OskHandle = FindWindow(vbNullString, "Klawiatura ekranowa")
SetWindowPos OskHandle, -1, 0, 0, 1000, 1000, &H40
'MoveWindow OskHandle, 500, 400, 1500, 1000, 1
End Sub
When I debug the program, variable OskHandle isn't empty.
Maybe is there another solution to solve my problem with positioning on-screen keyboard.
答案 0 :(得分:1)
这是Edge的窗口列表,其中一个选项卡向Google开放。
WindowText ClassName HWnd ParentHWnd ProcessID ParentProcessID ThreadID ModuleNameHWin EXENameProcess
-------------------------------------------------------------------------------------------------------------------
Microsoft Edge Windows.UI.Core.CoreWindow 82182908 45353128 7336 968 3544 «Not Available Error=126» MicrosoftEdge.exe
«No Window Text 0» Spartan ServiceUI XAML-To-Trident Input Routing Window 21627338 82182908 7336 968 1112 «Not Available Error=126» MicrosoftEdge.exe
«No Window Text 0» Spartan XAML-To-Trident Input Routing Window 54593368 82182908 7336 968 1112 «Not Available Error=126» MicrosoftEdge.exe
«No Window Text 0» Spartan Tab XAML-To-Trident Input Routing Window 64488388 54593368 7336 968 1112 «Not Available Error=126» MicrosoftEdge.exe
Google TabWindowClass 30934882 64488388 7992 4380 3564 «Not Available Error=126» MicrosoftEdgeCP.exe
CoreInput Windows.UI.Core.CoreComponentInputSource 57214268 30934882 7992 4380 3564 «Not Available Error=126» MicrosoftEdgeCP.exe
«No Window Text 0» Internet Explorer_Server 64620588 30934882 7992 4380 3564 «Not Available Error=126» MicrosoftEdgeCP.exe
«No Window Text 0» Spartan ServiceUI XAML-To-Trident Input Routing Window 30344376 54593368 7336 968 1112 «Not Available Error=126» MicrosoftEdge.exe
«No Window Text 0» Spartan ServiceUI XAML-To-Trident Input Routing Window 29230712 54593368 7336 968 1112 «Not Available Error=126» MicrosoftEdge.exe
子窗口的大小不能大于父窗口的大小。它与父窗口有关,而不与桌面窗口有关。您的窗口下降了4级。第二个字段是ClassName,因为顶部窗口没有标题(所有正在运行的MS Edge都一样)。
此功能可能有帮助。
GetAncestor
GetAncestor函数检索到该对象祖先的句柄 指定的窗口。
HWND GetAncestor( HWND hwnd, // handle to window UINT gaFlags // ancestor );
参数
hwnd [in]处理到要检索其祖先的窗口。如果 此参数是桌面窗口,函数返回NULL。
gaFlags [in]指定要检索的祖先。这个参数 可以是以下值之一。
值含义
GA_PARENT 检索父窗口。它不包括所有者,与GetParent函数一样。
GA_ROOT 通过遍历父窗口链来检索根窗口。 GA_ROOTOWNER ,通过遍历GetParent返回的父窗口和所有者窗口的链来检索拥有的根窗口。返回值返回值是祖先窗口的句柄。
来自帮助。
Also Edge也适用于用户。用于自动化的浏览器是Internet Explorer。它也是用于自动编辑HTML或将浏览器控件合并到您的应用中的浏览器。 (请注意,这是vbscript,如果您在VBA中使用它,请删除wscript.sleep
行,因为VBA不能使用该行,但它具有自己的等效项。
Set ie = CreateObject("InternetExplorer.Application")
ie.Navigate2 "www.google.com.au"
ie.visible=true
wscript.sleep 5000
ie.refresh2
ie.top=0
ie.left=0
ie.height=200
ie.width=100