CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2005
    Posts
    38

    Sending keystrokes to IrfanView?

    I have to update 1000+ JPG images by modifying the IPTC info stored inside the pictures.
    One of the tools I can use to update this info is IrfanView. After opening the image, hitting Ctrl-i brings up the IPTC info screen.

    I already have written the code (in VB6) that allows me to identify the pictures where the IPTC is missing or incomplete and also the code needed to start IrfanView en open the concerned picture automatically.
    I now want to send a Ctrl-i (and later on also the 4 tabs following this key combination) so that it also opens the IPTC window and tabs to the correct field.
    I tried to do this with the SendMessage function but IrfanView seems to ignore what I'm sending it.

    The value returned is zero.
    Checking the last error message reveals nothing special (normal completion).
    I include some of the code I used below.

    Code:
        ' Load startupinfo control block
        StrtInfo.cb = Len(StrtInfo)
        StrtInfo.dwFlags = STARTF_USESHOWWINDOW
        StrtInfo.wShowWindow = SW_SHOWMAXIMIZED
        
        ' Create process
        iSts = CreateProcess(vbNullString, _
                    xProgramSpec + " " + xPictureSpec, _
                    ByVal 0&, _
                    ByVal 0&, _
                    False, _
                    NORMAL_PRIORITY_CLASS, _
                    ByVal 0&, _
                    vbNullString, _
                    StrtInfo, _
                    ProcInfo)
        Debug.Print "Status after CreateProcess = "; iSts
        If iSts = 0 Then Exit Sub
                                 
        ' Wait for the process
        iSts = WaitForInputIdle(ProcInfo.hProcess, INFINITE) ' consider replacing INFINITE by 5000 = 5 seconds (or less)
        Debug.Print "Status after WaitForInputIdle = "; iSts
        If iSts <> 0 Then Exit Sub ' SURPRISE! Status 0 means success in this case ...
        
        ' Use FindWindow to get a handle on the window
        iWindowHandle = FindWindow(vbNullString, "depesseroey_antoon.jpg - IrfanView") ' hardcoded for test purposes
        Debug.Print "Handle found with FindWindow = "; iWindowHandle
        If iWindowHandle = 0 Then Exit Sub
      
        ' Send <Ctrl><i> to bring up the IPTC information window
        ' Testing RetVal has no sense.  SendMessage returns whatever it gets from the window.
        RetVal = SendMessage(iWindowHandle, WM_KEYDOWN, VK_CONTROL, 0)
        RetVal = SendMessage(iWindowHandle, WM_KEYDOWN, Asc("i"), 0)
        RetVal = SendMessage(iWindowHandle, WM_KEYUP, Asc("i"), 0)
        RetVal = SendMessage(iWindowHandle, WM_KEYUP, VK_CONTROL, 0)
    Anybody around having succeeded communicating with IrfanView through SendMessage?
    Thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Sending keystrokes to IrfanView?

    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Mar 2005
    Posts
    38

    Re: Sending keystrokes to IrfanView?

    Hi dglienna. Nice to see you are still very active on this forum.

    The processing I need is of a different kind. Nothing to do with batch conversion.
    I have to identify keywords on the pictures (these are scanned death certificates) and define tags identifying names, dates, places, etc.
    The program I have allows to input the tag texts, formats them and copies all of this to the clipboard.
    I then need to get the picture in update ITPC mode and store the infomation.
    I could save 4 or 5 mouse clicks per document if I were able to use the SendMessage function.

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Sending keystrokes to IrfanView?

    What program are you talking about then?
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    Join Date
    Mar 2005
    Posts
    38

    Re: Sending keystrokes to IrfanView?

    Well, in short, I have written a VB6 program that I now want to communicate with IrfanView in order to send it a few keystrokes. But IrfanView does not seem to respond to this.

    So I can only repeat my basic question: Anybody around having succeeded communicating from a VB6 program to IrfanView through SendMessage? If yes how?

    Thanks

  6. #6
    Join Date
    Mar 2005
    Posts
    38

    Re: Sending keystrokes to IrfanView?

    I replaced the SendMessage functions by SendKeys and it works ...
    Don't ask me why.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured