Page 1 of 1

Posted: Thu Jun 20, 2002 7:45 pm
by BackupUser
Restored from previous forum. Originally posted by cor.

Let's take the following:

result.l = FindWindow_(0,"Title")

It returns a window handle of another program

How to use this with other windows commands in PB

e.g.

MoveWindow
HideWindow
ResizeWindow
UseWindow
ActivateWindow

I tried with WindowID = WindowID([#Window])



Using Windows 98 SE
Registered PB version : 3.1 (Windows)
--------------------------
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com

Posted: Thu Jun 20, 2002 8:02 pm
by BackupUser
Restored from previous forum. Originally posted by Paul.

You are trying to mix 2 different things here.

For the most part, PB & API commands are for PB created things and API commands are for API created things.

If you are using API command hWnd=FindWindow_(0,"Title")
to find something created outside of your PureBasic app,

then you would use API command MoveWindow_(hWnd,x,y,width,height,1) to move/resize it or ShowWindow_(hWnd,#SW_HIDE) to hide it, etc.





Edited by - paul on 20 June 2002 21:04:22

Posted: Thu Jun 20, 2002 8:19 pm
by BackupUser
Restored from previous forum. Originally posted by cor.

Paul,

Thanks
I know that the 2 are different, but I suppose PB use also window handles for it's own window controlling, or is it done at a different way?.

I want to make use of PB to do automation things such as grabbing text and images from another program, and acting on it, if they where available or not.

No I use the program wintask http://www.wintask.com
Just look at the functions they have. I want to implement some of them in PB.
I think this is a great program, but it cannot compile to an exe.

I'am working now to perfect commands such as sendkeys to other programs.
Reading, writing to e.g. excel with DDE.

I'am working for a great bank company and I want to sell my own made automation things to other banks, ofcourse without the source.

I personaly think PB could jump into that market, but now i'am programming my own library to do such things.

Using Windows 98 SE
Registered PB version : 3.1 (Windows)
--------------------------
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com

Edited by - cor on 20 June 2002 21:21:13

Posted: Thu Jun 20, 2002 9:14 pm
by BackupUser
Restored from previous forum. Originally posted by PB.

> MoveWindow
> HideWindow
> ResizeWindow
> UseWindow
> ActivateWindow

Once you have the handle of the other window via the FindWindow API, you can
do all the above to it with the following API commands.

MoveWindow becomes: MoveWindow_(handle,x,y,w,h,#TRUE) ; Needs GetWindowRect first!

HideWindow becomes: ShowWindow_(handle,#HIDE) ; And #SHOW again if needed.

ResizeWindow becomes: MoveWindow_(handle,x,y,w,h,#TRUE) ; Set w and h to new dims.

UseWindow and ActivateWindow needs this procedure (which is the equivalent of the
Visual Basic "AppActivate" command):

Code: Select all

Procedure AppActivate(handle)
  thread1=getwindowthreadprocessid_(getforegroundwindow_(),0)
  thread2=getwindowthreadprocessid_(handle,0)
  If thread1thread2 : attachthreadinput_(thread1,thread2,#TRUE) : EndIf
  setforegroundwindow_(handle)
  If thread1thread2 : attachthreadinput_(thread1,thread2,#FALSE) : EndIf
EndProcedure
; This next code gets the width and height of a foreign window:
GetWindowRect_(handle,win.RECT) : w=win\right-win\left : h=win\bottom-win\top

Hope this helps!


PB - Registered PureBasic Coder

Edited by - PB on 20 June 2002 22:19:41

Posted: Thu Jun 20, 2002 9:24 pm
by BackupUser
Restored from previous forum. Originally posted by cor.
Hope this helps!


PB - Registered PureBasic Coder

Edited by - PB on 20 June 2002 22:19:41
Thanks Paul,

for your quick response

Using Windows 98 SE
Registered PB version : 3.1 (Windows)
--------------------------
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com