Active window keeps switching to command window

Hi,

I just upgraded to Igor7 on PC, and have found one feature frustrating. I have functions written that run through keyboard hooks (ie. typing "a" runs function "go()") , but in the new Igor, anytime I type a character in any other active window, the command window pops up as the active window and they character is typed into the command line. Any ideas on how to work around this?

Thanks and best,
Daniel
Let's see your hook function; is it returning 0 or 1?

--Jim Prouty
Software Engineer, WaveMetrics, Inc.
Thanks Jim! That's actually all the help I needed. This previous procedure ended with "return 0", and just changing that to "return 1" solves the problem.


SetWindow AnalysisWindow,hook(testhook)=KeyboardPanelHook

Function KeyboardPanelHook(s)  
    STRUCT WMWinHookStruct &s      
        if(stringmatch(winname(0,3),"AnalysisWindow"))
            switch(s.eventCode)    
                case 11:                    // keyboard hook
                    switch(s.keycode)
                        case 97:            //key "a"              
                                print "hi"
                            break
                        case 98:            //key "b"
                                print "bye"
                            break  
                    endswitch
            endswitch
        endif
    return 1            // changed from "return 0"
end

I suggest you return 1 only in the case that the event is a keyboard event and is one that you "handled".

0 means "didn't handle it, let Igor do the default action."
1 means "I handled it, Igor should not".

It looks like your code is claiming to handle all events that a hook function is called for.

This is unlikely to be what you want.

--Jim Prouty
Software Engineer, WaveMetrics, Inc.