Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you put the Procomm window on top when WINFOCUS doesn't work?

Status
Not open for further replies.

FastLearner

Technical User
May 10, 2002
17
0
0
US
Winfocus is supposed to change the active window for keyboard input, but it does not seem to be accomplishing that task. See code below...

This code should check for focus every 10 seconds and if Procomm doesn't have it, it should take it.

Run this and while running, click on another app. According to what Procomm can see, it IS changing the focus, but that doesn't mean it's on top?!? Anyone know how to solve this? We can't do much window navigation at all if this command doesn't work.

Code:
proc main
 while 1			;loop indefinitely for test
   pause 10			;wait 10 seconds
   if $FOCUSWIN != $PWMAINWIN	;check if PW has focus
     winfocus $PWMAINWIN	;if not, give it focus
     if $FOCUSWIN != $PWMAINWIN
       usermsg "The focus change failed. I don't know why...."
      else
       usermsg "Focus change was successful! Or was it?"
     endif
   endif
 endwhile
endproc
 
A workaround for this would be to minimize and then restore $PWMAINWIN before the winfocus command. See example below:

Code:
proc main
 while 1                         ;loop indefinitely for test
   pause 10                      ;wait 10 seconds
   if $FOCUSWIN != $PWMAINWIN    ;check if PW has focus

     ; Insert the following
     winminimize $PWMAINWIN      ;Minimize the window
     winrestore $PWMAINWIN       ;Restore the window

     winfocus $PWMAINWIN         ;if not, give it focus
     if $FOCUSWIN != $PWMAINWIN
       usermsg "The focus change failed. I don't know why...."
      else
       usermsg "Focus change was successful! Or was it?"
     endif
   endif
 endwhile
endproc
 
I believe that winmove and winsize commands also cause procomm windows to pop to the front. Of course for these commands you'll need their paramaters but it may be faster than minimize/maximize.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top