Source language: Translate to:

Active Window

Questions about NeoBook PlugIns

Moderator: Neosoft Support

Active Window

Postby Bernardo » Sun Feb 08, 2009 7:26 am

Hi everybody,

I would like to ask you all about a way to find whats the current active window. I tried the autoitdll, but I would like to detect the current one with the focus, dont want to find a window or process by name (knowing the name of the process). Just want to detect the title of the current window with the focus.

Any help is greatly appreciated. Thanks
All the best
Bernardo
Bernardo
 
Posts: 62
Joined: Mon Nov 06, 2006 2:35 pm

Postby HPW » Sun Feb 08, 2009 7:36 am

How did you try it?


This works for me:
hpwAutoItWinGetActiveTitle "[PubDir]" "[Result]"
Hans-Peter
User avatar
HPW
 
Posts: 2510
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany

Postby Bernardo » Sun Feb 08, 2009 8:00 am

Thanks Hans,

I am using this code you said. Together with

Code: Select all
hpwAutoItSend "[PubDir]" "Key or shortcut"


But the problem is when I click on the active window to send a key or shortcut it loses the focus. It goes back to my main NB app. Its supposed to send keys to other app. I cant use a nameofthesoftware.exe because it varies.
Bernardo
 
Posts: 62
Joined: Mon Nov 06, 2006 2:35 pm

Postby HPW » Sun Feb 08, 2009 12:11 pm

It is not clear to me what you want to do?

hpwAutoItWinGetActiveTitle "[PubDir]" "[Result]"

This work when your app is in the background and it returns the window title of the active window.
So your code has run in the background and the action has been triggered by a timer for example.

When you want to send a key by clicking your app, you must use hpwAutoItWinActivate before hpwAutoItSend to set back the focus to the target-window.
Hans-Peter
User avatar
HPW
 
Posts: 2510
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany

Postby Bernardo » Sun Feb 08, 2009 1:21 pm

Thanks again for the info. The timer and the activate command after getting the title of the window were the solution :). I added the timer to check the active window and then sent the desired keys/shortcuts.

Much appreciated and thx for the nice plugin,

All the best
Bernardo
Bernardo
 
Posts: 62
Joined: Mon Nov 06, 2006 2:35 pm

Re: Active Window with HPW a

Postby schmutly » Sun Aug 10, 2014 4:23 am

Hi Hans and maybe David (as using the npHook)...and HPWSendKeys1.23
Basically in NeoBook its a pain going to yellow OPEN icon or file OPEN or CTRL+o so i'm trying to make a little taskbar app that i
run only wen using NB. As i DONT use my middle mouse button i want toi use the WM_MBUTTONDOWN Event to set
focus to NeoBook and hpwSendKeysToHandle etc to OPEn the open-Dialog window.
It sorta works IF i run it from Neobook but if i compile it , doesnt work..it seems to bring the neobook Program to front but no popup.
I have used :
In the APPs enterpage:
hpwFindAWindow "NeoBook 5 Pro" "" "[neobookHANDLE]"
.Start the low level mouse hook
npHookMouseStart "[Result]"
npOnMouseHook "OnMouseHook" "[Event]" "[XPos]" "[YPos]" "[Data]"

And then for the Subroutine:
:OnMouseHook
If "[Event]" "=" "WM_MBUTTONDOWN"
npSetWindowOnTop "[neobookHANDLE]" "True" ""
hpwFocusWindow "[neobookHANDLE]"
hpwSendKeysToHandle "[neobookHANDLE]" "^o"
endif
Return

Can anyone see what i'm doing wrong?
Rob
schmutly
 
Posts: 217
Joined: Fri Feb 20, 2009 4:16 pm

Re: Active Window

Postby HPW » Sun Aug 10, 2014 5:18 am

Hello,

Have you debugged all steps?

If so and you are sure everything else is ok then it might be:
Code: Select all
hpwSendKeysToHandle "[neobookHANDLE]" "[#252]o[#253]"


Regards
Hans-Peter
User avatar
HPW
 
Posts: 2510
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany

Re: Active Window

Postby schmutly » Sun Aug 10, 2014 6:40 am

Hi Hans,
i changed it to hpwSendKeysToHandle "[neobookHANDLE]" "[#252]o" and its works IF
i click on the app first them minimize it...then if i go to NeoBook i can middle-mouse click
and it brings up the dialog.
But its intermittent....NOW i sometimes get
Image

In fact im thinking there's a problem with npHook as NOW,without doing anything im getting a horrible
window that comes up and the only way i got rid of it last time was reinstall...windows, NOT NB as this
error below never went away and Dave couldn't reproduce it BUT its odd that its the first time its come
up since 1yr and all i done different in NB was try to get this going today...
Image

Leave it with me...getting late here and tomorrow morn will try other NB apps to make sure i don't get this module
error and hopefully only related to THIS app (i think it was when when i tried to run NBPro a year ago got a module
error so went with Win7 64bit and no probs all this time till just NOW.
Spock would say: "..its logical thats its something with what i was doing tonight" so i will SLEEP on it and try tomorrow.
Thanks for the help.

Rob
schmutly
 
Posts: 217
Joined: Fri Feb 20, 2009 4:16 pm

Re: Active Window

Postby dec » Sun Aug 10, 2014 9:01 am

Hello,

In fact im thinking there's a problem with npHook as NOW,without doing anything im getting a horrible
window that comes up and the only way i got rid of it last time was reinstall...windows,


I am sorry for that, but honestly I can't imagine how the npHook plugin can cause the need to reinstall Windows. Anyway, try to stop the hook in the "OnMouseHook" event, do whatever you wanted, and then start the hook again. Remember anyway this is a system wide hook, and therefore their events can not be the best place to do certain things like show dialogs, etc. The hook never stop even if your publication do not have the user focus, and therefore lots of events can cause the plugin to crash.
.
Enhance your NeoBook applications!
.
57 plugins, 1113 actions and 230 samples
.
NeoPlugins website: www.neoplugins.com
.
User avatar
dec
 
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain

Re: Active Window

Postby HPW » Sun Aug 10, 2014 9:39 am

Hello,

I had edited my last post to:

Code: Select all
hpwSendKeysToHandle "[neobookHANDLE]" "[#252]o[#253]"


Use the #253 for CTRL_UP so that following loik gets not confused with a pressed CTRL-key.

Regards
Hans-Peter
User avatar
HPW
 
Posts: 2510
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany

Re: Active Window

Postby schmutly » Sun Aug 10, 2014 6:41 pm

dec wrote:Hello,


In fact im thinking there's a problem with npHook as NOW.
Sorry David, bad English. I didn't mean the plugin
but referring to MY USE of the nphook..in that im using it wrong and one of MY events are causing things to crash.
Maybe the reinstall sounds extreme and this morning i tried my most important PUB, the dvd library, but it works
thank goodness..last year i had to reinstall OS simply because that "module" error would not allow me to use NB at ALL
for anything..reinstalling NB didn't fix module error and i installed NB "FRESH" with no plugins and only installed the
NBPro DB which needed but the "module" error was still there (AND i didn't have my "restore points" enabled so did
what i had to do.
The Hook being system wide hook,i think, is what i actually want eventually to so i can use it if i have Photoshop open
or a few others i need it on...and a shortcut key to turn off, but its mainly want to run it when i exclusively work on a
few programs.
Finally, all your plugins and Hans and ALL of them i think are 'never' a problem, it's always my lack of experience and
understanding and sometimes my frustration :lol:

HPW wrote:Hello,
I had edited my last post to:
Code: Select all
hpwSendKeysToHandle "[neobookHANDLE]" "[#252]o[#253]"

Use the #253 for CTRL_UP so that following loik gets not confused with a pressed CTRL-key.
Regards


Hi Hans,
ok...i discovered that [#252]o OR [#252]o[#253] OR ^o had varying times it worked and sometimes strangely
gave invalid keyname ( even with [#252]o[#253] also) BUT....as i said to David, it's probably ME so let me do what you
said here again Hans and leave it as [#252]o[#253] then i will look at why I'm getting what i am.

It's just strange to me why it works well within NB after a F9 run but when compile getting this oddness.
Will post back here once i have had time to REDO it again (although hardly anything in the pub except an npHook and
the other HPW actions i posted so its basic BASIC pub with one job in mind)

Later...and thanks for your help..let you know :)
Rob
schmutly
 
Posts: 217
Joined: Fri Feb 20, 2009 4:16 pm

Re: Active Window

Postby dec » Mon Aug 11, 2014 8:25 am

Hello,

Don't worry Rob. Anyway you need to take care about what you do in a hook event. In general you can't show a user dialog, since the event can be executed very quickly lot of times, and this can cause some problems and errors. If you need to show a user dialog in a hook event, stop the hook before show the dialog, and start the hook again once the dialog is closed.
.
Enhance your NeoBook applications!
.
57 plugins, 1113 actions and 230 samples
.
NeoPlugins website: www.neoplugins.com
.
User avatar
dec
 
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain

Re: Active Window

Postby schmutly » Mon Aug 11, 2014 9:08 am

Hi David,
not sure what you mean as im using the hook and when middle mouse click it runs the
hook subroutine to sendkeys ctrl+o so how do i stop the hook first if its needed for the
action to run? Can u explain where to place it, i thought it needs to run all the time to
monitor for mouse activity!?
Rob
schmutly
 
Posts: 217
Joined: Fri Feb 20, 2009 4:16 pm

Re: Active Window

Postby dec » Mon Aug 11, 2014 10:45 am

Hello,

You can try by stop/start the hook in the event subroutine. Something like:

Code: Select all
:MyHookEventSubrutine

  Stop the hook here

  Do whatever you wanted here

  Start the hook again if you need

Return
.
Enhance your NeoBook applications!
.
57 plugins, 1113 actions and 230 samples
.
NeoPlugins website: www.neoplugins.com
.
User avatar
dec
 
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain

Re: Active Window

Postby schmutly » Mon Aug 11, 2014 5:23 pm

Understand,
thanks,
Rob
schmutly
 
Posts: 217
Joined: Fri Feb 20, 2009 4:16 pm

Next

Return to PlugIn Discussions

Who is online

Users browsing this forum: Bing [Bot] and 2 guests