Small screen keyboards with 1 button, help please

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Drogtz
Posts: 1
Joined: 21 Apr 2021, 15:14

Small screen keyboards with 1 button, help please

21 Apr 2021, 15:37

Hello I want a small Gui, with a button. And when i press the button i want it to press E and hold it down for like 50-70ms random sleep.


Here is my script. But the random sleep doesn't work, can someone please help me :D

Code: Select all

Gui, 1: +LastFound +AlwaysOnTop +ToolWindow +Caption +Border +E0x08000000
Gui, 1: font, S22, Verdana
Gui, 1: Add, Button, x10 y10 w65 h55 gSendE , e

Gui, 1: Show,x20 y464 NoActivate ,GUI Keyboard

SendE: 
StringLower, Letter, A_GuiControl
Send % (Letter="&&") ? "&" : "{" Letter "}"
Return

pressSpace:
SendInput {e down}
RandSleep(30,50)
SendInput {e up}
return

RandSleep(x,y) {
Random, rand, %x%, %y%
Sleep %rand%
}
[Mod edit: [code][/code] tags added.]
User avatar
boiler
Posts: 16925
Joined: 21 Dec 2014, 02:44

Re: Small screen keyboards with 1 button, help please

21 Apr 2021, 17:29

Drogtz wrote:
21 Apr 2021, 15:37
But the random sleep doesn't work
What makes you think that? Run the following script as a demonstration:

Code: Select all

DllCall("QueryPerformanceFrequency", "Int64*", freq)
DllCall("QueryPerformanceCounter", "Int64*", CounterBefore)
RandSleep(30,50)
DllCall("QueryPerformanceCounter", "Int64*", CounterAfter)
MsgBox % Round((CounterAfter - CounterBefore) / freq * 1000, 1) " ms"
return

RandSleep(x,y) {
Random, rand, %x%, %y%
Sleep %rand%
}

It's weird that sometimes it comes in under 30 ms when I run it, but Sleep isn't super accurate. The docs make it sound like it could be longer but not shorter, though. Anyway, it's within your desired range most of the time. You might want to bump up the bottom end if that's a problem.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Lamron750 and 247 guests