Script not working after wakeup from hibernation

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
kdaube
Posts: 86
Joined: 02 Nov 2015, 03:11

Script not working after wakeup from hibernation

15 Apr 2020, 08:12

Dear all,
Since recent times (hidden Win 10 update?) a script does not work after wakeup from hibernation.
The scipt sets up a large number of hot strings, which all are invokes via a 'trigger character'.
Since this happens I need to reload the script (which isin storage and the icon is in the tray).
Operating system: 10.0.18363 64 bit en
BNOLI
Posts: 548
Joined: 23 Mar 2020, 03:55

Re: Script not working after wakeup from hibernation

15 Apr 2020, 08:31

Script(s) running in Admin-mode?
Remember to use [code]CODE[/code]-tags for your multi-line scripts. Stay safe, stay inside, and remember washing your hands for 20 sec !
User avatar
kdaube
Posts: 86
Joined: 02 Nov 2015, 03:11

Re: Script not working after wakeup from hibernation

15 Apr 2020, 10:46

I think it is not in admin mode - because it has not introction such as the following

Code: Select all

#SingleInstance Force
if !A_IsAdmin ; must be first in script (see H:\Utilities\DDDutils\Test-ahks\Run-as-admin.ahk)
  {           ; see *verb in AHK help --- here the context-menu Run as Administrator 
  try Run *RunAs "%A_ScriptFullPath%" 
  catch 
    MsgBox, You clicked Cancel when asked to elevate the script`nPlease Run this again with admin rights.
  ExitApp
  }
What I do not understand is the fact, that it worked until recently (beinning of april) also after hibernation. BTW in my log the resume code is not in all cases the same:

Code: Select all

Wed 2020-04-15 09:07:28	Starting 361	; ;
Wed 2020-04-15 12:47:03	; ;	Force hibernate
Wed 2020-04-15 12:47:09	; ;	Suspend 4
Wed 2020-04-15 14:29:24	; ;	Resume 7
Wed 2020-04-15 15:09:50	Logging	; ; Since a while (2 weeks?) AHK script ShortHand does not work after wake up from hibernation a
Wed 2020-04-15 15:47:38	; ;	Suspend 4
Wed 2020-04-15 17:25:46	; ;	Resume 7
Wed 2020-04-15 17:25:46	; ;	Resume 18
The problem occurs If resume code is 7 (without the following 18).
In both cases I just hit the power button to revive windows - I have no clue why this creates different resume codes depending on the type of hibernation (suspend 4). Maybe I do not log the complete sleep condition...
Klaus Daube, Zürich, CH
User avatar
kdaube
Posts: 86
Joined: 02 Nov 2015, 03:11

Re: Script not working after wakeup from hibernation

08 May 2020, 03:02

I have now introduced the script with this code:

Code: Select all

#SingleInstance Force
if !A_IsAdmin { ; must be first in script  ; see *verb in AHK help --- here the context-menu Run as Administrator 
  try Run *RunAs "%A_ScriptFullPath%" 
  catch 
    MsgBox, You clicked Cancel when asked to elevate the script`nPlease Run this again with admin rights.
  ExitApp
} ; 
It seems that this cured the problem - thanks BNOLI for the hint!
Klaus Daube, Zürich, CH
User avatar
kdaube
Posts: 86
Joined: 02 Nov 2015, 03:11

Re: Script not working after wakeup from hibernation

10 Sep 2020, 01:31

... seems to help only for resume 10, but not resume 7

PBT_APMRESUMESUSPEND 0x0007 resuming from a low-power state
PBT_APMPOWERSTATUSCHANGE 0x000A e.g. switch from battery to A/C; low b attery

In my case 7 is after 'self-hibernation' (sleeping according to power settings),
10 is after 'forced hibernation' (PBT_APMSUSPEND 0x0004 typically broadcast when all applications and installable drivers have returned TRUE to a previous PBT_APMQUERYSUSPEND event).

Well, it's not that a drama, because script can be reloaded via system tray - but not elegant.
Klaus Daube, Zürich, CH

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: AHK_user and 202 guests