-
October 21st, 2013, 10:49 AM
#1
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.
-
October 21st, 2013, 01:51 PM
#2
Re: Sending keystrokes to IrfanView?
-
October 21st, 2013, 02:00 PM
#3
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.
-
October 21st, 2013, 10:17 PM
#4
Re: Sending keystrokes to IrfanView?
What program are you talking about then?
-
October 22nd, 2013, 04:25 AM
#5
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
-
October 22nd, 2013, 05:49 AM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|