Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Env ; Recommended for performance and compatibility with future AutoHotkey releases.
- ; #Warn ; Enable warnings to assist with detecting common errors.
- SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
- SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
- ;MsgBox, 4,, Would you like to continue?
- ;IfMsgBox, No
- ; return ; If No, stop the code from going further.
- ;MsgBox, You pressed YES. ; Otherwise, the user picked yes.
- ; /*
- ; * SendMessageTimeout values
- ;
- ; #define SMTO_NORMAL 0x0000
- ; #define SMTO_BLOCK 0x0001
- ; #define SMTO_ABORTIFHUNG 0x0002
- ; #if(WINVER >= 0x0500)
- ; #define SMTO_NOTIMEOUTIFNOTHUNG 0x0008
- ; #endif /* WINVER >= 0x0500 */
- ; #endif /* !NONCMESSAGES */
- ;
- ;
- ; SendMessageTimeout(
- ; __in HWND hWnd,
- ; __in UINT Msg,
- ; __in WPARAM wParam,
- ; __in LPARAM lParam,
- ; __in UINT fuFlags,
- ; __in UINT uTimeout,
- ; __out_opt PDWORD_PTR lpdwResult);
- ; */
- CheckIfResponding(ProcessIdentifier) {
- NR_temp =0 ; init
- TimeOut = 100 ; milliseconds to wait before deciding it is not responding - 100 ms seems reliable under 100% usage
- ; WM_NULL =0x0000
- ; SMTO_ABORTIFHUNG =0x0002
- WinGet, wid, ID, %ProcessIdentifier% ; retrieve the ID of a window to check
- Responding := DllCall("SendMessageTimeout", "UInt", wid, "UInt", 0x0000, "Int", 0, "Int", 0, "UInt", 0x0002, "UInt", TimeOut, "UInt *", NR_temp)
- return %Responding%
- ;~ If Responding = 1 ; 1= responding, 0 = Not Responding
- ;~ Msgbox, Responding
- ;~ Else
- ;~ Msgbox, Not Responding
- }
- F7::
- Processname=discord.exe
- Process, Exist, %Processname%
- if !ErrorLevel
- {
- MsgBox, % "Process " Processname " does not exists"
- return
- }
- pid:= ErrorLevel
- discord := % "ahk_pid " pid
- IfWinNotActive, %discord%
- {
- WinActivate, %discord%
- WinWaitActive, %discord%
- }
- WinMaximize
- ;Send {Click, 220, 1016}
- WinGetTitle, WindowTitle, %discord%
- ;~ MsgBox, %WindowTitle%
- ControlClick, X220 Y1016, %WindowTitle%
- return
- F6::
- MsgBox, %A_Cursor%
- WinGet, pid, PID, A
- WinGet, pname, ProcessName, A
- MsgBox, %pid% %pname%
- app := % "ahk_pid " pid
- WindowStatus := CheckIfResponding(app)
- If WindowStatus = 1
- MsgBox, Responding
- Else
- MsgBox, Not responding
- return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement