Use a Hotkey to Send Keystroke to an Active Window - Auto Fill

Started by Deana, October 04, 2013, 10:04:11 AM

Previous topic - Next topic

Deana

Ever want to use a hotkey to auto fill in fields such as your email address. If so check this out:

Use a Hotkey to Send keys to an Active Window: http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/tsleft.web+WinBatch/Shortcut~Information+Use~a~Hotkey~to~Sendkeys~to~an~Active~Window.txt

Code  winbatch Select
;***************************************************************************
;** 
;**      Get Last Active Window from Windows Shortcut
;** 
;** Purpose: Get Active Window When Launched from a Shortcut Hotkey Trick
;** Inputs: Must be launched from a windows shortcut.
;** Outputs: Get Last Active Window
;** Requirements:  Requires WinBatch 2011B or newer. Requires the Control Manager extender
;** Revisions:  2013.10.4 Deana Falk
;** 
;** NOTES:When you use a desktop shortcut, one of the windows associated with one of the shell's 
;** many threads gets the input focus and that will change the z order.  After that, the focus and 
;** z order top get passed around to different shell threads depending on what the target of the shortcut does.  
;** This script walks the adjacent and child windows until it finds one that is visible and not a shell window 
;** using Control Manger functions.  
;** 
;** 
;***************************************************************************
If Version( ) < '2011B' 
   Pause('Notice', 'Need 2011B or Newer Version of WinBatch')
   Exit 
EndIf

#DefineFunction WinGetLastActive ()
AddExtender("wwctl44i.dll",0,"wwctl64i.dll")
WS_VISIBLE = 268435456 ;0x10000000L
allwins = WinItemize()
For x = 1 to ItemCount(allwins, @tab)
   title = ItemExtract( x, allwins, @tab )
   hwnd = DllHwnd(title)
   style = cWndInfo( hwnd, 20 )
   If (style & WS_VISIBLE)
      If !(StrLower(title)=="start" || StrLower(title)=="program manager")
         state = WinState( title )
         If state == 2 || state == 3 ; not hidden or iconized.
            break      
         Endif
      EndIf
   EndIf
Next
Return title
#EndFunction

activeWin =  WinGetLastActive()
Pause("Debugging - Active Window",activeWin)

SendKeysTo( activeWin, "Hello World" )

Exit
Deana F.
Technical Support
Wilson WindowWare Inc.

kdmoyers

The mind is everything; What you think, you become.