Press different Keys

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
saulloa
Posts: 1
Joined: 13 May 2021, 16:41

Press different Keys

13 May 2021, 16:50

Hello, I need a script that will press the Page Down key 4 times, and right after 4 instances, press the F5 key,

this is what i currently have written up:

Code: Select all

#SingleInstance, Force 

#Persistent
SetTimer, PressTheKey, 10000
Return

PressTheKey:
Send, {PgDn 4}
return
Send, {F5}
return
[Mod edit: [code][/code] tags added.]
Last edited by gregster on 14 May 2021, 01:06, edited 1 time in total.
Reason: Topic moved to 'Ask For Help' (AHK v1), since this doesn't seem to be v2 code.
aifritz
Posts: 301
Joined: 29 Jul 2018, 11:30
Location: Germany

Re: Press different Keys

14 May 2021, 01:45

Code: Select all

#SingleInstance, Force 

#Persistent
SetTimer, PressTheKey, 10000
Return

PressTheKey:
i++
Send {PgDn 4}
If (i = 4)
  {
    i := 0
    Send {F5}
  }	
return
Rohwedder
Posts: 7623
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Press different Keys

14 May 2021, 02:24

Hallo,
or with ternary:

Code: Select all

#SingleInstance, Force 

#Persistent
SetTimer, PressTheKey, 10000
Return

PressTheKey:
i++
Send {PgDn 4}
Send,% Mod(i, 4)?:"{F5}"
return
or with:

Code: Select all

PressTheKey:
Send,% "{PgDn 4}" (Mod(i:=1+(0 i), 4)?"":"{F5}")
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada and 236 guests