topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Tuesday April 16, 2024, 1:20 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: DONE: Allow input commands to be sent to background windows.  (Read 24624 times)

big_smile

  • Participant
  • Joined in 2009
  • *
  • default avatar
  • Posts: 3
    • View Profile
    • Donate to Member
On Windows XP, when a window is not the active focus, it is not possible to input commands to it.

I think it would be great if someone could write a programme that allows input commands to be sent to a background window
(or alternatively a programme that allows more than one window to have the active focus).

This would be handy for:
--Video game emulation - Two emulators could be opened on one machine allowing two players to play at the same time (thus turning any 1 player game into a 2 player contest to see who could reach the end of a level first)
--Being able to input commands into a background programme that is open all the time (e.g. refreshing a web browser) while still working in a main application (e.g. typing a letter in Microsoft Word) without having to click on the background application.

It mustn't be too complex, as programmes like key loggers are able to accept inputs without being at the foreground. (Although not being a programmer I shouldn't really comment on the complexity!)  ^_^

wr975

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 369
    • View Profile
    • Donate to Member
Re: IDEA: Allow input commands to be sent to background windows.
« Reply #1 on: May 10, 2009, 06:21 AM »
> --Video game emulation ...

 :tellme:

> ...without having to click on the background application

Use TweakUI to activate the x-mouse setting (http://articles.tech...0878_11-5082157.html) or change the registry (http://www.pctools.c.../registry/detail/18/).

In Vista this feature is part of the OS (Control Panel > Ease of Access Center > Make the mouse easier to use)

Ampa

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 592
  • I am cute ;)
    • View Profile
    • MonkeyDash - 2 Player strategy boardgame
    • Donate to Member
Re: IDEA: Allow input commands to be sent to background windows.
« Reply #2 on: May 10, 2009, 07:00 AM »
It think that big_smile is probably refering to keyboard input, rather than mouse input, so wr975's suggestions don't quite fit the bill.

Here are some potential problems with the idea...

* Keyboard hardware is designed to accept a few keys being pressed at at time. Having 2 players at the same keyboard doubles the number of inputs that must be handled and I don't think that the hardware is up to it.

* How does the software know which keys to send to which application? Presumably I'd have to configure it for each combination of programs that I want to use.

* What if I need to send the same key to different applications, at different times? eg I have two browsers open and I hit F5 to refresh... which browser gets refreshed?

Perhaps you should seek better solutions to the problems you bring up...

* Opera (and probably other modern browsers) allow you to set an auto refresh time for each tab, removing the need to manually refresh the page at intervals.

* Look for an emulator that already incorporates 2 players, or one that will allow a network connection to play the game on 2 machines?

Ampa

skrommel

  • Fastest code in the west
  • Developer
  • Joined in 2005
  • ***
  • Posts: 933
    • View Profile
    • 1 Hour Software by skrommel
    • Donate to Member
Re: IDEA: Allow input commands to be sent to background windows.
« Reply #3 on: May 11, 2009, 04:57 AM »
 :) Try WriteThere!

It redirects all keyboard input to one window.
Click inside the target window and press F1 to redirect the input to it.
Press F1 twice fast to disable WriteThere.

Example:
Open Internet Explorer and Notepad, and place them side by side. Click inside Notepad and press F1 to redirect the keyboard. Now you can navigate your browser using the mouse, but everyting your write will end up in Notepad! 

This is a beta if ever there was one! There's probably a lot of keys missing, it doesn't work with all programs, it disables global hotkeys, and so on.

Skrommel


;WriteThere.ahk
; Redirect all keyboard input to one window.
; Click the target window and press F1 to redirect.
; Press F1 twice fast to disable.
;Skrommel 2009

#NoEnv
#Persistent,On
#SingleInstance,Force
SetWinDelay,0
SetControlDelay,0
SetBatchLines,-1
SendMode,Input
;SetKeyDelay,0

hotkeys=0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,æ,ø,å,LCtrl,RCtrl,LShift,RShift,LAlt,RAlt,LWin,RWin,Appskey,Left,Right,Up,Down,Tab,PgUp,PgDn,Home,End,Delete,Insert,Esc,Space,BackSpace,Enter,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,!,?,+,-,_,*,/,\,(,),{,[,],},<,>,|,&,§,@,$,£,#,¤,µ,^,~,¨,´,',.,:,`%,``,`",`;

TOOLTIPON("WriteThere`n`nRedirect all keyboard input to one window.`nClick the target window and press F1 to redirect.`nPress F1 twice fast to disable.`n`nwww.1HourSoftware.com",10)
Return


TOGGLEHOTKEYS:
If enabled<>On
  enabled=On
Else
  enabled=Off
TOOLTIPON("WriteThere " enabled)
Loop,Parse,hotkeys,`,
{
  Hotkey,$*%A_LoopField%,SEND,%enabled%
  Hotkey,$*%A_LoopField% Up,SEND,%enabled%
}
Hotkey,$*`,,SEND,%enabled%
Hotkey,$*`, Up,SEND,%enabled%
Return


SEND:
;TOOLTIPON(A_ThisHotkey)
StringTrimLeft,key,A_ThisHotkey,2
ControlSend,%ctrl%,{%key%},ahk_id %win%
Return


F1::
If enabled=On
If A_PriorHotkey=F1
If A_TimeSincePriorHotkey<999
{
  Gosub,TOGGLEHOTKEYS
  Return
}

If enabled<>On
  Gosub,TOGGLEHOTKEYS

win:=WinExist("A")
Loop
{
  parent:=DllCall("GetParent",UInt,win)
  If parent=0
    Break
  win:=parent
}

ControlGetFocus,ctrl,ahk_id %win%
winGetClass,class,ahk_id %win%
TOOLTIPON("Keyboard redirected to `n" ctrl " in `n" class)
Return


TOOLTIPON(tip,delay=3)
{
  ToolTip,%tip%
  SetTimer,TOOLTIPOFF,% delay*-1000
}


TOOLTIPOFF:
ToolTip,
Return
« Last Edit: May 11, 2009, 05:02 AM by skrommel »

big_smile

  • Participant
  • Joined in 2009
  • *
  • default avatar
  • Posts: 3
    • View Profile
    • Donate to Member
Re: IDEA: Allow input commands to be sent to background windows.
« Reply #4 on: May 11, 2009, 01:05 PM »
That's great for the second scenario I posted, but I would really like a solution to the first scenario (of using two game emualtors).

Is there anyway to make it direct all input to two windows?

With a game emulator, there isn't the problem of having wrong commands being sent to the wrong window, as you can set the each emulator to ignore commands.
(For example, you can tell emulator window 1 to execute the 'jump' command when the A key is pressed and tell emulator window 2 to execute the jump command when the B key is pressed.
It doesn't matter if emulator 2 receives the A key command, because it will only execute a jump when it receives a B key input).

skrommel

  • Fastest code in the west
  • Developer
  • Joined in 2005
  • ***
  • Posts: 933
    • View Profile
    • 1 Hour Software by skrommel
    • Donate to Member
Re: IDEA: Allow input commands to be sent to background windows.
« Reply #5 on: May 11, 2009, 01:16 PM »
 :) It could easily be done. Just make two separete scripts, edit the hotkeys= in each of them, and give each it's own redirect hotkey. But I'm uncertain if it will work properly, the last key pressed will probably overrule the other ones...

Skrommel
« Last Edit: May 11, 2009, 01:25 PM by skrommel »

big_smile

  • Participant
  • Joined in 2009
  • *
  • default avatar
  • Posts: 3
    • View Profile
    • Donate to Member
Re: IDEA: Allow input commands to be sent to background windows.
« Reply #6 on: May 27, 2009, 01:09 PM »
Hi
How do I use the script.

I have tried to figure it out on my own but haven't got very far.

Thanks!

skrommel

  • Fastest code in the west
  • Developer
  • Joined in 2005
  • ***
  • Posts: 933
    • View Profile
    • 1 Hour Software by skrommel
    • Donate to Member
Re: IDEA: Allow input commands to be sent to background windows.
« Reply #7 on: May 31, 2009, 03:22 PM »
 :) Go to www.autohotkey.com and download AutohotkeyInstaller. Install it, download the script, save it to WriteThere.ahk. Doubleclick it to run it.

Open Internet Explorer and Notepad, and place them side by side. Click inside Notepad and press F1 to redirect the keyboard. Now you can navigate your browser using the mouse, but everyting your write will end up in Notepad!

Skrommel

937o5

  • Participant
  • Joined in 2009
  • *
  • default avatar
  • Posts: 14
    • View Profile
    • Donate to Member
Re: IDEA: Allow input commands to be sent to background windows.
« Reply #8 on: September 29, 2009, 12:06 PM »
I was wondering... Would anyone here be willing to make this much more compatable with other applications? Like... Texter was coded with AHK scripts, and it works just fine in any program I've tested it on, even games. Couldn't this be changed to input the text the same way texter does? In turn making it more compatable with random programs out there.

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: IDEA: Allow input commands to be sent to background windows.
« Reply #9 on: September 30, 2009, 08:06 AM »
there is a similar program by jgpaiva here and a exe version which you can try out, if you wish.

edit by jgpaiva: fixed link
« Last Edit: September 30, 2009, 08:20 AM by jgpaiva »

937o5

  • Participant
  • Joined in 2009
  • *
  • default avatar
  • Posts: 14
    • View Profile
    • Donate to Member
Re: IDEA: Allow input commands to be sent to background windows.
« Reply #10 on: September 30, 2009, 08:15 AM »
Ohhh! That one works like I had hoped, but I don't need to select multiple windows.. And I'm trying to make the main window I'm working with not lose focus... Maybe I might be able to make some edits and try to make WriteThere work like that, and be able to toggle WriteThere on and off with a different hotkey, so no more double-tapping F1...

Actually, I just had an idea. I think WriteThere and the other script could be used together to send data to other windows the way I want! But... Would someone mind modding a version of WriteThere to use F1 to capture a window, and F2 to toggle the input redirect on and off?... Or maybe customizable hotkeys?... I just need them to be different, so I can capture what window I want, and only send text when I want to, without losing focus on the main window..
« Last Edit: September 30, 2009, 08:21 AM by 937o5 »

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: IDEA: Allow input commands to be sent to background windows.
« Reply #11 on: September 30, 2009, 08:21 AM »
that's the beauty of AHK, you can pick the best of the bunch to suit your needs.. take a look at both sources and maybe you can come with something. :)

937o5

  • Participant
  • Joined in 2009
  • *
  • default avatar
  • Posts: 14
    • View Profile
    • Donate to Member
Re: IDEA: Allow input commands to be sent to background windows.
« Reply #12 on: September 30, 2009, 08:22 AM »
If I get this working, I'll post the hybrid code up. =P

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: IDEA: Allow input commands to be sent to background windows.
« Reply #13 on: September 30, 2009, 08:37 AM »
good luck.. :)

Curt

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 7,566
    • View Profile
    • Donate to Member
Re: IDEA: Allow input commands to be sent to background windows.
« Reply #14 on: January 02, 2011, 10:23 AM »
WriteThere works in my setup, but is buggy: NO spaces at all. Everythingisoneverylongword.

Did any one use it with success?  :tellme:  I like the program's idea very much.