Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Setting mouse to ignore outside of _NewImage
#11
Code: (Select All)
Declare Dynamic Library "user32"
Sub SetForegroundWindow (ByVal hwnd As _Offset) 'set foreground window process(focus)
End Declare

hwnd%& = _WindowHandle
Do
If _WindowHasFocus = _FALSE Then
SetForegroundWindow hwnd%& 'set focus when necessary
Beep
Print "THOUGH SHALL STAY FOCUSED!!!"
End If
_Limit 30
Loop Until _KeyHit = 27 'escape to quit
System

Note that this tends to work intermittently on my OS. Windows says:

Quote:A window cannot be forced to the foreground if the user is actively working in another window. Instead, Windows will flash the taskbar button of the intended window to alert the user.

And, if you try this, you'll notice that's exactly what happens here. If it doesn't automatically restore focus, then it'll blink the icon on your task bar and BEEP incessantly until you swap back over to it.
Reply
#12
I recall that bullshit, too. I thought SetForegroundWindow was what I was looking for a few years back, too, but I got the same useless results you did. BEEP BEEP BEEP... but that wasn't in my program, it was, however, in my very vocal response!

The best you get from using SetForegroundWindow is one return focus as the active window. After that, is does the taskbar blinking shit you mentioned. I don't know why MS thought this would be a useful function, and even more, I don't care why they thought it would be a useful function. If you had the I.Q. of a gnat, you'd be overqualified to work there. Hey, did Clippy come up with this 'feature'

Pete
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  _NEWIMAGE can't accept variables as dimensions? bobalooie 23 915 02-18-2026, 11:16 PM
Last Post: Unseen Machine
  Any other way to ignore the Alt key using the INKEY method? Pete 24 1,385 12-31-2025, 05:24 PM
Last Post: Pete
  Do Loop, Sleep and Mouse Button Dimster 5 579 09-06-2025, 12:57 PM
Last Post: Dimster
  Stopping repeated mouse-key press PhilOfPerth 8 850 09-02-2025, 11:28 PM
Last Post: Pete
  Setting Line _RGB colours PhilOfPerth 10 1,917 11-03-2024, 05:37 AM
Last Post: PhilOfPerth

Forum Jump:


Users browsing this thread: