Hotkey for stopwatch

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Kilroy
Posts: 5
Joined: 20 Dec 2020, 03:26

Hotkey for stopwatch

Post by Kilroy » 26 Jan 2022, 15:47

Hello, I need help with my simple script which just hits space or enter to start or stop the windows stopwatch app. I don't understand why it isn't working, and I've tried a few different things. I'm not an expert in AHK at all. Here's a couple attempts:

Code: Select all

^a::
{
ControlSend,, {space}, Alarms & Clock
}
return
This one above doesn't do anything. I also tried a few things like putting in the ahk_id hwnd thing in place of WinTitle, or putting in the ClassNN after the first comma.

Code: Select all

^a::
{
ControlClick, X905 Y680, Alarms & Clock
}
return
[Mod edit: [code][/code] tags added.]

And this one I only made to see if I had the right WinTitle. It looks like I did, since it does seem to click on that window even if I am focused on a different window. But the weird thing is that it doesn't start the timer. I changed it to hit the right button temporarily to see if it was in the right position, and it was (right click menu popped up on the position of the play button). If I double tap the hotkey, it resizes the window smaller, exactly like double clicking any title bar, even though it wasn't clicking on the title bar. The reverse doesn't happen (it doesn't go to "fullscreen" from a small window). I'm confused, and don't really know what to try next.

After I got that done, I would've also wanted sound, ideally a different sound for stop and start, but I didn't search anything up to see if that kind of thing was possible with AHK yet.

amateur+
Posts: 655
Joined: 09 Oct 2021, 15:43

Re: Hotkey for stopwatch

Post by amateur+ » 26 Jan 2022, 17:08

Try something of the following:

Code: Select all

^a::ControlSend, ahk_parent, {space}, Alarms & Clock

Code: Select all

^a::ControlClick, X905 Y680, Alarms & Clock,,,, NA

Code: Select all

^a::
ControlClick, X905 Y680, Alarms & Clock,,,, NA
send, {space}
return
Also be sure that 905x680 are relative coordinates to the upper left corner of the window, not of the whole screen.
Have found any drawback in my code or approach? Please, point it out. /The moderator ordered to remove the rest of the signature, I had obeyed.
And I really apologize for our russian president. Being a citizen of an aggressor country is very shameful. Personally I tried to avoid this trying to defend elections from fraud being a member of the election commission of one of the precincts but only was subjected to a hooligan attack and right before the vote count was illegally escorted from the polling station and spent the night behind bars (in jail) in a result of illegal actions of corrupt policemen.

Kilroy
Posts: 5
Joined: 20 Dec 2020, 03:26

Re: Hotkey for stopwatch

Post by Kilroy » 26 Jan 2022, 17:18

None of these seem to work. The first doesn't do anything, and the next two have the same issues. I'm pretty sure I have the right coordinates, too.

amateur+
Posts: 655
Joined: 09 Oct 2021, 15:43

Re: Hotkey for stopwatch

Post by amateur+ » 26 Jan 2022, 17:24

And this?

Code: Select all

^a::
ControlClick, X905 Y680, Alarms & Clock
send, {space}
return

Code: Select all

^a::
WinActivate, Alarms & Clock
WinWaitActive, Alarms & Clock
Sleep 100
send, {Space}
return
Have found any drawback in my code or approach? Please, point it out. /The moderator ordered to remove the rest of the signature, I had obeyed.
And I really apologize for our russian president. Being a citizen of an aggressor country is very shameful. Personally I tried to avoid this trying to defend elections from fraud being a member of the election commission of one of the precincts but only was subjected to a hooligan attack and right before the vote count was illegally escorted from the polling station and spent the night behind bars (in jail) in a result of illegal actions of corrupt policemen.

Kilroy
Posts: 5
Joined: 20 Dec 2020, 03:26

Re: Hotkey for stopwatch

Post by Kilroy » 26 Jan 2022, 23:07

Thanks for the help, the second one works.

amateur+
Posts: 655
Joined: 09 Oct 2021, 15:43

Re: Hotkey for stopwatch

Post by amateur+ » 27 Jan 2022, 00:29

OK. Then you can try to decrease sleep amount and add checking on existence:
#If WinExist("Alarms & Clock")
^a::
...
...
#if
Have found any drawback in my code or approach? Please, point it out. /The moderator ordered to remove the rest of the signature, I had obeyed.
And I really apologize for our russian president. Being a citizen of an aggressor country is very shameful. Personally I tried to avoid this trying to defend elections from fraud being a member of the election commission of one of the precincts but only was subjected to a hooligan attack and right before the vote count was illegally escorted from the polling station and spent the night behind bars (in jail) in a result of illegal actions of corrupt policemen.

Post Reply

Return to “Ask for Help (v1)”