|
Thanks for the quick responce.
Al968
Avast Antivirus-<url>http://www.avast.com<url>
|
|
|
|
|
HOW to I close another dialog box from another application? Sendkeys doesn't send the tab key with a modal dialog box (Yes, No, Cancel buttons displayed)... How do I do this?
Do I have to use API calls? How? I am GREEN... I've seen some samples out there, but perhaps I didn't put the code in the right place?
CONFUSED...
(
Waushaka
|
|
|
|
|
You could send WM_CLOSE, I suppose. That may work. I thnk that's what the shutdown process does.
What are you trying to do ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Thanks for your prompt response. In vb net, I am trying to make another Windows application close (or respond) it's modal dialog boxes. It's a software program called "CareFacts", at my place of employment. I am an amateur programmer in vb net, but I've been able to accomplish several things, like games, sound, multiple forms, etc. Several of the modal dialogs come up, and I am trying to send code to respond to them, close them, etc.
I've been able to interact with the program, using API calls. I believe the "handle" changes when the modals come up; I'm not sure how to change the handle.
If you want to see my code, let me know, and I will send it to you..
much obliged for your attention-this program really sucks because it requires the end date for each of our clients to be updated manually... 535 plus (adds up to about 14,000 keystrokes or more), thus my trying to make this vb net program work.
thanks again...
Waushaka
|
|
|
|
|
Waushaka wrote: I believe the "handle" changes when the modals come up; I'm not sure how to change the handle.
Well, the modal form has it's own handle, and that's the form you want to send a message to.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I'm not sure how to find the handle, and I am also not sure how to change it. Can you give any advice on both? thanks!
Waushaka
|
|
|
|
|
There are C API functions you can p/invoke to go over all the active window handles. If you know the caption text of the window you want, you can find it that way.
You don't want to change the handle, nor is that possible. You want to send it a message, namely WM_CLOSE. SendMessage is the API you want to p/invoke, I think.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I have a VB.Net 2005 program.
In the program, users enter values into text boxes, and then when they go onto the next box, the text box is disabled.
I have set up a global variable to detect if the form has been on before. Is there any way, if the form has been on before, to make it reset (i.e. like the program has just been compiled again), so there are no values in the text boxes.
Really need help on this, im sure there has to be some reset command somewhere.
Cheers in advance for the help
(p.s. program is already set up with if's as validation, not arrays, so cant do it by running through arrays!)
|
|
|
|
|
There is no reset command, bar the InitializeComponents method. You should write one, call it initially, and call it as you need to.
If you want to reset all textboxes, then you just iterate over the controls collection, finding all textboxes.
What do you mean by 'been one before' ? If the form is being created every time, then it's a different instance of the form people are seeing.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Its done so that if the user wants to fill in the form again they can, but i want the form to be reset! I didnt know if there was a way to do this on formload, kinda reset-all!
It uses this code per input:
If txtInput1.Text.ToLower = lblLetter1.Text Then
lblLetter1.ForeColor = R
intScoreTop += 1
Else
lblLetter1.ForeColor = W
End If
txtInput1.Enabled = False
txtInput2.Enabled = True
txtInput2.Focus()
|
|
|
|
|
OK, like I said, to do a reset all, you need to write your own.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hello, I'm creating a macros in Excel that allows a person to export large amounts of data from the excel page and save to html. I'm using an example from the book VBA and Macros for Microsoft Excel by Bill Jelen, Tracy Syrstad. Except I've added a custom form that allows the user to determine how many rows of data to extract per html page as well as other features so that it will work with different files of different columns and column names.
My problem is this. I have an excel field called IMAGE_URL. It contains a normal URL to a product picture on the web. Instead of letting my html pages point to that picture online, I'd rather copy the picture and save it into the same folder as my HTML files so that when I upload the pages to the web they point to the pics in the folder and not elsewhere on the web.
Does anyone have any advice? I basically need to know how to access the picture with the given link and then save it in my folder but I need to automate it within the macros code. I'm trying to use createobject() but have yet to come up with anything.
To calrify exactly what I am doing. I have several excel files with thousands of rows of data. The fileds are like
ProductID, ProductName, Brand, Description, Price, Image_URL
I've created the macros that allows me at the click of a button to send that data to html files depending on how many rows of products I want to go into an html page. Inside the excel file I have place the html tags such as 'Print #1, "" etc so all the formatting is predefined through out each html page. I just need away to save the images from the web inside the same folder instead of point to the images elsewhere on the web.
|
|
|
|
|
I adapted the code here[^] to do something very similar in VBScript. I was downloading an .EXE file, but the concept applies to what you're doing. Let's see, where did I put that script...
GetBinaryFile "http://sourceURL", "destinationFilePath"
Private Function NavigateToPage(objIE, url)
attempts = 0
timeout = 5000
i = 0
While attempts < 5
objIE.Navigate2 url
While (objIE.ReadyState < READYSTATE_COMPLETE) And (i < timeout)
WScript.Echo "Waiting... " & i
WScript.Sleep 100
i = i + 100
Wend
If i >= timeout Then
WScript.Echo "Retrying..."
attempts = attempts + 1
i = 0
Else
' Domain should not be blank if the page worked!
If objIE.Document.Domain <> "" Then
NavigateToPage = True
Exit Function
Else
NavigateToPage = False
Exit Function
End If
End If
Wend
NavigateToPage = False
End Function
Private Sub GetBinaryFile(uri, filepath)
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2
Const adSaveCreateNotExist = 1
Set xml = CreateObject("Microsoft.XMLHTTP")
xml.Open "GET", uri, False
WScript.Echo "Downloading " & uri & "..."
xml.Send
Set oStream = CreateObject("Adodb.Stream")
oStream.Type = adTypeBinary
oStream.Open
oStream.Write xml.responseBody
WScript.Echo "Saving to file " & filepath & "..."
oStream.SaveToFile filepath, adSaveCreateOverWrite
oStream.Close
set oStream = Nothing
Set xml = Nothing
End Sub
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
That's exactly what I'm trying to do but I still can't get it to work. All I need is this part of the code you provided.
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2
Const adSaveCreateNotExist = 1
Dim uri
uri = "http://www.csdn.net/Images/logo_csdn.gif"
MyPath = ThisWorkbook.Path
ThisFile = MyPath & Application.PathSeparator
Set xml = CreateObject("Microsoft.XMLHTTP")
xml.Open "GET", uri, False
xml.Send
Set oStream = CreateObject("Adodb.Stream")
oStream.Type = adTypeBinary
oStream.Open
oStream.Write xml.responseBody
oStream.SaveToFile ThisFile, adSaveCreateOverWrite
oStream.Close
Set oStream = Nothing
Set xml = Nothing
When I get to the line
oStream.SaveToFile ThisFIle, adSaveCreateOverWrite
I get an error saying: Run-time error '3004' Write to file failed. Basically I just want the image to be stored in the same folder as my excel file. I may have an error in my file path.
I've tried another example that does work and is very similar to the one you provided but contains a minor problem.
Const adTypeBinary = 1
Const adSaveCreateNotExist = 1
Const TemporaryFolder = 2
Dim oStream ' ADODB.Stream
Dim oFSO ' Scripting.FileSystemObject
Dim xml ' Microsoft.XMLHTTP
Dim sURL
Dim oFil
Dim sImagePath
' create objects
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set xml = CreateObject("Microsoft.XMLHTTP")
Set oStream = CreateObject("Adodb.Stream")
sURL = "http://www.csdn.net/Images/logo_csdn.gif"
' get the temp file...
MyPath = ThisWorkbook.Path
ThisFile = MyPath & Application.PathSeparator & oFSO.GetTempName
xml.Open "GET", sURL, False
xml.Send
oStream.Type = adTypeBinary
oStream.Open
oStream.Write xml.responseBody
' Do not overwrite an existing file
oStream.SaveToFile ThisFile, adSaveCreateNotExist
oStream.Close
' cleanup...
'oFil.Delete
Set oStream = Nothing
Set xml = Nothing
Set oFSO = Nothing
Set oFil = Nothing
The problem with this code is
ThisFile = MyPath & Application.PathSeparator & oFSO.GetTempName
The oFSO.GetTempName creates and stores a .tmp file which is no good to me.
If you could help me figure this out I'd be very grateful
|
|
|
|
|
I got your example to work. Had the filename messed up.
Many thanks for the code!
You saved my life.
|
|
|
|
|
Hello,
I would like to create a program that can unpackprograms that have been packed. In other words I would like to create a program that does the opposite of UPX. For now I just would like to unpack UPX Packed files. Could someone point me to a tutorial or give me some advice on how to do this ??
Thanks
Al968
Avast Antivirus - http://www.avast.com
|
|
|
|
|
Hi all,
im trying to add something to my database if a particular form is open. ive embedded the following IF statement inside a larger if statement.
If form2.Visible = True Then
dsNewRow.Item("UseCaseID") = "2"
End If
The if statement is on form3. The above code doesnt seem to work for some reason, was hoping you guys may be able to help.
Thanks in advance
Jaidev
|
|
|
|
|
It doesn't work because your instance of Form3 doesn't have a reference to the instance of Form2. Your trying to look at the value of Visible as if it were a static property on a class. This is not VB6, where every form existed automatically and globally. Form3 needs a reference to an existing Form2 object passed to it before this will work.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
How do I do this?
I have around 15 different forms, ideally I would like them all to exist automatically and globally, is there a way in which I can do this? so that I can use different forms like in my code.
Thanks in advance.
Jaidev
|
|
|
|
|
The VB6 way is nasty, that's why it's history.
The best way to do it, is to use delegates to pass information between forms. The other way, is to pass your form2 instance in to your form3 instance, so it has a reference to it. Finally, the Application object has a collection of open forms, which you can look through, I believe.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
You can create a static (shared in VB) property in each form class where you store the current instance of the form. In the constructor of the form you store the reference to the instance:
This of course means that you can only create a single form from each form class.
---
single minded; short sighted; long gone;
|
|
|
|
|
Hi,
Thanks for your replies, however I dont fully understand the jargon, would it be possible for you guys to send me example codes on how this can work?
Cheers
Jaidev
|
|
|
|
|
If you don't understand what shared is, you should buy a VB.NET book and work through it. Delegates are widely documented on the web, if you google any of the 'jargon' we've given you, you'll get more detailed examples than you will find in a forum post.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
What ive done is created a new class (class1) in which ive stated my variable.
then ive referenced this class, but its still not working.
form3.
Dim var As New class1()
---------
If var.numberofcalls = 1 Then
dsNewRow.Item("UseCaseID") = "2"
End If
form1.
Dim var As New class1() --> seems to work
class1.
Public Class class1
Public numberofcalls = 0
End Class
Am i pointing in the right direction?
Jaidev
|
|
|
|
|
Perhaps, the problem is, you didn't make the variable 'shared'. Shared means, there's only one instance of the variable across all class instances, which means you can set it in one class, and get it in another, without having to pass an instance around. In C#, it's called 'static'. Google these terms and you should find good examples of how it works.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|