Script only runs once

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
shiro_design
Posts: 14
Joined: 21 Apr 2019, 13:57

Script only runs once

24 Apr 2019, 12:09

HI, I have simple script that plays a gif when the control key is pressed down. It closes when the control is released. My goal with this is to create very short how to vids when a key is pressed. I'm new to autohotkey so i'm picking this up as i go along. I have no real experience in coding. So i've put this together from bits I've found.The problem i have with the script is it only runs once even if i put the #Persistent tag. I want this to be there in the background so whenever the user holds down the key the animation plays.

#SingleInstance force
#Persistent

~ctrl::
keywait, Ctrl, D
file := "C:\Users\JV\Desktop\GIFAHK\kanye.gif"
Gui, Margin, 1, 1
Gui, +HwndhWndGifAnim +Resize +LabelGifAnimationSampleGui ; Set it

resizable
AnimatedGifControl(hWndGifAnim, file, "hWndhWndGifAnimControl")
Gui, Show,, Animated Gif Gui Control Sample 3


GifAnimationSampleGuiSize:
GuiControl, Move, % hWndGifAnimControl, % "H" (A_GuiHeight-20) " W"

(A_GuiWidth-20)


keywait, Ctrl,
WinActivate, Animated Gif Gui Control Sample 3,
WinWaitActive, Animated Gif Gui Control Sample 3,
WinKill, Animated Gif Gui Control Sample 3
MsgBox You released control key
return
Osprey
Posts: 453
Joined: 18 Nov 2017, 05:50

Re: Script only runs once

24 Apr 2019, 17:21

It stays running for me. I had to comment out the AnimatedGifControl() function call, though, because you didn't provide that. That could mean that that function is exiting the script, either deliberately or by crashing.
Last edited by Osprey on 26 Apr 2019, 03:08, edited 1 time in total.
shiro_design
Posts: 14
Joined: 21 Apr 2019, 13:57

Re: Script only runs once

26 Apr 2019, 01:56

For some reason it wasn't working but then after a restart it started working again. Maybe it was a bug or because i had my machine on hibernate earlier. Thanks for the reply.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: filipemb, mikeyww, PsysimSV, USS_Sandhu and 319 guests