"Fossies" - the Fresh Open Source Software Archive

Member "AutoHotkey_L-1.1.33.09/source/application.h" (8 May 2021, 4380 Bytes) of package /windows/misc/AutoHotkey_L-1.1.33.09.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "application.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2 AutoHotkey
    3 
    4 Copyright 2003-2009 Chris Mallett (support@autohotkey.com)
    5 
    6 This program is free software; you can redistribute it and/or
    7 modify it under the terms of the GNU General Public License
    8 as published by the Free Software Foundation; either version 2
    9 of the License, or (at your option) any later version.
   10 
   11 This program is distributed in the hope that it will be useful,
   12 but WITHOUT ANY WARRANTY; without even the implied warranty of
   13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   14 GNU General Public License for more details.
   15 */
   16 
   17 #ifndef application_h
   18 #define application_h
   19 
   20 #include "defines.h"
   21 
   22 // Callers should note that using INTERVAL_UNSPECIFIED might not rest the CPU at all if there is
   23 // already at least one msg waiting in our thread's msg queue:
   24 // Use some negative value unlikely to ever be passed explicitly:
   25 #define INTERVAL_UNSPECIFIED (INT_MIN + 303)
   26 #define NO_SLEEP -1
   27 enum MessageMode {WAIT_FOR_MESSAGES, RETURN_AFTER_MESSAGES, RETURN_AFTER_MESSAGES_SPECIAL_FILTER};
   28 bool MsgSleep(int aSleepDuration = INTERVAL_UNSPECIFIED, MessageMode aMode = RETURN_AFTER_MESSAGES);
   29 
   30 // This macro is used to Sleep without the possibility of a new hotkey subroutine being launched.
   31 // Timed subroutines will also be prevented from running while it is enabled.
   32 // It should be used when an operation needs to sleep, but doesn't want to be interrupted (suspended)
   33 // by any hotkeys the user might press during that time.  Reasons why the caller wouldn't want to
   34 // be suspended:
   35 // 1) If it's doing something with a window -- such as sending keys or clicking the mouse or trying
   36 //    to activate it -- that might get messed up if a new hotkey fires in the middle of the operation.
   37 // 2) If its a command that's still using some of its parameters that might reside in the deref buffer.
   38 //    In this case, the launching of a new hotkey would likely overwrite those values, causing
   39 //    unpredictable behavior.
   40 #define SLEEP_WITHOUT_INTERRUPTION(aSleepTime) \
   41 {\
   42     g_AllowInterruption = FALSE;\
   43     MsgSleep(aSleepTime);\
   44     g_AllowInterruption = TRUE;\
   45 }
   46 
   47 // Have this be dynamically resolved each time.  For example, when MsgSleep() uses this
   48 // while in mode WAIT_FOR_MESSSAGES, its msg loop should use this macro in case the
   49 // value of g_AllowInterruption changes from one iteration to the next.  Thankfully,
   50 // MS made WM_HOTKEY have a very high value, so filtering in this way should not exclude
   51 // any other important types of messages:
   52 #define MSG_FILTER_MAX (IsInterruptible() ? 0 : WM_HOTKEY - 1)
   53 #define INTERRUPTIBLE_IN_EMERGENCY (g_AllowInterruption && !g_MenuIsVisible)
   54 
   55 #define DoWinDelay \
   56     if (::g->WinDelay > -1)\
   57     {\
   58         MsgSleep(::g->WinDelay);\
   59     }
   60 
   61 #define DoControlDelay \
   62     if (g->ControlDelay > -1)\
   63     {\
   64         MsgSleep(g->ControlDelay);\
   65     }
   66 
   67 ResultType IsCycleComplete(int aSleepDuration, DWORD aStartTime, bool aAllowEarlyReturn);
   68 
   69 // These should only be called from MsgSleep() (or something called by MsgSleep()) because
   70 // we don't want to be in the situation where a thread launched by CheckScriptTimers() returns
   71 // first to a dialog's message pump rather than MsgSleep's pump.  That's because our thread
   72 // might then have queued messages that would be stuck in the queue (due to the possible absence
   73 // of the main timer) until the dialog's msg pump ended.
   74 bool CheckScriptTimers();
   75 #define CHECK_SCRIPT_TIMERS_IF_NEEDED if (g_script.mTimerEnabledCount && CheckScriptTimers()) return_value = true; // Change the existing value only if it returned true.
   76 
   77 void PollJoysticks();
   78 #define POLL_JOYSTICK_IF_NEEDED if (Hotkey::sJoyHotkeyCount) PollJoysticks();
   79 
   80 bool MsgMonitor(HWND aWnd, UINT aMsg, WPARAM awParam, LPARAM alParam, MSG *apMsg, LRESULT &aMsgReply);
   81 
   82 void InitNewThread(int aPriority, bool aSkipUninterruptible, bool aIncrementThreadCountAndUpdateTrayIcon
   83     , ActionTypeType aTypeOfFirstLine);
   84 void ResumeUnderlyingThread(LPTSTR aSavedErrorLevel);
   85 BOOL IsInterruptible();
   86 
   87 VOID CALLBACK MsgBoxTimeout(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime);
   88 VOID CALLBACK AutoExecSectionTimeout(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime);
   89 VOID CALLBACK UninterruptibleTimeout(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime);
   90 VOID CALLBACK InputTimeout(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime);
   91 VOID CALLBACK RefreshInterruptibility(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime);
   92 
   93 #endif