i have tried this, no success, done pauses from 1sec to 15secs
Printable View
i have tried this, no success, done pauses from 1sec to 15secs
i use vb.net
can i use it to
or do you have a simple script that i can use
if i use your script i get more errors
please help
sorry for my english
Here. Just set the last number from 3 (seconds to whatever you want)
For 1 minute, use 60 seconds.
VB Code:
Dim OldTime As Long Private Sub Form_Load() OldTime = Timer Timer1.Interval = 1000 Timer1.Enabled = True End Sub Private Sub Timer1_Timer() If Timer >= OldTime + 3 Then ' <------ Change this Timer1.Enabled = False Beep End If End Sub
eleanor,
You'll have to give more information. What are you trying to do and what errors do you get?
Balboa,
I don't know what else to try. Let's see if I can summarize where you are:
1. If you manually open the external program then your button clicking program works.
2. If you open the external program via VB then your button clicking program still works, but your external program does not run properly.
Maybe it needs command line options?
Maybe it needs to be run from a certain directory?
i put a message box in but i won't get a 1 or 0VB Code:
'Returns handle to target window Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _ ByVal lpClassName As String, _ ByVal lpWindowName As String _ ) As Long 'Returns handle to target control Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" ( _ ByVal hWnd1 As Long, _ ByVal hWnd2 As Long, _ ByVal lpsz1 As String, _ ByVal lpsz2 As String _ ) As Long 'Sends a message to our target Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _ ByVal hwnd As Long, _ ByVal wMsg As Long, _ ByVal wParam As Long, _ ByVal lParam As any _ ) As Long 'The message we want to send Const BM_CLICK = &HF5 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim hWndForm As Long ' handle to target window Dim hWndButton As Long ' handle to the button Dim strCaptionForm As String 'caption of the target form Dim strClassButton As String ' Button Class Dim strCaptionButton As String ' Button Caption Dim strClassForm As String 'Form Class Name strCaptionForm = "DMW3 - Client Login" strCaptionButton = "Login" strClassButton = "Button" strClassForm = "#32770" 'Get handle to desired form ' if this returns 0 we didn't get it hWndForm = FindWindow(strClassForm, strCaptionForm) MsgBox(hWndForm) '<<<<<<<<<test message1 If hWndForm = 0 Then MsgBox("Sorry, could not find requested form") Exit Sub End If 'Get handle to desired button on form ' if this returns 0 we didn't get it hWndButton = FindWindowEx(hWndForm, 0, strClassButton, strCaptionButton) MsgBox(hWndButton) '<<<<<<<<<test message2 If hWndButton = 0 Then MsgBox("Sorry, could not find requested button") Else 'Send click message to button Call SendMessage(hWndButton, BM_CLICK, 0, 0) End If End Sub
the test message1 like 17821312361 and not 1 or 0
and i get a error on ANY
must i at somthing or import????
VB Code:
'Sends a message to our target Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _ ByVal hwnd As Long, _ ByVal wMsg As Long, _ ByVal wParam As Long, _ ByVal lParam As [COLOR=Sienna]any[/COLOR] _ <<<<<As Any' is not supported in 'Declare' statements------------- ) As Long
Change Any to Long
VB Code:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _ ByVal hwnd As Long, _ ByVal wMsg As Long, _ ByVal wParam As Long, _ ByVal lParam As [B]Long [/B]_ ) As Long
i think it must need some kind od command line options aswell or something liek that. eleanor are you trying to help me with the program mate or you trying to get this program for your own use? i dnt mind either way lol, but if its for your own use are u having teh same problem as me?
ok that good now but the message are
for myself but if i can help you i wil do that :) :thumb: :afrog:Quote:
Originally Posted by Balboa.sCo
These numbers are handles to your windows. As long as they are not zero, they should be OK.Quote:
ok that good now but the message are
do you use DMW yourself? and do you play the game medal of honor?
but i dont have the program on my computer "DMW Client 3"Quote:
Originally Posted by moeur
then i must get the messagebox or not??
VB Code:
MsgBox("Sorry, could not find requested form")
but thats not working
can i try it with a other program
or do you have a tutorial or somthing to find it out
the handles are everytime somthing else??
I don't know if Long in VB.net means the same thing as Long in VB 6. How many bytes is a Long in VB.net?
If it is longer than 4, then you need to change all Long declarations to integer.
You'll have to check with the VB.net forum or your documentation.
long is 8 and 64 bitsQuote:
Originally Posted by moeur
like this????
VB Code:
'Returns handle to target window Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _ ByVal lpClassName As String, _ ByVal lpWindowName As String _ ) As Long 'Returns handle to target control Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" ( _ ByVal hWnd1 As integer, _ ByVal hWnd2 As integer, _ ByVal lpsz1 As String, _ ByVal lpsz2 As String _ ) As Long Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _ ByVal hwnd As integer, _ ByVal wMsg As integer, _ ByVal wParam As integer, _ ByVal lParam As integer _ ) As Long 'The message we want to send Const BM_CLICK = &HF5 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim hWndForm As Long ' handle to target window Dim hWndButton As Long ' handle to the button Dim strCaptionForm As String 'caption of the target form Dim strClassButton As String ' Button Class Dim strCaptionButton As String ' Button Caption Dim strClassForm As String 'Form Class Name strCaptionForm = "DMW3 - Client Login" strCaptionButton = "Login" strClassButton = "Button" strClassForm = "#32770" 'Get handle to desired form ' if this returns 0 we didn't get it hWndForm = FindWindow(strClassForm, strCaptionForm) MsgBox(hWndForm) If hWndForm = 0 Then MsgBox("Sorry, could not find requested form") Exit Sub End If 'Get handle to desired button on form ' if this returns 0 we didn't get it hWndButton = FindWindowEx(hWndForm, 0, strClassButton, strCaptionButton) MsgBox(hWndButton) If hWndButton = 0 Then MsgBox("Sorry, could not find requested button") Else 'Send click message to button Call SendMessage(hWndButton, BM_CLICK, 0, 0) End If End Sub
change ALL Longs, not just some
oke sorry thats helpQuote:
Originally Posted by moeur
but
i download the program and run it
but it gives a zero now i look for the caption like this
>>>>>>>>>>>> Window Details <<<<<<<<<<<<<
Title: DMW3 - Client Login
Class: #32770
Size: X: 836 Y: 378 W: 459 H: 266
>>>>>>>>>>> Mouse Details <<<<<<<<<<<
Screen: X: 1142 Y: 631
Cursor ID: 2
>>>>>>>>>>> Pixel Color Under Mouse <<<<<<<<<<<
RGB: Hex: 0xD4D0C8 Dec: 13947080
>>>>>>>>>>> Control Under Mouse <<<<<<<<<<<
Size: X: 287 Y: 218 W: 75 H: 23
Control ID: 1
ClassNameNN: Button1
Text: Login
>>>>>>>>>>> Status Bar Text <<<<<<<<<<<
and my code is like this
VB Code:
Returns handle to target window Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _ ByVal lpClassName As String, _ ByVal lpWindowName As String _ ) As Integer 'Returns handle to target control Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" ( _ ByVal hWnd1 As Integer, _ ByVal hWnd2 As Integer, _ ByVal lpsz1 As String, _ ByVal lpsz2 As String _ ) As Integer Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _ ByVal hwnd As Integer, _ ByVal wMsg As Integer, _ ByVal wParam As Integer, _ ByVal lParam As Integer _ ) As Integer 'The message we want to send Const BM_CLICK = &HF5 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim hWndForm As Integer ' handle to target window Dim hWndButton As Integer ' handle to the button Dim strCaptionForm As String 'caption of the target form Dim strClassButton As String ' Button Class Dim strCaptionButton As String ' Button Caption Dim strClassForm As String 'Form Class Name strCaptionForm = "DMW3 - Client Login" strCaptionButton = "Login" strClassButton = "Button1" strClassForm = "#32770" 'Get handle to desired form ' if this returns 0 we didn't get it hWndForm = FindWindow(strClassForm, strCaptionForm) MsgBox(hWndForm) If hWndForm = 0 Then MsgBox("Sorry, could not find requested form") Exit Sub End If 'Get handle to desired button on form ' if this returns 0 we didn't get it hWndButton = FindWindowEx(hWndForm, 0, strClassButton, strCaptionButton) MsgBox(hWndButton) If hWndButton = 0 Then MsgBox("Sorry, could not find requested button") Else 'Send click message to button Call SendMessage(hWndButton, BM_CLICK, 0, 0) End If End Sub
Balboa,
What is the exact caption you had to use to get the window handle? I think it was not as expected.
i try and try and try
but only zero's
what do i wrong
i have a exe with
VB Code:
msgbox("hello")
but thats not working to
please help my
ps: you neet the dotnetfx.exe to open de exe file
can find it on microsoft.com
http://www.microsoft.com/downloads/d...DisplayLang=en
I don't understand what you are saying.
moeur.
Thanks
but i have it already i used a other program then spy ++
now its working
but can i use it for a checkbox??
Hey moeur, :wave:
Sweet code there to integrate Spy++ functionality into your custom app. Does it flash the target window or put a box around it temporarily? I'll check it out when I get home. Could you add that modification? :ehh:
I was thinking it would be nice to have that feature, but so far have not figured out how to do it. I was looking at Spy++ and noticed that it looks like they are using some kind of window shadow effect.
i have 1 button in my program and all the code is down here but if i push the button nothing happens but push i again on the same butten then mijn setup on the other program go 1 step ahead
how is this possable
VB Code:
'Returns handle to target window Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _ ByVal lpClassName As String, _ ByVal lpWindowName As String _ ) As Integer 'Returns handle to target control Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" ( _ ByVal hWnd1 As Integer, _ ByVal hWnd2 As Integer, _ ByVal lpsz1 As String, _ ByVal lpsz2 As String _ ) As Integer Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _ ByVal hwnd As Integer, _ ByVal wMsg As Integer, _ ByVal wParam As Integer, _ ByVal lParam As Integer _ ) As Integer 'The message we want to send Const BM_CLICK = &HF5 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim hWndForm As Integer ' handle to target window Dim hWndButton As Integer ' handle to the button Dim strCaptionForm As String 'caption of the target form Dim strClassButton As String ' Button Class Dim strCaptionButton As String ' Button Caption Dim strClassForm As String 'Form Class Name strCaptionForm = "Adobe Reader 7.0 - Setup" strCaptionButton = "&Next >" strClassButton = "Button" strClassForm = "MsiDialogCloseClass" 'Get handle to desired form ' if this returns 0 we didn't get it hWndForm = FindWindow(strClassForm, strCaptionForm) MsgBox(hWndForm) If hWndForm = 0 Then MsgBox("Sorry, could not find requested form") Exit Sub End If 'Get handle to desired button on form ' if this returns 0 we didn't get it hWndButton = FindWindowEx(hWndForm, 0, strClassButton, strCaptionButton) MsgBox(hWndButton) If hWndButton = 0 Then MsgBox("Sorry, could not find requested button") Else 'Send click message to button Call SendMessage(hWndButton, BM_CLICK, 0, 0) End If End Sub End Class
Maybe you'd be better off using the VBasic SendKeys statement?
1. make Adobe Reader 7.0 - Setup the active window
2. Sendkeys("{ENTER}")
if the &Next > key is not the default, then you'll have to send some {TAB} keys first.
Get it?
The name had 2 spaces after it to answer ur previsous question moeur, i really cnt get this to work, gladh u guys are still working on it :), elenar have u got the code to work yet?
To fix this code mate DMW - Client Login must have 2 spaces after it, "DMW - Client Login "Quote:
Originally Posted by eleanor
This info is excellent guys!
I made the Spy++ equilivent program, and see the class name, caption, and handle for most things, however, I have encountered a problem:
I am trying to "Press" a button. The button is the Play button in Music Match Jukebox. In using the program (and also tried Spy++), there is no Caption; it is blank. The form has all the relevent info, but the button has the following info:
Handle: 406EA
Caption:
Class Name: AfxOleControl70u
Also, how do I send other things, such as Ctrl + right arrow?
Thanks for your help!
KyferEz