https://bugs.winehq.org/show_bug.cgi?id=52716
Bug ID: 52716 Summary: Sending key stroke (using [System.Windows.Forms.SendKeys]::SendWait) fails (seems to go into a loop?) Product: Wine Version: 7.4 Hardware: x86-64 URL: https://github.com/PowerShell/PowerShell/releases/down load/v7.0.3/PowerShell-7.0.3-win-x64.msi OS: Linux Status: NEW Keywords: dotnet, download Severity: normal Priority: P2 Component: -unknown Assignee: wine-bugs@winehq.org Reporter: xerox.xerox2000x@gmail.com Distribution: ---
Created attachment 72077 --> https://bugs.winehq.org/attachment.cgi?id=72077 ps script
Hi, I have a powershell script where I need to send a keystroke to a program.
I found code snippet on the internet and made little script that I tested in windows (using powershell core) and it works.
It sends ctrp^p to notepad, and that opens the printer-dialog correctly on windows.
On wine however it doesn`t work, cpu-usage goes up so it seems to get into loop(???)
Script (also see attachment): ###################################################################
Start-Process "notepad.exe" Sleep 3
$WindowHandle = Get-Process | Where-Object { $_.MainWindowTitle -Match "Notepad" } | Select-Object -ExpandProperty MainWindowHandle
[void][System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms') [System.Windows.Forms.SendKeys]::SendWait("^{p}")
#####################################################################
Steps to reproduce:
1. winetricks -q dotnet48 2. wget https://github.com/PowerShell/PowerShell/releases/download/v7.0.3/PowerShell... 3. wine PowerShell-7.0.3-win-x64.msi 4. Save the script from attachment as a.ps1 in current folder 5. wine pwsh -file ./a.ps1
Notepad opens but nothing really happens and cpu-usage goes up
https://bugs.winehq.org/show_bug.cgi?id=52716
--- Comment #1 from Louis Lenders xerox.xerox2000x@gmail.com --- Still present in wine-7.10
From a log it goes into endless loop PeekMessage/CoregisterMessageFilter, and
just before that there`s trace:hook:NtUserSetWindowsHookEx WH_JOURNALPLAYBACK 0x1bf3c84 0 -> 0x1007c trace:hook:NtUserSetWindowsHookEx WH_JOURNALPLAYBACK 0x1bf3cc4 0 -> 0x2007c
With sad hack below, just stupidly returning 0 for NtUserSetWindowsHookEx it works ok (keystroke is sent and it doesn`t get into the loop.)
So maybe the problem is in NtUserSetWindowsHookEx?
Sad hack :
diff --git a/dlls/win32u/hook.c b/dlls/win32u/hook.c index a271693622a..fd25ddefd27 100644 --- a/dlls/win32u/hook.c +++ b/dlls/win32u/hook.c @@ -73,7 +73,7 @@ static BOOL is_hooked( INT id ) */ HHOOK WINAPI NtUserSetWindowsHookEx( HINSTANCE inst, UNICODE_STRING *module, DWORD tid, INT id, HOOKPROC proc, BOOL ansi ) -{ +{return 0; HHOOK handle = 0;
if (!proc)
https://bugs.winehq.org/show_bug.cgi?id=52716
Louis Lenders xerox.xerox2000x@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Component|-unknown |win32u
--- Comment #2 from Louis Lenders xerox.xerox2000x@gmail.com --- Setting component
https://bugs.winehq.org/show_bug.cgi?id=52716
Louis Lenders xerox.xerox2000x@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Fixed by SHA1| |e1259ff91a40d7d97fa730235e2 | |b7737b229f708 Resolution|--- |FIXED
--- Comment #3 from Louis Lenders xerox.xerox2000x@gmail.com --- This is now fixed by Zhiyi's yesterday commit
commit e1259ff91a40d7d97fa730235e2b7737b229f708 Author: Zhiyi Zhang zzhang@codeweavers.com Date: Wed Oct 25 15:20:32 2023 -0500
win32u: Return ERROR_ACCESS_DENIED for WH_JOURNALRECORD and WH_JOURNALPLAYBACK.
Thanks Zhiyi!
https://bugs.winehq.org/show_bug.cgi?id=52716
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #4 from Alexandre Julliard julliard@winehq.org --- Closing bugs fixed in 8.20.