Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Yet another question to the brains

Status
Not open for further replies.

Craftor

Programmer
Feb 1, 2001
420
NZ
Yet another question to the brains out there...

I need to automate the selection of a folder in my application. The way it works is my app is an add-in to another app (Ascent Capture) and my app sends images to Ascent but Ascent automatically browses to the path in which it is installed. My app's images are located in c:\temp. My users are complaining about having to browse to C:\temp continually - is there any way (e.g. an api or something else) that I can cause ascent to automatically browse to c:\temp??

Thanks all

X-)
 
I'm not sure how add-ins like this work so please forgive me if this is way off.

Could you use SendKeys() to get Ascent to open the correct folder?
Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Did try Sendkeys"%SS" to automate it (this causes ascent to start a software import) but it unfortunately just opens ascent's program directory. Any ideas how to change it?
 
Craftor,

Could you give it some more keystrokes to move to the directory you want? Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Problem is, it will be different on every machine it is installed on. Is there no "generic" way to browse to C:\temp??
 
Public Declare Function SetCurrentDirectory Lib "kernel32" Alias "SetCurrentDirectoryA" (ByVal lpPathName As String) As Long

Public Function SetCurrentDir(ByVal NewDir As String) As Boolean
'*** SET CURRENT DIRECTORY ***
Dim ReturnVal As Boolean

On Error Resume Next
ReturnVal = SetCurrentDirectory(NewDir)

If (Err.Number <> 0) Or (Not ReturnVal) Then
MsgBox &quot;Error&quot;
End If

SetCurrentDir = ReturnVal
End Function


'*** You need Strip Terminator to strip the 0-terminator at the end of the C++ string so VB can use it ***
Private Function StripTerminator(ByVal strString As String) As String
'*** STRIP TERMINATOR ***
Dim intZeroPos As Integer
intZeroPos = InStr(strString, Chr$(0))

If (intZeroPos > 0) Then
StripTerminator = Left$(strString, intZeroPos - 1)
Else
StripTerminator = strString
End If
End Function


Call the function via:
RETURN_VALUE = SetCurrentDir(DESIRED_DIRECTORY_NAME)
Where DESIRED_VALUE is any string variable you want and DESIRED_VALUE in your case would be &quot;C:\temp&quot;
You may want to check that it exists first with the dir(&quot;&quot;,16) command. Just a thought.
If it returns anything but spaces, it errored. I hope this helps!
Brett Please visit my websites!
 
Craftor,

Different for every machine? I had in mind that you could send the keystrokes 'c:\temp' to the open dialogue box. Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
A-HA - thanks Mike - I tried that and it works great (feel like a bit of a moron for not getting that first off) - so thanks for putting me right with that. And thanks m99computers - have not yet had a chance to try that API but will give it a go this weekend!

Thanks all

Craftor

:p
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top