QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: MLambert on June 21, 2018, 01:50:02 am

Title: FUNCTION FindWindowA%& (BYVAL ClassName AS _OFFSET, WindowName$) 'find process h
Post by: MLambert on June 21, 2018, 01:50:02 am
Hi,

FindWindowA%$ ..... what does the %$ mean appended the variable ?

Regards,

Mike
Title: Re: FUNCTION FindWindowA%& (BYVAL ClassName AS _OFFSET, WindowName$) 'find process h
Post by: bplus on June 21, 2018, 08:25:49 am
http://qb64.org/wiki/OFFSET
DECLARE CUSTOMTYPE LIBRARY
    FUNCTION FindWindow& (BYVAL ClassName AS _OFFSET, WindowName$)
END DECLARE

Only the ampersand & is present, no % sign!

& after variable name represents the long integer type variable often used for variable handles to access specially stored memory items like images or play files.

Oh hey! There is FindWindowA, example #2:
http://qb64.org/wiki/CLIPBOARD$
Code: QB64: [Select]
  1. '"ClippyBoard" program uses GetKeyState Win API to monitor a specific key combination.
  2. 'This demo will maximize the window and focus on program when Shift+A is pressed.
  3.  
  4.   FUNCTION FindWindowA%& (BYVAL ClassName AS _OFFSET, WindowName$) 'find process handle by title
  5.   FUNCTION GetKeyState% (BYVAL nVirtKey AS LONG) 'Windows virtual key presses
  6.   FUNCTION ShowWindow& (BYVAL hwnd AS _OFFSET, BYVAL nCmdShow AS LONG) 'maximize process
  7.   FUNCTION GetForegroundWindow%& 'find currently focused process handle
  8.   FUNCTION SetForegroundWindow& (BYVAL hwnd AS _OFFSET) 'set foreground window process(focus)
  9.  
  10.  
typo?

maybe a screwy way for unsigned long? ~&

or maybe a Windows type:
http://qb64.org/wiki/Windows_Libraries
right at beginning
Title: Re: FUNCTION FindWindowA%& (BYVAL ClassName AS _OFFSET, WindowName$) 'find process h
Post by: FellippeHeitor on June 21, 2018, 08:42:05 am
Quote
typo?
Does it work?
Title: Re: FUNCTION FindWindowA%& (BYVAL ClassName AS _OFFSET, WindowName$) 'find process h
Post by: bplus on June 21, 2018, 08:56:46 am
No errors thrown so probably a Window type?
Title: Re: FUNCTION FindWindowA%& (BYVAL ClassName AS _OFFSET, WindowName$) 'find process h
Post by: FellippeHeitor on June 21, 2018, 08:57:48 am
Type of prefix %& is _OFFSET, as you pointed out: http://qb64.org/wiki/OFFSET
Title: Re: FUNCTION FindWindowA%& (BYVAL ClassName AS _OFFSET, WindowName$) 'find process h
Post by: bplus on June 21, 2018, 09:16:30 am
Code: QB64: [Select]
  1. '"ClippyBoard" program uses GetKeyState Win API to monitor a specific key combination.
  2. 'This demo will maximize the window and focus on program when Shift+A is pressed.
  3.  
  4.     FUNCTION FindWindowA%& (BYVAL ClassName AS _OFFSET, WindowName$) 'find process handle by title
  5.     FUNCTION GetKeyState% (BYVAL nVirtKey AS LONG) 'Windows virtual key presses
  6.     FUNCTION ShowWindow& (BYVAL hwnd AS _OFFSET, BYVAL nCmdShow AS LONG) 'maximize process
  7.     FUNCTION GetForegroundWindow%& 'find currently focused process handle
  8.     FUNCTION SetForegroundWindow& (BYVAL hwnd AS _OFFSET) 'set foreground window process(focus)
  9.  
  10. title$ = "Clippy Clipboard (Ctrl+Shift)" 'title of program window
  11. _TITLE title$ 'set program title
  12. hwnd%& = FindWindowA(0, title$ + CHR$(0)) 'find this program's process handle
  13.  
  14. IF hwnd%& <> 0 THEN PRINT "Worked" ELSE PRINT "Did not work"
  15.  
  16.  

So what do you think I got "Worked" or "Did not work"?
Title: Re: FUNCTION FindWindowA%& (BYVAL ClassName AS _OFFSET, WindowName$) 'find process h
Post by: bplus on June 21, 2018, 09:23:22 am
Oh there is an _OFFSET type with %& suffix
http://qb64.org/wiki/Variable_Types

There is even an unsigned offset ~%&
Title: Re: FUNCTION FindWindowA%& (BYVAL ClassName AS _OFFSET, WindowName$) 'find process h
Post by: bplus on June 21, 2018, 09:29:35 am
Maybe _OFFSET type can't be printed with a value other than 0?
Title: Re: FUNCTION FindWindowA%& (BYVAL ClassName AS _OFFSET, WindowName$) 'find process h
Post by: FellippeHeitor on June 21, 2018, 09:33:58 am
Oh there is an _OFFSET type with %& suffix
http://qb64.org/wiki/Variable_Types

That’s what I meant when I said

Type of prefix %& is _OFFSET, as you pointed out: http://qb64.org/wiki/OFFSET

Anyway, QB64 can now give you the current window handle with _WINDOWHANDLE, no need for FindWindow.
Title: Re: FUNCTION FindWindowA%& (BYVAL ClassName AS _OFFSET, WindowName$) 'find process h
Post by: bplus on June 21, 2018, 09:36:44 am
oops, dang I thought i was editing a previous reply
Title: Re: FUNCTION FindWindowA%& (BYVAL ClassName AS _OFFSET, WindowName$) 'find process h
Post by: bplus on June 21, 2018, 09:40:54 am
Where is my modify button?

EDIT: on previous posts?
Title: Re: FUNCTION FindWindowA%& (BYVAL ClassName AS _OFFSET, WindowName$) 'find process h
Post by: bplus on June 21, 2018, 10:18:49 am
Fellippe, I think you are meaning suffix, %& is a suffix for the _OFFSET type, a prefix comes before then main word. Like _ in _OFFSET

And yes, it completely slipped my understanding that there was a type called _OFFSET.

And, it is handy to know that function has been replaced with Keyword.

EDIT: AND, apparently there is a time limit for how long you are allowed to modify a post.
Title: Re: FUNCTION FindWindowA%& (BYVAL ClassName AS _OFFSET, WindowName$) 'find process h
Post by: bplus on June 21, 2018, 10:25:52 am
See it would be nice if I could edit  "then" to "the" in the above post.

I really think MODIFY functions have been modified, a shorter time limit.

Now the folks here have to suffer my poor typing skills... no Ninja fingers here...

Title: Re: FUNCTION FindWindowA%& (BYVAL ClassName AS _OFFSET, WindowName$) 'find process h
Post by: FellippeHeitor on June 21, 2018, 10:33:19 am
I did mean suffix.
Title: Re: FUNCTION FindWindowA%& (BYVAL ClassName AS _OFFSET, WindowName$) 'find process h
Post by: MLambert on June 22, 2018, 04:31:22 am
Hi Everyone,

Thks for the feedback.

I don't understand many of the threads..

So is hwnd%&  ... "%&" valid ?

Mike
Title: Re: FUNCTION FindWindowA%& (BYVAL ClassName AS _OFFSET, WindowName$) 'find process h
Post by: MLambert on June 22, 2018, 04:35:29 am
Hi,

The Focus.bas is found on the page

https://qb64.org/wiki/Windows_Libraries

Mike
Title: Re: FUNCTION FindWindowA%& (BYVAL ClassName AS _OFFSET, WindowName$) 'find process h
Post by: FellippeHeitor on June 22, 2018, 05:01:19 am
Yes, MLambert, "%&" at the end of a variable name is valid and denotes the type _OFFSET (http://www.qb64.org/wiki/OFFSET).

_OFFSET is used to store the position in memory of a desired value. You will see it a lot with API calls.
Title: Re: FUNCTION FindWindowA%& (BYVAL ClassName AS _OFFSET, WindowName$) 'find process h
Post by: MLambert on June 22, 2018, 06:04:07 am
Hi Fellippe,

My e-mail is not working ... pls ignore the message regarding my signon issues . It resurrected itself.

Thank you for the %& answer

Mike