Script stops working -> why?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
John John
Posts: 2
Joined: 18 Jun 2018, 07:10

Script stops working -> why?

29 Aug 2018, 11:04

Hi All,

I wrote a script, run it, but it stops working after some period of time (~15-30min).

Honestly, I don't understand why it stops working (hotkeys, which I defined in the script, stop working).

Could someone take a look what's the problem in the script?

Here is the script. I run it as an Administrator under Win10 x64 Home OS.
----------------------------------------------------------------------

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#NoTrayIcon ; No Try Icon in the System Try
#SingleInstance force ;
#Hotstring EndChars `n `t
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetTitleMatchMode, 2 ; windows title can contain WinTitle anywhere inside it to be a match
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; * [LogiTechMouse]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;---------------------------------------------------------------------
;* [ALL]
;---------------------------------------------------------------------

  ;-------------------------------------------------------------------
  ; Wheel Tilt
  ;-------------------------------------------------------------------

WheelLeft::
  send {Volume_Up}
return

WheelRight::
  send {Volume_Down}
return

;---------------------------------------------------------------------
;* [Google Chrome]
;---------------------------------------------------------------------
#IfWinActive ahk_exe chrome.exe
  ;------------------------------
  ; Arrow Left
  ;------------------------------
  XButton1:: ; Back Button
    send {Left}
  return ;
  ;------------------------------
  ; Arrow Right
  ;------------------------------
  XButton2:: ; Forward Button
   ;msgbox, XButton2
    send {Right}
  return ;
  ;------------------------------
  ; Page Down (LButton+X1)
  ;------------------------------
  ~LButton & ~XButton1::
    send {PgDn}
    send {ESC}
  return ;
  ;------------------------------
  ; Page Down (RButton+X1)
  ;------------------------------
  ~RButton & XButton1::
    send {PgDn}
    send {ESC}
  return ;
  ;------------------------------
  ; Page Up (RButton+X1)
  ;------------------------------
  ~LButton & ~XButton2::
    send {PgUp}
    send {ESC}
  return ;
  ;------------------------------
  ; Page Up
  ;------------------------------
  ~RButton & ~XButton2::
    send {PgUp}
    send {ESC}
  return ;
  ;----------
  ; Click
  ;----------
return
#IfWinActive ; chrome.exe

;---------------------------------------------------------------------
;* [Firefox]
;---------------------------------------------------------------------
#IfWinActive ahk_exe firefox.exe
  ;------------------------------
  ; Page Down
  ;------------------------------
  ~LButton & XButton1::
    send {PgDn}
  return ;
  ;------------------------------
  ; Page Up
  ;------------------------------
  ~LButton & XButton2::
    send {PgUp}
  return ;
return

----------------------------------------------------------------------

Thank you!
burque505
Posts: 1734
Joined: 22 Jan 2017, 19:37

Re: Script stops working -> why?

29 Aug 2018, 11:39

You might try

Code: Select all

#InstallMouseHook
at the top of your script to see if it helps.
The man page is here.
Edit: Note that it makes a script persistent, meaning you should use ExitApp to stop your script if you use it.
Regards,
burque505
Guest

Re: Script stops working -> why?

29 Aug 2018, 12:42

You have a few too many (two) returns in there that don't do anything but that wouldn't be the problem I suspect.
If it keeps on happening, simply add a SetTimer and Reload the script every 5 minutes or so, that way it should always work.
Crude solution but probably very effective.
John John
Posts: 2
Joined: 18 Jun 2018, 07:10

Re: Script stops working -> why?

29 Aug 2018, 13:51

Thanks for your suggestions! Probably a problem is in contention with the Logitech software ... Will update you later how it works...
User avatar
jackdunning
Posts: 126
Joined: 01 Aug 2016, 18:17
Contact:

Re: Script stops working -> why?

29 Aug 2018, 13:53

I posted this a few years back in the archived AutoHotkey forum. I have stopped using SendMode and now rarely (if ever) experience Hotkey outages. I use the SendInput command when I want SendInput.

"At some point, I discovered that the SendMode command may interfere with proper operation of some Hotkeys and/or Hotstrings. Not immediately, but after the script runs for a while. As far as I can tell it is not a problem with SendMode, but other programs which may be running at the same time. (I don't know which programs.) I tried changing the command, but as I later updated my information (see below), it was usually best to just eliminate the command completely. I don't know all the ramifications of doing this (nor whether it has anything to do with your problem), but it worked for me.

"Wednesday, October 29, 2014, I just tried compiling the next week's Hotstring code with the SendMode InputThenPlay line (discussed last week) at the beginning of the script. It completely screwed up the Hotstrings. My recommendation is now to remove any SendMode commands from your scripts unless you have a compelling reason to keep it. (I'm not sure what that would be.) If I get more information on the SendMode command and how to prevent the associated problems, I'll pass them along."

Someone may have a better answer. It's a mystery to me.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Lamron750, mikeyww and 225 guests