Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Find All Open Programs
#1
I was wondering if there is a way to find all open programs? And Close the program and just leave QM running? :lol:

Thanks!
Reply
#2
This code displays names of all non popup windows except QM. Uncomment last command to close these windows. Taskbar and other inportant explorer's windows are popup and therefore skipped by setting flag 4. This code requires one of latest QM versions.

Code:
Select All      Help
ARRAY(int) a
GetWindowList 0 0 1|4 0 0 a
int i h
for i 0 a.len
,h=a[i]
,if(h=_hwndqm) continue
,out _s.getwintext(h)
,;clo h
Reply
#3
Wow thanks!

Also, I have this large macro that clean up files. Problem is, users think its not doing anything and they think its stuck pressing Pause/Break.

Is there a way i could place a message at the beginning of the macro saying "PLEASE WAIT" and then the clean up codes, then turn off the message at the end of the macro?
Reply
#4
I am getting the error below when I copied, pasted and tried to compile the codes you provided. Am I doing something wrong?

>>>>>> expected 1 to 5 arguments, not 6. <<<<<<<<<<<<<
Reply
#5
You need newer QM version. Or, import the attached file and use function GetWindowList2 instead.


Attached Files
.qml   New GetWindowList.qml (Size: 1.58 KB / Downloads: 772)
Reply
#6
We are getting really close, I can taste it.

How come it does not find Yahoo Messenger tho?
Reply
#7
It is difficult to determine what windows must be closed, because there are many windows that you maybe don't think that they are windows, eg desktop, taskbar, tooltips, owners of real windows, and hundreds of hidden windows. This code enumerates all visible nonpopup windows and popup windows that have caption (title bar).

Code:
Select All      Help
ARRAY(int) a
GetWindowList2 0 0 1 0 0 a
int i h
for i 0 a.len
,h=a[i]
,if(h=_hwndqm) continue ;;skip QM
,int style=GetWinStyle(h)
,if(style&WS_POPUP)
,,if(style&WS_CAPTION != WS_CAPTION) continue ;;skip windows without title bar
,,
,out _s.getwintext(h)
,;clo h
Reply
#8
you are definitely the god of all gods!

have u thought about my other question? about the "PLEASE WAIT" message?

thanks!
Reply
#9
Function PleaseWait:

Code:
Select All      Help
\Dialog_Editor

;BEGIN DIALOG
;0 "" 0x10C00A44 0x100 0 0 72 31 "Quick Macros"
;3 Static 0x54000000 0x0 12 8 48 12 "Please wait ..."
;END DIALOG
;DIALOG EDITOR: "" 0x2010800 "" ""


opt waitmsg 2
ShowDialog("PleaseWait" 0 0 0 1)

Create new function, name it PleaseWait, and paste this code. To paste, use menu Edit -> Other formats -> Paste escaped. Call this function at the beginning of the macro. If your QM version is older, remove opt waitmsg 2 and insert opt waitmsg 1 in the macro, before PleaseWait. Example:

opt waitmsg 1
PleaseWait
...
Reply
#10
Ummm, am i suppose to remove the ";"

Confusedhock:

its showing me error message on line: if(flags&2) txt=macro; else txt.getmacro(macro)
Reply
#11
NEVERMIND, I GOT IT

Tongue


THANKS SO MUCH!
Reply
#12
Ummm, seems like the dialog box just flashed on screen and didnt stay.

Cry
Reply
#13
The dialog disappears when the macro ends.

This version of PleaseWait creates "always on top" dialog, which is not at screen center.

Code:
Select All      Help
;\Dialog_Editor

;BEGIN DIALOG
;0 "" 0x10C00246 0x100 0 0 72 30 "Quick Macros"
;3 Static 0x54000000 0x4 12 8 48 12 "Please wait ..."
;END DIALOG
;DIALOG EDITOR: "" 0x2010800 "" ""


opt waitmsg 2
ShowDialog("PleaseWait" 0 0 0 1)
Reply
#14
Works Great!!!!

Is there a way to place it on the center of the screen? Or it wont work?
Reply
#15
You can open the dialog in the Dialog Editor and add DS_CENTER style. Or, just replace 0x10C00246 to 0x10C00A46.
Reply
#16
Hello Ginatars:

I have a little problem. I have multiple windows that have the same name and would like to move them to another part of the screen. I pretty much know what to do once I find all the windows, problem is, finding them :lol:


For example, if I have 5 windows with the name "Find" how do I repeat functions on each window?

Thanks
Gabby
Reply
#17
What code you now use?
Reply
#18
Code:
Select All      Help
str xFound
str xWin="Find "
int xL=50
int xT=50

foreach xFound xWin
    act xWin
    mov ScreenWidth-xL xT xWin
    xT=xT+50



The problem is, its only moving the first window Sad
Reply
#19
The attachment contains functions to enumerate certain windows. Download and import it. Then use this code.

Code:
Select All      Help
int h
int xL=50
int xT=50

foreach h "Find " FE_Window1
,act h
,mov ScreenWidth-xL xT h
,xT=xT+50


Attached Files
.qml   Find certain windows.qml (Size: 960 bytes / Downloads: 696)
Reply
#20
Hello Mr. Gintaras:

I am stuck in the middle of a project. I have to work ong 6 notepad windows, to be able to manipulate each document. Each document is saved as Insert1, Insert2, Insert3, etc.

I used the function you gave to find the exact window name and it works great. The problem is, I don't know how to find a specific window without using the function over and over. I was hoping to run this function once and be able to assign the variable Doc1 to document Insert1, Doc2 to document Insert3, and so on.

I hope you can help.
Reply
#21
Gintaras Wrote:The attachment contains functions to enumerate certain windows. Download and import it. Then use this code.

Code:
Select All      Help
int h
int xL=50
int xT=50

foreach h "Find " FE_Window1
,act h
,mov ScreenWidth-xL xT h
,xT=xT+50


Hi!

I have been using this code for sometime now and had no problems whatsoever until I purchased a faster computer Big Grin

I am getting "cannot activate window" (on act h line)

The problem disappears when I use spe 50, instead of spe.

Is this a typical behavior? Both machines are set with the same run time options, just thought was weird.


Thank you
Denise
Reply
#22
Do you really need to activate different windows so frequently? I don't remember why there is act h, maybe it can be removed.

It is not typical behavior, but possible. I cannot say why it fails to activate in your case. Now I tried this code, and no errors (6 matching windows):

Code:
Select All      Help
spe
int h
rep 100
,foreach h "a" FE_Window1
,,act h
Reply
#23
Well, normally just 4 notepad windows, 3 of them I need to get text from, the 4th one is the compiled file.

I will try your suggestion and let you know.

Thank you very much.
Reply
#24
Also try to check or uncheck Disable Windows Foreground Lock Feature in Options.
Reply
#25
Checked on both computers
Reply
#26
iv made a macro that hides the I.E that i have up and im trying to hide new ones as they pop up im not sure how i need to add the new window to the ARRAY so when i unhide then all the windows come back here is the code

thanks



Code:
Select All      Help
SK
rep
,0.1
,ifk F12
,,break


ARRAY(int) a
GetWindowList 0 "IEXPLORE" 1 0 0 a
int i h


for i 0 a.len
,h=a[i]
,hid h

rep
,0.1
,ifi(win("" "" "IEXPLORE"))
not sure how to add my new window to the ARRAY
i+1 is not working
,,hid h
,ifk F11
,,break

for i 0 a.len
,h=a[i]
,hid- h
goto SK
Reply
#27
To add array element, I usually use this:

a[a.redim(-1)]=h

a.redim(-1) resizes the array by 1 element and returns the index of the element.

Or use this:

int ni
ni=a.redim(-1)
a[ni]=h

_____


win("" "" "IEXPLORE")

will return hidden windows too. Use flag 0x400 if you need only visible windows.

rep
,0.1
,h=win("" "" "IEXPLORE" 0x400)
,if(h)
,,a[a.redim(-1)]=h
,,hid h


Use

,hid- h; err
Reply
#28
is the a way to get only windows that are not visible with GetWindowList2?, i didnt see a flag for it.

MOZER
Reply
#29
Code:
Select All      Help
ARRAY(int) a; int i
GetWindowList(0 0 0 0 0 a)
for i 0 a.len
,if(IsWindowVisible(a[i])) continue
,str sc st
,sc.getwintext(a[i])
,st.getwintext(a[i])
,out "%i ''%s'' ''%s''" a[i] sc st
Reply
#30
I KNOW ITS SOMETHING SMALL IM DOING WRONG, HERE IS THE CODE
Code:
Select All      Help
str titles exe
ARRAY(int) handles
GetWindowList &titles "RUNTIMER" 0 0 0 handles
ARRAY(str) arr = titles

for(int'i 0 arr.len)
,if(IsWindowVisible(arr[i])) continue
,int hwnd=handles[i]
,exe.getwinexe(hwnd 1)
,if _s.getfilename(exe 0)=="blackbox"
,,exe = "explorer.exe *1"
,if arr[i]=="QM Help"
,,exe = "c:\windows\hh.exe *0"
,arr[i].findreplace(":" " ") ;;escape :
,arr[i].escape(1) ;;escape "
,arr[i].formata(" :act %i; err * %s" hwnd exe)
,;
titles=arr

int htb=win("MY_TASKBAR" "QM_Toolbar")
if(htb) titles.setmacro("my_taskbar") ;;just replace text, which will automatically update the toolbar
else htb=DynamicToolbar(titles "my_taskbar")
IT WILL GET ALL THE WINDOWS EVEN IF THEY ARE VISIBLE.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)