Author Topic: FUNCTION FindWindowA%& (BYVAL ClassName AS _OFFSET, WindowName$) 'find process h  (Read 7726 times)

0 Members and 1 Guest are viewing this topic.

Offline MLambert

  • Forum Regular
  • Posts: 115
    • View Profile
Hi,

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

Regards,

Mike

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
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
« Last Edit: June 21, 2018, 08:43:22 am by bplus »

FellippeHeitor

  • Guest
Quote
typo?
Does it work?

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
No errors thrown so probably a Window type?

FellippeHeitor

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

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
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"?

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Oh there is an _OFFSET type with %& suffix
http://qb64.org/wiki/Variable_Types

There is even an unsigned offset ~%&
« Last Edit: June 21, 2018, 09:24:50 am by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Maybe _OFFSET type can't be printed with a value other than 0?

FellippeHeitor

  • Guest
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.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
oops, dang I thought i was editing a previous reply
« Last Edit: June 21, 2018, 09:38:26 am by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Where is my modify button?

EDIT: on previous posts?

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
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.
« Last Edit: June 21, 2018, 10:20:20 am by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
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...


FellippeHeitor

  • Guest
I did mean suffix.

Offline MLambert

  • Forum Regular
  • Posts: 115
    • View Profile
Hi Everyone,

Thks for the feedback.

I don't understand many of the threads..

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

Mike