Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

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

Login with username, password and session length
  • December 08, 2016, 10:14:49 AM
  • Proudly celebrating 10 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: IDEA: launch application upon focusing a GUI element  (Read 5428 times)

gjehle

  • Member
  • Joined in 2006
  • **
  • Posts: 286
  • lonesome linux warrior
    • View Profile
    • Open Source Corner
    • Read more about this member.
    • Donate to Member
IDEA: launch application upon focusing a GUI element
« on: October 23, 2007, 07:44:23 AM »
ok, this might sound a bit confusing, let me elaborate.
mouser suggested i post it in here (original: http://www.donationc...ex.php?topic=10517.0)

environment:
  • windows XP / 2000
  • touch-screen display (for windows this is just a simple mouse)
  • 2 applications (A and OSK)
    A: random application with GUI
    OSK: on-screen-keyboard

the idea:
  • monitor A's GUI
  • launch/unhide OSK as soon as focus is given to an edit control (usually needs keyboard input)
  • if edit control looses focus (or OSK has no more GUI-clicking going on, aka timeout) close/hide OSK

candy:
  • make this work global for all running apps
  • make it only work for a list of applications
  • make types of controls that trigger the OSK configurable
  • support for arbitrary OSK apps (windows' own, 3rd party)

alternative:
is there any OSK app out there that already does it?
i couldn't find any.

belkira

  • Member
  • Joined in 2006
  • **
  • Posts: 52
    • View Profile
    • Donate to Member
Re: IDEA: launch application upon focusing a GUI element
« Reply #1 on: October 26, 2007, 10:15:17 PM »
Using AHK, I came up with a way to open the osk, but not auto close it. I am no programmer tho so maybe someone can take this code and run with it.....

#Persistent
SetTimer, WatchCursor, 100
return

WatchCursor:
MouseGetPos, , , id, control

StringLeft, control_edit, control, 4 ;The edits are usually Edit1 Edit2 etc so we only want the first 4 chars
if (control_edit = "Edit")
{
run osk.exe
}
return

belkira

  • Member
  • Joined in 2006
  • **
  • Posts: 52
    • View Profile
    • Donate to Member
Re: IDEA: launch application upon focusing a GUI element
« Reply #2 on: October 27, 2007, 12:34:40 AM »
Ok, after playing around a bit I think I may have it. Give this a try and let me know how it works for you.
Again this is in AHK
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
#Persistent
#SingleInstance, Force

SetTimer, WatchControl, 500
return

WatchControl:
ControlGetFocus, a_control, A
StringLeft, activeControl, a_control, 4
; ToolTip, %activeControl%
if (activeControl = "Edit")
ifWinExist, On-Screen Keyboard
return
else
run, osk.exe
if (activeControl <> "Edit")
IfWinExist, On-Screen Keyboard
process, close, osk.exe
else
return
return
« Last Edit: October 27, 2007, 12:48:20 AM by belkira »

gjehle

  • Member
  • Joined in 2006
  • **
  • Posts: 286
  • lonesome linux warrior
    • View Profile
    • Open Source Corner
    • Read more about this member.
    • Donate to Member
Re: IDEA: launch application upon focusing a GUI element
« Reply #3 on: October 27, 2007, 04:38:18 AM »
nice one!
I'll test it if I get the chance next week

f0dder

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 9,029
  • [Well, THAT escalated quickly!]
    • View Profile
    • f0dder's place
    • Read more about this member.
    • Donate to Member
Re: IDEA: launch application upon focusing a GUI element
« Reply #4 on: October 27, 2007, 07:56:51 AM »
Nice idea - too bad if some application has a custom edit control...
- carpe noctem

gjehle

  • Member
  • Joined in 2006
  • **
  • Posts: 286
  • lonesome linux warrior
    • View Profile
    • Open Source Corner
    • Read more about this member.
    • Donate to Member
Re: IDEA: launch application upon focusing a GUI element
« Reply #5 on: October 27, 2007, 11:59:34 AM »
Nice idea - too bad if some application has a custom edit control...

I'm wondering if it works for custom controls inheriting the base edit control.

belkira

  • Member
  • Joined in 2006
  • **
  • Posts: 52
    • View Profile
    • Donate to Member
Re: IDEA: launch application upon focusing a GUI element
« Reply #6 on: October 27, 2007, 01:23:35 PM »
If you run AHK Window Spy Im sure you could find the name of the control and adjust the script accordingly.

I am still in the learning process, so if I think of anything to make it more universal I will update it. I was hoping for some way of saying,
If this field can be typed in, launch osk, but have not yet found that magical ability.

f0dder

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 9,029
  • [Well, THAT escalated quickly!]
    • View Profile
    • f0dder's place
    • Read more about this member.
    • Donate to Member
Re: IDEA: launch application upon focusing a GUI element
« Reply #7 on: October 27, 2007, 06:23:07 PM »
Nice idea - too bad if some application has a custom edit control...

I'm wondering if it works for custom controls inheriting the base edit control.
Subclassed yes, superclassed no.

Of course you can detect other classnames and adjust, but it's annoying - just like getting "scrolled app captures", though not as bad.
- carpe noctem