DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: set focus in "file name" control?  (Read 16,419 times)

rshory

  • Participant
  • Joined in 2012
  • *
  • Posts: 4
set focus in "file name" control?
« on: August 26, 2012, 05:52 AM »
Is there a dialog extender that will set focus to the "file name" control, so I can just start typing the file name without clicking there first? I have tried several and none of them do this. I have software for my scanner (HP PrecisionScan Pro) which worked fine under Windows XP. However, under Windows 7, the File Save dialog comes up with the focus set evidently nowhere. I have to either explicitly click in the "File Name" control, or press <Tab> four times first, before I can start typing the file name. This seems trivial, but it more than doubles the effort of saving a file.
The dialog extenders I've tried do all sorts of cool things, but none of them have this simple option. Does anyone know another way to make this happen, besides a dialog extender? Or how I would write my own dialog extender?

skwire

  • I eat Coding Snacks for breakfast...
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,297
    • Participated in NANY Challenge Seventeen Times
    • Coding Snacks
    • Superboy Coder
    • Cody Award
    • Volunteers/Staff
    • Gathering Badge
Re: set focus in "file name" control?
« Reply #1 on: August 26, 2012, 02:03 PM »
Hi, rshory, and welcome to the DonationCoder site.  The extender that I use, FlashFolder, works like you describe (for me anyway =]).

rjbull

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 3,217
Re: set focus in "file name" control?
« Reply #2 on: August 26, 2012, 08:05 PM »
Have you tried Listary?

rshory

  • Participant
  • Joined in 2012
  • *
  • Posts: 4
Re: set focus in "file name" control?
« Reply #3 on: September 03, 2012, 03:19 PM »
Neither "FlashFolder" nor "Listary" did what I wanted.

tomos

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 11,970
    • Gathering Badge
    • Participated in NANY Challenge Once
Re: set focus in "file name" control?
« Reply #4 on: September 03, 2012, 07:27 PM »
I have tried several and none of them do this. I have software for my scanner (HP PrecisionScan Pro) which worked fine under Windows XP. However, under Windows 7, the File Save dialog comes up with the focus set evidently nowhere.

have you tried running the problem software in XP compatibility mode?
Tom

rshory

  • Participant
  • Joined in 2012
  • *
  • Posts: 4
Re: set focus in "file name" control?
« Reply #5 on: September 07, 2012, 01:52 PM »
I tried every compatibility mode back to Windows 95. No difference.

rjbull

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 3,217
Re: set focus in "file name" control?
« Reply #6 on: September 07, 2012, 08:49 PM »
Is it possible to write a macro in AHK, AutoIt, PowerPro or something, that will watch for the appropriate window, and put the cursor in the right location whenever it first appears?

rshory

  • Participant
  • Joined in 2012
  • *
  • Posts: 4
Re: set focus in "file name" control?
« Reply #7 on: September 12, 2012, 03:40 AM »
Well, like everything in computers "it's easy -- after you know how".

Of the three scripting suggestions, I chose AutoIt at random. It took me about a day to learn enough to write the few lines of code I needed. Here it is, with all my debugging comments still in. I just start it in the background, and then kill the process after I'm done scanning; or leave it running till next time.

Code: (generic)
While 1
	$handle = WinWaitActive("Save As", "File &name:") ; listen for Save As dialog
;	MsgBox(0, "Event", "Save As window active")
	If (WinExists("HP Precisionscan Pro") = 1) Then ; is the parent app running?
        ; assure the app is indeed the parent of this Save As dialog
		$HPPsPHandle = WinGetHandle("HP Precisionscan Pro")
;		msgbox(0,"PS handle", $HPPsPHandle)
		$result = DllCall("user32.dll", "int", "GetParent", "hwnd", $handle)
;		msgbox(0,"Result0",$result[0])
;		msgbox(0,"Result1",$result[1])
        ; parent handle is in hex, and result in decimal, but equality works
		If ($result[0] = $HPPsPHandle) Then
;			msgbox (0,"OK", "They match")
			Send("!n") ; send Alt-n to set focus to File Name control
		EndIf
	EndIf
	; wiat till the dialog closes, so as not to re-fire
	WinWaitClose($handle)
WEnd

Original address: https://www.donationcoder.com/forum/index.php?topic=32059.0