|
-
Jul 21st, 2013, 03:18 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] trying to determine if a button is enabled or disabled in another programs window..
I'm basically trying to automate a task that has come to annoy me over the past few days, what i need to do is check if a specific button on another program is enabled or not. i have no clue where to begin, any suggestions? (with examples if you got please)
-
Jul 21st, 2013, 04:10 PM
#2
Re: trying to determine if a button is enabled or disabled in another programs window
try this. I used a test app executable with windowName = "testExe", + the button I was testing = "Button2":
Code:
Imports System.Runtime.InteropServices
Public Class Form1
<DllImport("user32.dll")> _
Private Shared Function IsWindowEnabled(ByVal hWnd As IntPtr) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
Private Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" (ByVal hWnd1 As IntPtr, ByVal hWnd2 As IntPtr, ByVal lpsz1 As String, ByVal lpsz2 As String) As IntPtr
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim iHwnd As IntPtr = FindWindow(vbNullString, "testExe")
Dim iHwndChild As IntPtr = FindWindowEx(iHwnd, IntPtr.Zero, vbNullString, "Button2")
MsgBox(IsWindowEnabled(iHwndChild))
End Sub
End Class
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jul 21st, 2013, 04:14 PM
#3
Re: trying to determine if a button is enabled or disabled in another programs window
EDIT ... <Sigh>or .paul can just beat me to it.</sigh>
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Jul 21st, 2013, 04:20 PM
#4
Thread Starter
Fanatic Member
Re: trying to determine if a button is enabled or disabled in another programs window
thanks for the replies.. .paul. that one seemed to do the job perfectly. thank you.
-
Jul 21st, 2013, 05:30 PM
#5
Re: trying to determine if a button is enabled or disabled in another programs window
 Originally Posted by dunfiddlin
EDIT ... <Sigh>or .paul can just beat me to it.</sigh>
err... <Sigh>You had 52 minutes to answer before I answered. I'd say you had a fair chance if you had anything useful to say</sigh>
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jul 21st, 2013, 06:14 PM
#6
Re: [RESOLVED] trying to determine if a button is enabled or disabled in another prog
That assumes that I have nothing better to do with my time than sit watching the forum for every new post and leaping upon it the instant it's posted. I actually read the OP a few minutes before you posted at most! About the amount of time I read your latter post prior to this reply on account of indulging in an episode of Miss Fisher's Murder Mysteries in the meantime (a far better use of my time all round!)
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Jul 21st, 2013, 06:22 PM
#7
Re: [RESOLVED] trying to determine if a button is enabled or disabled in another prog
 Originally Posted by dunfiddlin
I actually read the OP a few minutes before you posted at most!
well unfortunately that is the nature of asynchronous communication. some you win, some you lose
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
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
|