473,387 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Something tricky!

I have an application that uses a TWAIN activex control. On one
particular scanner driver, I have the option to do a pre-scan. After
doing the pre-scan, my application receives focus again and looks like
it is hanging because the pre-scan window is still open waiting for me
to accept the scan. I can then simply click the prescan window in the
taskbar to open that window and accept the prescan.

I'm wondering if there is a way to look for a particular window that may
have been opened by an activex control and give it focus, or look for
a the name of an application in the taskbar and give it focus... I guess
I just need some sort of hack. Anyone have any ideas?

Thanks,
Dustin
Jun 23 '06 #1
2 1009

You can do this by querying the process list
hth

Michel Posseth [MCP]
"Dustin Davis" <du****@davisvillage.com> schreef in bericht
news:OR****************@TK2MSFTNGP02.phx.gbl...
I have an application that uses a TWAIN activex control. On one particular
scanner driver, I have the option to do a pre-scan. After doing the
pre-scan, my application receives focus again and looks like it is hanging
because the pre-scan window is still open waiting for me to accept the
scan. I can then simply click the prescan window in the taskbar to open
that window and accept the prescan.

I'm wondering if there is a way to look for a particular window that may
have been opened by an activex control and give it focus, or look for a
the name of an application in the taskbar and give it focus... I guess I
just need some sort of hack. Anyone have any ideas?

Thanks,
Dustin

Jun 24 '06 #2
here some example code
( reusable class module i once wrote )
this one is showing msinfo and raises an event when it is closed
documented in dutch but it is pretty simple to understand and it shows what
i mean

Imports System.Diagnostics
Imports Microsoft.Win32
Imports System.Threading
Namespace MPSoft
Public Class clsMsInfo
Private Function exeFile() As String
exeFile = String.Empty
Try
' haal het pad naar MSINFO32.EXE uit het register
Dim key As RegistryKey
key = Registry.LocalMachine.OpenSubKey( _
"SOFTWARE\Microsoft\Shared Tools\MSInfo")
If key Is Nothing Then
Throw New Exception("Registry key not found")
End If
exeFile = key.GetValue("Path", "").ToString()
key.Close()
Finally
If String.IsNullOrEmpty(exeFile) OrElse Not
My.Computer.FileSystem.FileExists(exeFile) Then
'blijkbaar hebben we geen registry access , of de
waardes aldaar zijn corrupt
'we hopen dus maar dat de environment variabelen dit
probleem voor ons oplossen
exeFile = "msinfo32.exe"
End If
End Try
End Function
Public Event MsInfoClosed()
''' <summary>
''' Starts the ms system info dialog and raises an event when closed
''' the prefered start method for this sub is asynchronous ( asynch
delegate )
''' </summary>
Public Sub StartMsInfo()
'start het process
Dim proc As Process = Process.Start(exeFile)

Thread.Sleep(2000) ' pauseer de thread zodat we zeker weten dat
de proces lijst is geupdated

Dim closed As Boolean 'wanneer true dan is de system
information dialog afgesloten

Do Until closed
Thread.Sleep(5)
Dim ref As Boolean
For Each proc In Process.GetProcesses 'loop door de proces
lijst
If proc.ProcessName.Trim = "HelpCtr" Then
ref = True 'gevonden dus weg hier en check opnieuw
Exit For
End If
ref = False
Next
closed = Not ref
Loop
'laat weten dat de info dialog is afgesloten
RaiseEvent MsInfoClosed()
End Sub
Public Event MsinfoRapportCreated(ByVal ReportLocation As String)
''' <summary>
''' Maakt een MS info rapport van het gehele systeem
''' </summary>
''' <param name="outfile">file path voor rapport </param>
Public Sub MsInforapport(Optional ByVal outfile As String =
"c:\Temp\Report.txt")
Try
Dim proc As Process = Process.Start(exeFile, "/report " &
outfile)
' wacht to het proces klaar is (dit kan even duren )
proc.WaitForExit()
RaiseEvent MsinfoRapportCreated(outfile)
Catch ex As Exception
'doe niets
End Try
End Sub
End Class
End Namespace

"Michel Posseth [MCP]" wrote:

You can do this by querying the process list
hth

Michel Posseth [MCP]
"Dustin Davis" <du****@davisvillage.com> schreef in bericht
news:OR****************@TK2MSFTNGP02.phx.gbl...
I have an application that uses a TWAIN activex control. On one particular
scanner driver, I have the option to do a pre-scan. After doing the
pre-scan, my application receives focus again and looks like it is hanging
because the pre-scan window is still open waiting for me to accept the
scan. I can then simply click the prescan window in the taskbar to open
that window and accept the prescan.

I'm wondering if there is a way to look for a particular window that may
have been opened by an activex control and give it focus, or look for a
the name of an application in the taskbar and give it focus... I guess I
just need some sort of hack. Anyone have any ideas?

Thanks,
Dustin


Jun 26 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Lars Plessmann | last post by:
Problem: I try to store data in a objects field and read it out again. Sounds easy, yeah. But its a bit tricky here.... ;-) This is the class Customer.php with some setter and getter functions...
0
by: dracolytch | last post by:
Good day all, Ok, I have a pretty tricky problem that I need some help with. I pass around search query information a fair amount (specifically WHERE statements). Normally, I just rawurlencode()...
4
by: Bung | last post by:
Hi, I have a tricky sql statment I have to write (tricky for me) and I am stuck. I'm having trouble with the following problem. Table1 (Column a, Column b, Column c) Table2 (Column a, Column...
11
by: Ray Godfrey | last post by:
Hi there, Just a simple question, I think. I'm writing a program that takes information from a text file and uses that info to query a DB. Sounds simple enough..... The data would look...
0
by: Ray Godfrey | last post by:
Hi there Bob, To answer your questions: 1. I'm using MS SQL Server V8.0 2. Yeah there will be money, date/time data. All the DB will be money/datetime. Its pretty tricky. Using the code...
25
by: PyPK | last post by:
What possible tricky areas/questions could be asked in Python based Technical Interviews?
8
by: pras.vaidya | last post by:
Hi , below given question was asked to me during an interview and i figured it out little tricky . It would be a great help if anyone could solve it. Code : - main() { char...
56
by: maadhuu | last post by:
hello, this is a piece of code ,which is giving an error. #include<stdio.h> int main() { int a =10; void *p = &a; printf("%d ", *p ); //error....why should it //be an error ?can't the...
44
by: Tolga | last post by:
As far as I know, Perl is known as "there are many ways to do something" and Python is known as "there is only one way". Could you please explain this? How is this possible and is it *really* a...
20
by: James | last post by:
I am new to vb.net (I am an old vb6 programmer). I cannot figure out an easy way to watch variables. In vb6 all I did was right click and could chose to stop execution when a variable chances as...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.