<SetForegroundWin> failed: Operating system SetForegroundWindow function failed; Windows reports system error 0, "The operation completed successfully."
Anyone know how to correct this error or why it happens only intermittently
<SetForegroundWin> failed: Operating system SetForegroundWindow function failed; Windows reports system error 0, "The operation completed successfully."
Anyone know how to correct this error or why it happens only intermittently
I am currently having the same issue. The error happens very inconsistently, maybe 50% of the time I try to execute a ToggleWin command. The frustrating thing about this is the same script was working without issue as recently as two or three weeks ago.
Has anyone else encountered this issue?
I don't face this error using the <SetForegroundWin> only for the first window, but when I use the code with <SeForegroundWin> after each window target it does cause that error... Let me know if this works for you as worked for me
*Resize for 1920x1080p monitor and five accounts
Code:<Command ResizeAndPosition> <TargetWin %2%> <SetWinRect 1280 0 640 360> <UpdateWin> <TargetWin %3%> <SetWinRect 1280 360 640 360> <UpdateWin> <TargetWin %4%> <SetWinRect 1280 720 640 360> <UpdateWin> <TargetWin %5%> <SetWinRect 640 720 640 360> <UpdateWin> <TargetWin %1%> <SetWinRect 0 0 1280 720> <SetForegroundWin> <UpdateWin>
Last edited by muldorante : 07-21-2019 at 05:42 AM Reason: Missing information
Thank you for the response! I played around a bit with the solution you recommended and found that the errors were happening less frequently, but were still occurring. In my case, I'm toggling between 3 accounts as opposed to your 5 accounts. I started to wonder whether the time needed to resize 5 windows introduced a delay long enough to avoid the errors. Incidentally, another symptom I noticed was when errors occurred I could hear 2 soundtracks playing on top of one another.
I started to wonder whether there was a timing issue involved between switching focus to the desired window and syncing up the hidden window, which might be responsible for playing the soundtrack.
I introduced a delay to see if it helped matters and it eliminated the errors I was experiencing. Here was the original setup that failed roughly half the time:
I introduced a delay in my own version of ToggleWin:Code:// -- run this first <Hotkey ScrollLockOn Ctrl F12> <SendPC local> <RenameWin "World of Warcraft" hidden-wow-1> <RenameWin "World of Warcraft" hidden-wow-2> <RenameWin "World of Warcraft" hidden-wow-3> // -- run this second <Hotkey ScrollLockOn Shift Ctrl F12> <SendPC local> <RenameWin "World of Warcraft" wow1> <RenameWin "World of Warcraft" wow2> <RenameWin "World of Warcraft" wow3> <Hotkey ScrollLockOn Shift Ctrl F11> <SendPC local> <ToggleWin wow1 wow2 wow3>
So far, this seems to work for me without errors. After some experimentation, I settled on a wait time of 100ms (note the <wait 100> command) and no longer saw errors. I will say that adjusting the wait to be lower started to result in errors again, so it's possible you'll need to adjust this number based on your own setup.Code:// -- run this first <Hotkey ScrollLockOn Ctrl F12> <SendPC local> <RenameWin "World of Warcraft" hidden-wow-1> <RenameWin "World of Warcraft" hidden-wow-2> <RenameWin "World of Warcraft" hidden-wow-3> // -- run this second <Hotkey ScrollLockOn Shift Ctrl F12> <SendPC local> <RenameWin "World of Warcraft" wow1> <RenameWin "World of Warcraft" wow2> <RenameWin "World of Warcraft" wow3> <Command DelayedToggleWin> <SendPC local> <TargetWin %1%> <wait 100> <SetForegroundWin> <UpdateWin> <Hotkey ScrollLockOn Shift Ctrl F11> <If ActiveWinIs wow1> <DelayedToggleWin wow2> <Else If ActiveWinIs wow2> <DelayedToggleWin wow3> <Else> <DelayedToggleWin wow1>
Note that this is working for my use case: 3 accounts running on a single computer. Hopefully this will be helpful to others experiencing this issue.
Update:
After playing with this config for a few hours, I'm still seeing issues. The errors are happening much less frequently, but they are still happening. Please share if you have other ideas on this issue. Thanks!
Last edited by raikodin : 08-07-2019 at 10:42 AM
In your hotkeynet settings the Disable foreground lock is checked?
Options > Settings > Disable foreground lock
With this option checked and the code that i posted earlier I don't face any errors
Give it a try, good luck![]()
Thanks for taking another look at this issue. Unfortunately, my 'disable foreground lock' setting was already selected. Just in case I'm missing something, I've posted my settings below.
![]()
Last edited by raikodin : 08-11-2019 at 10:12 PM Reason: Original post settings image was a bit too hard to read
Can you post your script? Maybe something else is causing this error...
Code:<Hotkey ScrollLockOn Ctrl F12> <SendPC local> <RenameWin "World of Warcraft" hidden-wow-1> <RenameWin "World of Warcraft" hidden-wow-2> <RenameWin "World of Warcraft" hidden-wow-3> <Hotkey ScrollLockOn Shift Ctrl F12> <SendPC local> <RenameWin "World of Warcraft" wow1> <RenameWin "World of Warcraft" wow2> <RenameWin "World of Warcraft" wow3> <Label w1 Local SendWinM wow1> <Label w2 Local SendWinM wow2> <Label w3 Local SendWinM wow3> <Hotkey ScrollLockOn B, C, M, 0-9, Plus, Minus, Space> <SendLabel w1, w2, w3> <Key %Trigger%> <Hotkey ScrollLockOn Ctrl B, 0-9, Plus, Minus> <SendLabel w1, w2, w3> <Key %Trigger%> <MovementHotkey ScrollLockOn S, down> <SendLabel w1, w2, w3> <Key %Trigger%> <Command DelayedToggleWin> <SendPC local> <TargetWin %1%> <wait 100> <SetForegroundWin> <UpdateWin> <Hotkey ScrollLockOn Shift Ctrl F8> <DelayedToggleWin wow1> <Hotkey ScrollLockOn Shift Ctrl F9> <DelayedToggleWin wow2> <Hotkey ScrollLockOn Shift Ctrl F10> <DelayedToggleWin wow3> <Hotkey ScrollLockOn Shift Ctrl F11> <If ActiveWinIs wow1> <DelayedToggleWin wow2> <Else If ActiveWinIs wow2> <DelayedToggleWin wow3> <Else> <DelayedToggleWin wow1>
I just tested your code and indeed it sometimes causes the error to appear on the hotkeynet
I changed a little bit the code, replaced the <SetForegroundWin> with <SetActiveWin> and deleted the <wait 100> and <UpdateWin>
If you're just toggling the windows there is no need for the <SetForegroundWin> or <UpdateWin>
Try it out, just replace the
forCode:<Command DelayedToggleWin> <SendPC local> <TargetWin %1%> <wait 100> <SetForegroundWin> <UpdateWin>
Code:<Command DelayedToggleWin> <SendPC local> <TargetWin %1%> <SetActiveWin>
I gave your suggestion a try tonight and things seem to be working perfectly! No errors at all! Muldorante, thank you!
I did notice just a little lag when I toggled between windows. I bumped up the max FPS for background windows and the lag went away.
I have to say, this is a big relief. I could still play with the errors, but it drained some of the fun out of it when there were constant delays when trying to switch from character to character. So glad things are fixed in time for classic!
Thanks again
update: For completeness sake, here is my updated script which is working thanks to Muldorante's suggestion:
Code:<Hotkey ScrollLockOn Ctrl F12> <SendPC local> <RenameWin "World of Warcraft" hidden-wow-1> <RenameWin "World of Warcraft" hidden-wow-2> <RenameWin "World of Warcraft" hidden-wow-3> <Hotkey ScrollLockOn Shift Ctrl F12> <SendPC local> <RenameWin "World of Warcraft" wow1> <RenameWin "World of Warcraft" wow2> <RenameWin "World of Warcraft" wow3> <Label w1 Local SendWinM wow1> <Label w2 Local SendWinM wow2> <Label w3 Local SendWinM wow3> <Hotkey ScrollLockOn B, C, M, 0-9, Plus, Minus, Space> <SendLabel w1, w2, w3> <Key %Trigger%> <Hotkey ScrollLockOn Ctrl B, 0-9, Plus, Minus> <SendLabel w1, w2, w3> <Key %Trigger%> <MovementHotkey ScrollLockOn S, down> <SendLabel w1, w2, w3> <Key %Trigger%> <Command DelayedToggleWin> <SendPC local> <TargetWin %1%> <SetActiveWin> <Hotkey ScrollLockOn Shift Ctrl F8> <DelayedToggleWin wow1> <Hotkey ScrollLockOn Shift Ctrl F9> <DelayedToggleWin wow2> <Hotkey ScrollLockOn Shift Ctrl F10> <DelayedToggleWin wow3> <Hotkey ScrollLockOn Shift Ctrl F11> <If ActiveWinIs wow1> <DelayedToggleWin wow2> <Else If ActiveWinIs wow2> <DelayedToggleWin wow3> <Else> <DelayedToggleWin wow1>
Last edited by raikodin : 08-19-2019 at 09:06 PM Reason: added working configuration
Connect With Us