Basic help with settimer

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
DAVE_100
Posts: 2
Joined: 03 Dec 2019, 16:40

Basic help with settimer

Post by DAVE_100 » 02 Jun 2023, 14:32

Hi all

I'm trying to make the below code work, it should behave as follow:

Press f1 > wait till either Notepad or My Documents is opened. Give relevant messagebox

Currently it almost works, but the messagebox will only appear upon seeing My Documents only after the Notepad messagebox has triggered first. I need it to be looking for whichever I enter first. Also sometimes the messagebox pops up twice, quickly after closing, how do I get this to just run once?

Any ideas how I can tweak this? Thanks in advance.

Code: Select all

f1::

settitlematchmode, 2
settimer, docs, -1
settimer, notepad, -1
;return

docs:
winwaitactive, ahk_class CabinetWClass
msgbox, docs
return

notepad:
winwaitactive, ahk_class Notepad
msgbox, Notepad


return
[Mod edit: Moved topic to AHK v1 help, since this is not v2 code.]

User avatar
V0RT3X
Posts: 231
Joined: 20 May 2023, 21:59
Contact:

Re: Basic help with settimer

Post by V0RT3X » 02 Jun 2023, 15:11

I'm just learning this stuff myself, but until one of the experienced folks show up, you might want to look at this..
https://www.autohotkey.com/docs/v1/lib/_If.htm

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

Re: Basic help with settimer

Post by mikeyww » 02 Jun 2023, 16:42

Welcome to this AutoHotkey forum!

Code: Select all

#Requires AutoHotkey v1.1.33
GroupAdd doc, ahk_class CabinetWClass
GroupAdd doc, ahk_class Notepad

F1::
SoundBeep 1500
WinWaitActive ahk_group doc
WinGetClass class
MsgBox 64, Class, % class
Return

DAVE_100
Posts: 2
Joined: 03 Dec 2019, 16:40

Re: Basic help with settimer

Post by DAVE_100 » 02 Jun 2023, 17:20

Thank you, I'm so sorry I now need to do the same but where the class is the same but the window title is different, are you able to help with that too please? I really am grateful, thank you for your response.

Eg the below, which isn't working..

Code: Select all

F1::
GroupAdd doc, Google
GroupAdd doc, Yahoo UK
SoundBeep 1500
WinWaitActive ahk_group doc

IfWinActive, google
MsgBox 64, this is the Google website

  IfWinActive, Yahoo UK
MsgBox 64, this is the Yahoo website

Return

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

Re: Basic help with settimer

Post by mikeyww » 02 Jun 2023, 17:49

Check Window Spy for the WinTitle info. Use the leading text. Window titles are case sensitive.

See documentation for IfWinActive. The statement is deprecated and not recommended.

Code: Select all

#Requires AutoHotkey v1.1.33
GroupAdd doc, Google
GroupAdd doc, Yahoo UK

F1::
SoundBeep 1500
WinWaitActive ahk_group doc
WinGetTitle title
MsgBox % title
Return

Post Reply

Return to “Ask for Help (v1)”