Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
exe: do something when windowtitle contains ...
#1
I want an executable that does something when a window opens with a certain title.
This can be any application within windows.

At the moment I can make an executable that does this withe following code

Macro Macro38
Code:
Copy      Help
int i
str titles
ARRAY(int) handles
GetWindowList &titles "" 1|2|4 0 0 handles
ARRAY(str) arr = titles

for i 0 arr.len
,out arr[i]

I just repeat above code indefinitely (every # second or # millisecond).
For example if there is window which has which has "test" in it's title, then "mspaint" will be opened ("mspaint" opens paint in windows).

I just wanted to ask if it there is a more memory/process friendly way to do this (in exe compiled exe).
Probably the infinite loop method with above code is process/memory friendly OR only method but then at least I know it 100% sure.
#2
Cannot use wait(0 WC win(...)) or similar?
#3
The "wait(0 WC win(...))" could work but implies that I have to set the following in the code itself:
- actual keyword to look for: "test"
- and the application to start: "mspaint"

Because I want to give the user the option to add/modify multiple keywords and applications the compiled exe will use an external textfile. In the "For i 0..." loop the arr[i] would be matched with each line of the textfile.

The textfile in which the user defines the string to look for in window title and what to start.
The textfile could look like this:

[keyword_app_list]
test_1|c:\test\app_1.exe
test_2|c:\test\app_2.exe

The pipe symbol splits/delimits the 2 values first value keyword, second value application to start.
I do not know if compiled exe code constantly reads code from the HD and then executes OR once the exe is loaded in memory it does not access the .exe on the HD (making it hard drive friendly at least).
But then I need to know if continually repeating the code does not impact the machines performance (processor and or RAM-memory wise).

I can understand it is difficult to give an estimation on this or that it is very difficult to create processor/ram friendly code based on constant execution of code. It is not extremely important, but I was very curious about this.
#4
If you need something like "window triggers":
https://msdn.microsoft.com/en-us/librar ... 85%29.aspx
Menu File -> New -> Templates -> Hook -> Hook_SetWinEventHook.

Repeatedly calling GetWindowList uses more CPU.
#5
OK THANK YOU!


Forum Jump:


Users browsing this thread: 1 Guest(s)