Hotkey requires two presses to display correct information

Get help with using AutoHotkey and its commands and hotkeys
Posts: 1
Joined: 28 Jul 2018, 04:57

Hotkey requires two presses to display correct information

13 Aug 2018, 03:16

This script I have made works. However, I have to press the hotkey twice before the information in the variable is displayed correctly via the tooltip. I would like to know how to fix this and what the cause is for having to push the hotkey twice. I have gone into detail in a commented block below.

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

#SingleInstance, Force																;run only one instance of the script
#Persistent																		;runs the script until closed by user

myfile := "a"																		;file variable

toolTipTime := 2																	;time in seconds to refresh tooltip info

toolTipTime := toolTipTime * 1000													        ;conversion from milliseconds to seconds

SetTimer, toolTipUpdate, % toolTipTime  											                ;This makes the subroutine "toolTipUpdate" automatically run every Xms
return																			;end of the auto-execution section

expected behavior:
1. pressed ONCE
2. cut text
3. store cut text into variable sectionName

actual behavior:
1. pressed TWICE (minimum) before variable reflects changes correctly

working example:
playing a game in full screen. instead of alt+tabbing to the desktop, editing the values in the script, saving and reloading, alt+tabbing back to the game and waiting for it to render,
you can type the section of the ini you want and have the information correctly displayed via a tooltip

1st part of the example:
1. in the game and full screened
2. alt+tab out of the game to the desktop
3. navigate to the script location
4. edit the script values
5. save and reload the script
6. alt+tab back into the game
7. wait for the game to render

2nd part of the example:
1. type corresponding section of the ini file. for instance, since we are in 'a.ini', type: aa
2. highlight the text
3. use keyboard shortcut to cut the text. this puts it into the clipboard which then gets stored into a variable we use to read and write to the ini
4. read the correct and updated information via a tooltip

1a. type: ab
1b. type: ac
whichever section is typed and cut should be reflected in the tooltip, no matter which file is selected at the beginning of the script

Send, ^{x}																			;sends control+x
sectionName := Clipboard															        ;sets contents of clipboard as variable

Esc::ExitApp																		;exits the app

[::goto, minusone																	;go to subroutine
]::goto, addhalf																	        ;go to subroutine

minusone:																			;start of the subroutine
myLives--																			;subtracts 1 from variable
IniWrite, % myLives, C:\Users\User\Desktop\%myfile%.ini, % sectionName, 1			                                ;writes/updates ini file with new variable info

addhalf:																			;start of the subroutine
myLives := myLives + 0.5															        ;adds 0.5 to variable 
IniWrite, % myLives, C:\Users\User\Desktop\%myfile%.ini, % sectionName, 1			                                ;writes/updates ini file with new variable info

toolTipUpdate: 																		;start of the subroutine 
IniRead, myLives, C:\Users\User\Desktop\%myfile%.ini, % sectionName, 1				                        ;read ini file contents
ToolTip, % myLives, 0, 0 															        ;updates tooltip with current variable info

the ini files are basically set up like this:












Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], NoUser, Rohwedder, TAC109 and 194 guests