Class: ATT::PopupWindow

Inherits:
Object
  • Object
show all
Extended by:
FFI::Library
Defined in:
lib/popup/popup_window.rb

Constant Summary collapse

@@listen_threads =
[]

Class Method Summary collapse

Class Method Details

.is_popup?(hwnd) ⇒ Boolean

check the window of hwnd whether a popup window

Returns:

  • (Boolean)


10
11
12
# File 'lib/popup/popup_window.rb', line 10

def self.is_popup?(hwnd)
  GetWindow( hwnd, 4 ) != 0
end

.listen(interval = 5) ⇒ Object

:yields: popup



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/popup/popup_window.rb', line 16

def self.listen(interval=5) # :yields: popup
  th = Thread.new do
    Popup.record
    begin
      loop do 
        sleep interval
        news = Popup.find_all
        news.each do |popup|
          yield popup
        end
      end
    end
  end
  @@listen_threads << th
  th
end

.listen_threadsObject



48
49
50
# File 'lib/popup/popup_window.rb', line 48

def self.listen_threads
  @@listen_threads
end

.stop_listen(thread = 'all') ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/popup/popup_window.rb', line 33

def self.stop_listen(thread = 'all')
  if thread == 'all'
    @@listen_threads.each do |thread|
      begin
      thread.kill
      rescue Exception
        puts $!
      end
    end
    @@listen_threads =[]
  elsif @@listen_threads.delete(thread)
    thread.kill
  end
end