Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trigger in Exe
#1
Hi Gintaras and all QM fellows!

I am coding a little app that auto checks some pages on the web. That website has a lot of pop-up ads, very annoying stuff that slow down all the process. I've made a trigger that closes every pop-up (when created window with class: Mozilla*...) and so on. It works fine and very quickly.

My question is: I made an exe file and the trigger is a feature not available in exe, so how can I deal with it?
#2
For example, before the exe-macro starts checking web pages, it can launch other thread (with mac) that repeatedly (every 0.1 s) checks the active window (win, wintest) and closes it if need. The "trigger" will live as long as the exe process.
#3
Thanks for the reply. Dėkoju!
#4
More intelligent trigger than rep - use hook. QM uses this hook for its window triggers and accessible object triggers.
Function exe_window_trigger
Code:
Copy      Help
function hHook event hwnd idObject idChild dwEventThread dwmsEventTime

if getopt(nargs)!=7
,int hh=SetWinEventHook(EVENT_SYSTEM_FOREGROUND EVENT_SYSTEM_FOREGROUND 0 &exe_window_trigger 0 0 WINEVENT_OUTOFCONTEXT)
,if(!hh) end F"{ERR_FAILED}. {_s.dllerror}"
,opt waitmsg 1
,wait -1
,UnhookWinEvent hh
,ret

;This code runs whenever a window activated.

outw hwnd

;if wintest(hwnd ...)
;,clo hwnd

Main macro:
mac "exe_window_trigger"
then do the main work
#5
Extra thanks!

The ultimate pop-up killer is working smoothly. :mrgreen:
#6
Is this a correct way to include this into a QM dialog?
I wanted to stop exe_window_trigger after de the QM dialog ee exits/ends.
I works perfectly, but I wanted to know if this is a correct way doing it.

(I declared hDlg thread global and used it in de exe_window_trigger function.)

Function ee
Code:
Copy      Help
int hh=SetWinEventHook(EVENT_SYSTEM_FOREGROUND EVENT_SYSTEM_FOREGROUND 0 &exe_window_trigger 0 0 WINEVENT_OUTOFCONTEXT)
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog" "4"
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040A00 "*" "" "" ""

if(!ShowDialog(dd &sub.DlgProc 0)) ret


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,,int- main_dlg;main_dlg=hDlg
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1


Function exe_window_trigger
Code:
Copy      Help
function hHook event hwnd idObject idChild dwEventThread dwmsEventTime
int- main_dlg
if getopt(nargs)!=7
,int hh=SetWinEventHook(EVENT_SYSTEM_FOREGROUND EVENT_SYSTEM_FOREGROUND 0 &exe_window_trigger 0 0 WINEVENT_OUTOFCONTEXT)
,if(!main_dlg)end
,if(!hh) end F"{ERR_FAILED}. {_s.dllerror}"
,opt waitmsg 1
,wait -1
,UnhookWinEvent hh
,ret

;This code runs whenever a window activated.

outw hwnd

;if wintest(hwnd ...)
;,clo hwnd


Forum Jump:


Users browsing this thread: 1 Guest(s)