How to improve my first script?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Rushu
Posts: 4
Joined: 29 May 2017, 09:15

How to improve my first script?

29 May 2017, 16:37

hi

the goal of this script is to press multiple keys with just one, but in a sequence
so when you press F1:

— F10 will be pressed but not hold
— wait briefly
— type #s m1
— press enter
— wait briefly again
— F12 will be pressed but not hold

that's it, i'll use it from F1 to F12

I want to make it faster if possible, and improve it's performance, because I feel that it can be short and better
I want too that every 5 minutes it will, automatically, type and send something, but how I make so it will only send if a specific program is being used?

also, how can I make so every 3 minutes it will press (but not hold) something and click somewhere in the screen?

Code: Select all

#NoEnv
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
ListLines Off
Process, Priority, , A
SetBatchLines, -1
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
SetWinDelay, -1
SetControlDelay, -1
SendMode Input
;WAZAAAAA autohotkey.com/boards/viewtopic.php?f=7&t=6413

~F1::
    Send, {F10 down}{F10 up}
         Sleep, 10
             Send, {#}s m1
                 Send, {Enter}
                     Sleep, 10
                         Send, {F12 down}{F12 up}

return

~F2::
    Send, {F10 down}{F10 up}
         Sleep, 10
             Send, {#}s m2
                 Send, {Enter}
                     Sleep, 10
                         Send, {F12 down}{F12 up}

return

~F3::
    Send, {F10 down}{F10 up}
         Sleep, 10
             Send, {#}s m3
                 Send, {Enter}
                     Sleep, 10
                         Send, {F12 down}{F12 up}

return

~F4::
    Send, {F10 down}{F10 up}
         Sleep, 10
             Send, {#}s m4
                 Send, {Enter}
                     Sleep, 10
                         Send, {F12 down}{F12 up}

return
thanks for any helping
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: How to improve my first script?

30 May 2017, 02:25

Code: Select all

;
;WAZAAAAA autohotkey.com/boards/viewtopic.php?f=7&t=6413
;

#HotkeyInterval 99000000
#KeyHistory 0
ListLines Off
Process, Priority, , A
SetBatchLines, -1
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
SetWinDelay, -1
SetControlDelay, -1
SendMode Input
#SingleInstance, Force						; Added this for my convinience

~F1::JustDoIt(SubStr(A_ThisHotkey,0),10)    ; pressing the key is calling the function
~F2::JustDoIt(SubStr(A_ThisHotkey,0),10)    ; 1st parameter is holding/extracting the number of the key eg F2 -> 2
~F3::JustDoIt(SubStr(A_ThisHotkey,0),10)    ; 2nd parameter ist setting the time (in sec) you want to delay the flow
~F4::JustDoIt(SubStr(A_ThisHotkey,0),10)    ; additional parameters could hold which key to press, how often, ...
~F5::MsgBox % SubStr(A_ThisHotkey,0)        ; just for testing.

~F6::Run, https://autohotkey.com/docs/commands/_IfWinActive.htm
~F7::Run, https://autohotkey.com/docs/commands/SubStr.htm
~F8::Run, https://autohotkey.com/docs/commands/SetTimer.htm
~F9::Run, https://autohotkey.com/docs/Functions.htm

JustDoIt(Number,Delay) {            ; the function
    Send, {F10 down}{F10 up}
    Sleep, %Delay% * 1000           ; using the value that has been set at the call
    Send, {#}s m%Number%            ; using the value that has been set at the call
    Send, {Enter}
    Sleep, %Delay% * 1000           ; using the value that has been set at the call
    Send, {F12 down}{F12 up}
    return
    }
    
!r::Reload		; press Alt + r to reload the script
!x::ExitApp		; ...
!e::Edit		; ...
Edited.

Press F6/F7/F8/F9 for more details.
Good luck :)
User avatar
Rushu
Posts: 4
Joined: 29 May 2017, 09:15

Re: How to improve my first script?

02 Jun 2017, 19:44

BoBo wrote:

Code: Select all

;
;WAZAAAAA autohotkey.com/boards/viewtopic.php?f=7&t=6413
;

#HotkeyInterval 99000000
#KeyHistory 0
ListLines Off
Process, Priority, , A
SetBatchLines, -1
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
SetWinDelay, -1
SetControlDelay, -1
SendMode Input
#SingleInstance, Force						; Added this for my convinience

~F1::JustDoIt(SubStr(A_ThisHotkey,0),10)    ; pressing the key is calling the function
~F2::JustDoIt(SubStr(A_ThisHotkey,0),10)    ; 1st parameter is holding/extracting the number of the key eg F2 -> 2
~F3::JustDoIt(SubStr(A_ThisHotkey,0),10)    ; 2nd parameter ist setting the time (in sec) you want to delay the flow
~F4::JustDoIt(SubStr(A_ThisHotkey,0),10)    ; additional parameters could hold which key to press, how often, ...
~F5::MsgBox % SubStr(A_ThisHotkey,0)        ; just for testing.

~F6::Run, https://autohotkey.com/docs/commands/_IfWinActive.htm
~F7::Run, https://autohotkey.com/docs/commands/SubStr.htm
~F8::Run, https://autohotkey.com/docs/commands/SetTimer.htm
~F9::Run, https://autohotkey.com/docs/Functions.htm

JustDoIt(Number,Delay) {            ; the function
    Send, {F10 down}{F10 up}
    Sleep, %Delay% * 1000           ; using the value that has been set at the call
    Send, {#}s m%Number%            ; using the value that has been set at the call
    Send, {Enter}
    Sleep, %Delay% * 1000           ; using the value that has been set at the call
    Send, {F12 down}{F12 up}
    return
    }
    
!r::Reload		; press Alt + r to reload the script
!x::ExitApp		; ...
!e::Edit		; ...
Edited.

Press F6/F7/F8/F9 for more details.
Good luck :)
oh! sorry for taking so long to reply, I'll give it a try right now; thank you BoBo!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 333 guests