BBC BASIC for Windows
Programming >> BBC BASIC language >> Necessity to use mouse to activate program.
http://bb4w.conforums.com/index.cgi?board=language&action=display&num=1436576542

Necessity to use mouse to activate program.
Post by TheFamousCash on Jul 11th, 2015, 01:02am

I transferred a program which has run successfully for years to a Dell OptiPlex 3030 all-in-one when the original computer failed.
When the program is a run from a shortcut in "startup" folder, the first screen awaits input from the user to enter ID.
The problem with this computer is, the keyboard is disabled and only activates when a mouse is connected and clicked anywhere on the screen.
I ran three other programs, including an "empty" one and all failed to accept keyboard input until the mouse was clicked.
Obviously, I would like to avoid this, (The dedicated system does not even have a mouse connected under normal usage.)
If anyone has experienced this, or may offer a solution, I would be grateful to hear from them.
Thanks,
Bob.

Re: Necessity to use mouse to activate program.
Post by rtr2 on Jul 11th, 2015, 07:40am

on Jul 11th, 2015, 01:02am, TheFamousCash wrote:
The problem with this computer is, the keyboard is disabled and only activates when a mouse is connected and clicked anywhere on the screen.

In private correspondence Bob has confirmed that the text caret (cursor) is present and flashing at the time, suggesting that the window does have the input focus.

He has also tried the following code as a workaround, but it was ineffective:

Code:
      INSTALL @lib$+"WINLIB5"
      PROC_setfocus(@hwnd%) 

This is a strange fault indeed.

Richard.
Re: Necessity to use mouse to activate program.
Post by ady on Jul 11th, 2015, 08:50am

Cycle with the tab button?

Alt-Esc?
Re: Necessity to use mouse to activate program.
Post by rtr2 on Jul 11th, 2015, 09:55am

on Jul 11th, 2015, 08:50am, ady wrote:
Cycle with the tab button? Alt-Esc?

Certainly worth trying as a workaround, but obviously not a 'solution' as such since it requires operator action that should not be needed.

Some more things for Bob to try, as much as a diagnostic aid than a workaround (clearly they should not be necessary):

1. Code:
      SYS "SetForegroundWindow", @hwnd% 

2. Code:
      SYS "BringWindowToTop", @hwnd% 

If neither of those work try these more complicated variants:

3. Code:
      SYS "GetWindowThreadProcessId", @hwnd%, 0 TO W%
      SYS "GetCurrentThreadId" TO O%
      SYS "AttachThreadInput", O%, W%, TRUE
      SYS "SetForegroundWindow", @hwnd%
      SYS "AttachThreadInput", O%, W%, FALSE 

4. Code:
      SYS "GetWindowThreadProcessId", @hwnd%, 0 TO W%
      SYS "GetCurrentThreadId" TO O%
      SYS "AttachThreadInput", O%, W%, TRUE
      SYS "BringWindowToTop", @hwnd%
      SYS "AttachThreadInput", O%, W%, FALSE 

Richard.

Re: Necessity to use mouse to activate program.
Post by TheFamousCash on Jul 11th, 2015, 12:49pm

Many thanks for the responses.
I will try implementing the suggestions.
The program is used from 7.45am to 2.30am seven days a week and it is difficult to gain access for experiments when the owner is more than happy as it stands and reluctant to permit interruption.
I will advise of progress.
Thanks,
Bob.

Re: Necessity to use mouse to activate program.
Post by rtr2 on Jul 11th, 2015, 1:59pm

on Jul 11th, 2015, 12:49pm, TheFamousCash wrote:
The program is used from 7.45am to 2.30am seven days a week

If it's as hot there as it is here (26.2 C at the moment and rising) you might appreciate some night shifts.... tongue

Richard.

Re: Necessity to use mouse to activate program.
Post by TheFamousCash on Jul 11th, 2015, 2:12pm

Richard, since my days of running casino when I retired in 1981, I always go to bed around 5 or 6 am. . . No problem for me.
I program using your fantastic BB4W from midnight each night.
I never get bored experimenting. Done it for years since I used to program BBC Master Series.
Regards,
Bob.