Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
type or class EXE
#1
i never did much with own type or classes in qm,
only in php ....

can you show me how to make a global type/class for this:

Code:
Copy      Help
,,exe_path.getwinexe(handles[i] 1)
,,exe_name.getwinexe(handles[i] 0)
,,exe_title.getwintext(handles[i])
,,exe_class.getwinclass(handles[i])
,,title.findreplace(":" " ") ;;escape :
,,title.escape(1) ;;escape "
,,title.left(title 14)
pi
#2
To create new class, declare it somewhere and run or compile the code. The declaration includes member variables but does not include member functions.

class EXE member variables

Then add member functions using File -> New menu. QM item names must begin with class name and dot, like EXE.function1. Item named EXE will be constructor. Item named EXE. will be destructor. Item named EXE= will be operator =. All these special member functions are optional.
#3
EXE can't be used, so my class would be exe.

please give me an example, because i don't understand all the parts.
pi
#4
i don't understand how to make a class or type (what to use)
out of the code i posted.

i have never used it in on my own in qm.
pi
#5
Depends on the purpose. Generally, type and class in QM are just different names for the same thing. If you will add functions to it, use class.

What is the purpose you want to use class?

Is your example code single function or it must be converted to multiple member functions?
#6
instead of using the same code again and again it seems
to be clever to use some global script for the code i posted.

i use it in many triggers.

so exe.name(hwnd) or exe.title(truncate(30)) would be easier to use.

TSK_Main3
Code:
Copy      Help
out "WRONG"
str exe_title exe_path exe_name exe_class
int hwnd htb1 htb2 count1
str-- tb1 tb2
ARRAY(int)-- handles
ARRAY(int) r_handles
opt waitmsg 1
int w2=ShowDialog("TSK_Dialog2" &TSK_Dialog2 0 0 1)
int-- htb=id(3 w2)
rep
,out
,tb2="";count1=0
,if(!IsWindow(w2)) break
,GetWindowList 0 "" 0 0 0 handles
,
,for(int'i 0 handles.len)
,,hwnd=handles[i]
,,if(!IsWindowVisible(hwnd)) continue ;;exclude hidden
,,if(GetWinStyle(hwnd 1)&WS_EX_TOOLWINDOW) continue

,,if taskbar_splitter(hwnd)!=1
,,,if (exe.name!="FreeMeter")
,,,,r_handles[r_handles.redim(-1)]=handles[i]
,,,,tb2.formata("%i: %s - hwnd= %i exe= %s[]" r_handles.len-1 exe.title(15) handles[i] exe.name)

,
,handles.redim(0);r_handles.redim(0)
,out tb2
,
,out exe.title
,3
pi
#7
Do I correctly understand:

EXE is class that represents a window and provides functions to get information about the window.

Will try to explain how to create such class.

Since EXE cannot be used, let it be Exe.

Somewhere (eg in init2, or in macro code before using the class) declare the class:

class Exe m_hwnd -str'm_exename -str'm_exepath ;;and so on

Compile the code that contains the declaration.

Create member function (use menu File -> New) named EXE.name:

Code:
Copy      Help
function'str
if(!this.m_exename.len) m_exename.getwinexe(m_hwnd 0)
ret this.m_exename

Similarly create more member functions.

Example macro that declares and uses the class:
Code:
Copy      Help
class Exe m_hwnd -str'm_exename -str'm_exepath ;;and so on

Exe exe ;;declare variable of Exe class
exe.m_hwnd=_hwndqm ;;initialize. Alternatively, create member function eg Init that initializes the object.
out exe.name

This was just one of possible implementations. Maybe you need to get some properties every time the member function is called, instead of caching into member variables. Or get all properties in Exe.Init, which would simplify other member functions.
#8
amazing !

that was a astonishing lesson !
pi
#9
now with parameter for truncate title

call_Exe
Code:
Copy      Help
#compile Exe.Init
Exe exe
exe.m_hwnd=_hwndqm
;exe.m_hwnd=win(mouse)
out exe.name
out exe.path
out exe.title
out exe.title(20)


Attached Files
.qml   Exe.qml (Size: 789 bytes / Downloads: 155)
pi
#10
how to declare using mutliline ?

works:
Exe.Init
Code:
Copy      Help
class Exe m_hwnd -str'm_exename -str'm_exepath  -str'm_exetitle -int'm_truncate -str'm_execlass str'm_exeout


works not:
Exe.Init
Code:
Copy      Help
class Exe m_hwnd -str'm_exename -str'm_exepath  -str'm_exetitle
-int'm_truncate -str'm_execlass str'm_exeout
pi
#11
Example
Code:
Copy      Help
class ConvertCH
,~m_s ~m_file ~m_dest ~m_sInclDir ~m_sFuncDll ~m_sFuncArgsWin ~m_sFuncArgsCrt
,IStringMap'm_mf IStringMap'm_mfcb IStringMap'm_mtd IStringMap'm_mt IStringMap'm_mi IStringMap'm_mc IStringMap'm_mg IStringMap'm_mcf IStringMap'm_mtag
,IStringMap'm_mh IStringMap'm_mfan IStringMap'm_mfdn IStringMap'm_mcomm IStringMap'm_mall IStringMap'm_mut IStringMap'm_mpch IStringMap'm_mo
,IExprC'm_expr IExprC'm_expr2
,ARRAY(str*)m_aems ARRAY(CHDLL)m_adll
,!m_crt !m_outIncl !m_compact !m_pch
,CHRX'm_rx


Forum Jump:


Users browsing this thread: 1 Guest(s)