is there any chance Autohotkey would lead to browser frozen on input?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
auto1127
Posts: 3
Joined: 13 May 2017, 14:41

is there any chance Autohotkey would lead to browser frozen on input?

Post by auto1127 » 03 Feb 2023, 01:26

I'm using a new Windows 10 gaming computer, AMD 6-core CPU, 16 GB ram, 512 GB SSD. I'm usually running three AHK scripts at a time. (They do different things.)

I've been experiencing freezing on input. The computer will freeze while I'm typing, then suddenly catch up about 5 to 8 seconds later.

As it could be just about anything.. motherboard drivers, SSD driver bugs, Display driver, any other software I have installed ... I wanted to just investigate the possibility that AHK can cause this kind of freezing. (I'm using Version 1.1). Has anyone heard of this?

Regards,
Mike

swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: is there any chance Autohotkey would lead to browser frozen on input?

Post by swagfag » 03 Feb 2023, 02:43

its rather unlikely, but then again scripts(especially badly coded ones) can do all sorts of wonky stuff. without seeing the code, this conversation is meaningless. u can always run them on a different device and check if u get freezes there

User avatar
mikeyww
Posts: 26601
Joined: 09 Sep 2014, 18:38

Re: is there any chance Autohotkey would lead to browser frozen on input?

Post by mikeyww » 03 Feb 2023, 06:54

An even simpler test:
1. Remove script links from startup folders.
2. Reboot.
3. Run no scripts.
4. See if system works.

You then have your answer quickly.

You can combine your scripts into one. In some situations, that is a better approach and can also avoid some conflicts.

auto1127
Posts: 3
Joined: 13 May 2017, 14:41

Re: is there any chance Autohotkey would lead to browser frozen on input?

Post by auto1127 » 03 Feb 2023, 17:06

Thanks everyone. I should have said it's very intermittent. It's one of those problems that is hard to debug because it may not happen for hours, then suddenly happen several times. That's why I wanted to just get a sense first of the possibilities so I know what to try first. And it sounds like the scripts could potentially do that. I'll attach my scripts for your interest. These are the two I usually run.

Code: Select all

;----------------------------------------------------------------------
;; Two quick capslock to turn on mouse mode
$CapsLock::

   if ( GetKeyState("CapsLock", "T") )
   {
        newstate = off
   }
   else
   {   
        newstate = on
   }
   SetCapsLockState, %newstate%
   
   if ( A_PriorHotkey != A_ThisHotKey || A_TimeSincePriorHotkey > 400 )
   {
      Return
   }
   
   ;; At this point we know a double-capslock has happened.
   ;; This will start mouse mode. A return value of 
   ;; a 1 means that we should start the menu. 0 means return immediately.

   gosub MouseModeStart
Return


MouseModeStart:
   slowStep := 1
   mediumStep := 9
   fastStep := 50
   preDelayTime := 90
   interDelayTime := 40
   timeLastSpacebarPress := A_TickCount - 10000
   fastMode := 0

   Gosub, regularToolTip

   Hotkey, *j, leftMouse, On
   Hotkey, *l, rightMouse, On
   Hotkey, *k, downMouse, On
   Hotkey, *i, upMouse, On
   Hotkey, *d, rightClickMouse, On
   Hotkey, *f, leftClickMouse, On
   Hotkey, *t, wheelUpMouse, On
   Hotkey, *g, wheelDownMouse, On
   Hotkey, *Space, registerSpacePress, On
   Hotkey, *v, exitMouse, On
Return

exitMouse:
   ToolTip
   Hotkey, *j, Off
   Hotkey, *l, Off
   Hotkey, *k, Off
   Hotkey, *i, Off
   Hotkey, *d, Off
   Hotkey, *f, Off
   Hotkey, *t, Off
   Hotkey, *g, Off
   Hotkey, *Space, Off
   Hotkey, *v, Off
Return

enterFastMode:
  fastMode := 1
Return

registerSpacePress:
   timeLastSpacebarPress := A_TickCount
Return

rightMouse:
   gx := 1
   gy := 0
   gkey = l
   Gosub, generalMouse
Return

leftMouse:
   gx := -1
   gy := 0
   gkey = j
   Gosub, generalMouse
Return

upMouse:
   gx := 0
   gy := -1
   gkey = i
   Gosub, generalMouse
Return

downMouse:
   gx := 0
   gy := 1
   gkey = k
   Gosub, generalMouse
Return


generalMouse:
   if (A_TickCount - timeLastSpacebarPress < 350)
      fastMode := 1
   GoSub generalMouseMove
   Sleep, %preDelayTime%
   SetTimer, generalMouseMove, %interDelayTime%
   KeyWait, %gkey%
   fastMode := 0
   SetTimer, generalMouseMove, Off
Return

generalMouseMove:
   c := GetKeyState("ctrl")
   if c 
      factor := slowStep
   else if (fastMode)
      factor := fastStep
   else
      factor := mediumStep
   x := factor * gx
   y := factor * gy
   MouseMove, %x%, %y%, 0, R
Return

leftClickMouse:
  Click, Down
  KeyWait, f
  Click, Up
Return

rightClickMouse:
  Click, Right
Return

wheelDownMouse:
  Click, WheelDown
Return

wheelUpMouse:
  Click, WheelUp
Return

regularToolTip:
   CoordMode, ToolTip
   t := "M  M  M  M  M  M  M  M  M  M  M  M  M  M  M  M "
   tt := t . t . t . t . t
   ToolTip, %tt%, 0, 0
Return



Code: Select all

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; For the use of the Goldtouch keyboard, these
;; window-raising commands use keys other than 
;; the numeric pad.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Definition of windowSelctionMode:
;;
;;     this is obsolete now
;;
;;  = 0 means cygwin emacs slection
;;  = 1 mean local emacs selection
;;  = 2 mean Microsoft word selection
;;
;;  now it is just for selecting the terminal and 
;;   = 0 means cygwin
;;   = 1 means windows


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Definition of keyboardLayoutMode
;;  = 0 means goldtouch (this corresponds to names altPgUpTitle,
;;      altPgDownTitle, and altEndTitle)
;;  = 1 means laptop (meaning of altPgUpTitle, altPgDownTitle, and
;;        altEndTitle are altered)



setSelectKeysLocal:
   altLeftTitle = lleft
   altRightTitle = lright
   altUpTitle = xterm
   altDownTitle = "bach 1"
   altPgUpTitle = GHCi
   altPgDnTitle = cmd.exe
   altEndTitle = Firefox
Return

setSelectKeysCygwin:
   altLeftTitle := "left emacs"
   altRightTitle := "right emacs"
   altUpTitle = xterm
   altDownTitle := "bach 1"
   altPgUpTitle := "bach 3"
   altPgDnTitle := "bach 2"
   altEndTitle := "Firefox"
Return

/*
setBindings()
{
  global
  if ( windowSelectionMode == 0 )
    Gosub setSelectKeysCygwin
  else 
    Gosub setSelectKeysLocal
}
*/

activateRightCmdExe()
{
  activateTerminal(1)
}


activateLeftCmdExe()
{
  activateTerminal(0)
}

/*
; leftRight = 0 means activate left, 
;           = 1 means right
activateTerminal(left_right)
{
   activateTerminal2(left_right, 0)
   activateTerminal2(left_right, 1)
}
*/

; leftRight = 0 means activate left, 
;           = 1 means right
; cmd_mingw = 0 means search cmd.exe windows, 
;           = 1 means search MINGW windows
activateTerminal(left_right)
{
   activeId := WinExist("A")
   SetTitleMatchMode, 2
   midScreen := A_ScreenWidth / 2

   WinGet, idList, List, ahk_exe sh.exe  
   Loop, %idList%
   {
      id := idList%A_Index%
      if (id == activeId) {
         continue
      }
      WinGetPos, x, y, width, height, ahk_id %id%
      midWin := x + width/2
      if ( left_right == 0 && midWin < midScreen
           || left_right == 1 && midWin > midScreen )
      {
         WinActivate, ahk_id %id%
         return
      }
   }
   WinGet, idList, List, Command
   Loop, %idList%
   {
      id := idList%A_Index%
      if (id == activeId) {
         continue
      }
      WinGetPos, x, y, width, height, ahk_id %id%
      midWin := x + width/2
      if ( left_right == 0 && midWin < midScreen
           || left_right == 1 && midWin > midScreen )
      {
         WinActivate, ahk_id %id%
         return
      }
   }
}


!Left:: 
    SetTitleMatchMode, 2
    WinActivate, left
Return

!Right:: 
    SetTitleMatchMode, 2
    WinActivate, right
Return

!Down:: 
   GoSub LowerLeft
Return


LowerLeft:
  activateLeftCmdExe()
Return

!Up:: 
  ; setBindings()
  if ( windowSelectionMode == 1 )
  {
    SetTitleMatchMode, 2
    WinActivate, wide
  }
  else
  {
    SetTitleMatchMode, 2
    WinActivate, %altUpTitle%
  }
Return

!PgDn:: 
  GoSub LowerRight
Return 

LowerRight:
  activateRightCmdExe()
Return

/*
!PgUp:: 
  setBindings()
  SetTitleMatchMode, 2
  WinActivate, %altPgUpTitle%
Return
*/

/*

!End::
  setBindings()
  SetTitleMatchMode, 2
  if ( A_PriorHotkey == A_ThisHotKey && A_TimeSincePriorHotkey < 2000 )
    WinActivateBottom, %altEndTitle%
  else
    WinActivate, %altEndTitle%
Return
*/

;======================================================================
; Selecting microsoft word
;======================================================================

;----------------------------------------------------------------------
selectWordLeftWindow( idList ) 
{
   ; Select bottommost Word window on the left
   s := 0
   loop, %idList%
   {
     s := s + 1
   }
   v = idList_1
   MsgBox, 
}

;----------------------------------------------------------------------
selectWord( leftRight ) 
{
   SetTitleMatchMode, 2
   WinGet, idList, List, Microsoft Word
   bottomLeftWindowId := 0
   bottomRightWindowId := 0
   centerScreen := A_ScreenWidth / 2
   Loop, %idList%
   {
     id := idList%A_Index%
     WinGetPos, x, y, width, height, ahk_id %id%
     centerX := x + width/2
     if ( centerX < centerScreen )
         bottomLeftWindowId := id
     else
         bottomRightWindowId := id
   }
   if ( bottomLeftWindowId != 0 and leftRight == "left" )
      WinActivate, ahk_id %bottomLeftWindowId%
   else if ( bottomRightWindowId != 0 and leftRight == "right" )
      WinActivate, ahk_id %bottomRightWindowId%
}

;======================================================================
; Moving windows left or right
;======================================================================
moveTopWindow( placement )
{
   global rememberTopTitle
   WinGetPos, x, y, width, height, %rememberTopTitle%
   if ( placement == "l" )
   {
      newX := A_ScreenWidth /4 - width / 2
   }
   else if ( placement == "r" )
   {
      newX := 3*A_ScreenWidth/4 - width/2
   }
   else if (placement == "L" )
   {
      newX := 5
   }
   else
   {
      newX := A_ScreenWidth - width - 5
   }
   WinMove %rememberTopTitle%,, %newX%, %y%
}


User avatar
mikeyww
Posts: 26601
Joined: 09 Sep 2014, 18:38

Re: is there any chance Autohotkey would lead to browser frozen on input?

Post by mikeyww » 03 Feb 2023, 18:02

I maintain my recommendation, especially because it requires no real work, and after one day without your scripts, you will have greater confidence about whether the scripts are problematic. If the problem occurs, you will be completely certain that it has nothing to do with the scripts.

If you think that you are triggering hotkeys in your script, you can add logging, visual confirmation, or audible signals to help you understand that quickly. AHK has additional debugging tools as well-- ListLines, etc.

Post Reply

Return to “Ask for Help (v1)”