|
-
Feb 24th, 2002, 05:42 AM
#1
Thread Starter
Fanatic Member
changing focus to a paticular window, all i know is the window title
Hi, I would like to change the focus to a window of title "WindowTItle".
i am guessing i need to loop thru all the windows (how?) and use that getwindowtext API to compare the window title, and once found setfocus API?
or if i get desperate
do
sendkeys "%{TAB}", true
loop until getActiveWindowTitle = "WindowTitle"
how do u type that code in "visual basic code" syntax on the post?
Last edited by SkiNLaB; Feb 24th, 2002 at 07:24 AM.
-
Feb 24th, 2002, 07:36 AM
#2
Thread Starter
Fanatic Member
i c
where exactly would i find short descriptions about these API's? like a web page where u type the name in, and up comes a description explaining what it does and what the arguments are.
-
Feb 24th, 2002, 07:43 AM
#3
Thread Starter
Fanatic Member
ahh found one, www.vbapi.com
-
Feb 24th, 2002, 07:50 AM
#4
Thread Starter
Fanatic Member
geez, this structure is weird, i just read up on this enumWindows API, its freakin weird! so u call it, and give it the address of a public function that is in a module, and then enumWindows just calls that function over and over again until there are no more windows to be processed.... how bout that, thats great, thanx for ur help! just one thing though.... in EnumWindowsProc, at the end u return true ALWAYS, at no point can it return false, is it up to me to decide when it should return false (ie once the window has been found)
-
Feb 24th, 2002, 07:52 AM
#5
Thread Starter
Fanatic Member
oops one more thing...
'Create a buffer
MyStr = String(GetWindowTextLength(hwnd) + 1, Chr$(0))
whats this buffer stuff?
-
Feb 24th, 2002, 08:08 AM
#6
Thread Starter
Fanatic Member
i just found another API called FindWindow
http://www.vbapi.com/ref/f/findwindow.html
i simply feed it the title, and it returns to me the hWnd, which means i can setforegroundWindow to it, and also discovered that setFocus will only work for windows that ur program owns, which in this case mine does not.
-
Feb 24th, 2002, 08:50 AM
#7
Download the API viewer from http://www.allapi.net/ and have the API declarations and samples of how to use them at your fingertips.
-
Feb 24th, 2002, 10:40 AM
#8
PowerPoster
Originally posted by SkiNLaB
oops one more thing...
'Create a buffer
MyStr = String(GetWindowTextLength(hwnd) + 1, Chr$(0))
whats this buffer stuff?
Creates a buffer of length returned by the GetWindowTextLength and fills it with Null. You will get your Window Caption in this buffer.
-
Feb 24th, 2002, 04:13 PM
#9
Thread Starter
Fanatic Member
hmm k thats what i thought, but why do i need to create a Buffer for this? does getwindowtext need a string thats allready *buffed* does it?
-
Feb 24th, 2002, 05:10 PM
#10
Why not you use AppActivate (=standard VB, no API)
AppActivate "WindowTitle"
-
Feb 24th, 2002, 05:37 PM
#11
Thread Starter
Fanatic Member
i thought appactivate LOADS a program, my program and adobe premiere shall be swapping focus from time to time.
-
Feb 24th, 2002, 05:50 PM
#12
VB Help:
The AppActivate statement changes the focus to the named application or window but does not affect whether it is maximized or minimized. Focus moves from the activated application window when the user takes some action to change the focus or close the window. Use the Shell function to start an application and set the window style.
-
Feb 24th, 2002, 07:02 PM
#13
Thread Starter
Fanatic Member
ohhhhhhhhhh, i c, damn and i just went and learnt all this API crap, ah well, i spose i had to learn it one of these days! thanx twanvl
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
|