Remapping a key based upon choice from dropdownlist

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
skeerrt
Posts: 1
Joined: 29 Mar 2024, 04:37

Remapping a key based upon choice from dropdownlist

29 Mar 2024, 04:43

Sorry for being so new, I've been googling but I may not be using the correct terminology

I have a script built that works for me, but if a friend wants to use it they have to change their keybinds to match mine. To overcome this, I made a gui dropdown list with selections of F-keys.

How do I tell my script to remap the right mouse button to the drop down selection? Currently it's just hard coded to F2 until I can figure out a way to change it.

Here is what I have -

Code: Select all

; Generated by Auto-GUI 3.0.1
#SingleInstance Force
#NoEnv
SetWorkingDir %A_ScriptDir%
SetBatchLines -1

Gui Font, s9, Segoe UI
Gui Add, Tab3, Settings
Gui Tab, 1
Gui Font
Gui Font, cGreen
Gui Add, Button, vStart gstart x216 y40 w155 h40, START
Gui Font
Gui Font, s9, Segoe UI
Gui Font
Gui Font, cRed
Gui Add, Button, vStop gstop x216 y88 w155 h40, STOP
Gui Font
Gui Font, s9, Segoe UI
Gui Add, Text, x24 y32 w120 h23 +0x200 +0x400000, Inventory hotkey:
Gui Add, Button, vChange gkeys x24 y96 w122 h23, SUBMIT
Gui Add, DropDownList, gkeys x24 y64 w120, F1|F2||F3|F4|F5|F6|F7|F8|F9|F10|F11|F12
Gui Font
Gui Font, s20
Gui Add, Button, vQuit gover x16 y136 w391 h51, QUIT
Gui Font
Gui Font, s9, Segoe UI
Gui Tab

Gui Show, w419 h210, Remapper
Return

start:
	GuiControl, Enable, Stop
	GuiControl, Disable, Start
	stopped := 0
	{
		#IfWinActive ahk_class client
		RButton::F2
		process_watcher:
		Process Exist, client.exe ; check to see if PoE is still open
		If ErrorLevel = 0
		Exitapp ; if it's closed, exit the .ahk file
		if stopped
			return
	}

stop:
Return

keys:
Return

over:
Return

GuiEscape:
GuiClose:
    ExitApp


stop:
	GuiControl, Enable, Start
	GuiControl, Disable, Stop
	stopped := 1
return

Keys:
if Choice
	Hotkey, % Choice, Off
Gui, Submit, NoHide
Hotkey,% Choice, Choice
ToolTip, now use the chosen inventory hotkey!
SetTimer, ToolTipOff, -4000
return

ToolTipOff:
	ToolTip
return

[Mod edit: Changed inline code tags (c) to [code][/code] tags. Please use them yourself when posting code.]
User avatar
mikeyww
Posts: 26972
Joined: 09 Sep 2014, 18:38

Re: Remapping a key based upon choice from dropdownlist

29 Mar 2024, 06:15

Welcome to this AutoHotkey forum!

I ran the script that you posted. It generates an error message. Do you see it?

Code: Select all

#Requires AutoHotkey v1.1.33.11
winTitle := "ahk_exe notepad.exe" ; Change as needed
winTitle := "ahk_exe emeditor.exe" ; Change as needed
Gui +AlwaysOnTop
Gui Font, s10
Gui Add, DDL     , gSet vsel     w230 Choose1, 3|4|5
Gui Add, Checkbox, gSet vactive, Active
Gosub F3

F3::Gui Show, NoActivate, RButton

Set:
Gui Submit
Sleep 50
Gosub F3
Hotkey IfWinActive, % winTitle
If active {
 Hotkey *RButton   , RBdown, On
 Hotkey *RButton Up, RBup  , On
 SoundBeep 1500
} Else {
 Hotkey *RButton   , Off
 Hotkey *RButton Up, Off
 SoundBeep 1000
}
HotKey IfWinActive
Return

RBdown:
SetKeyDelay -1
Send % "{Blind}{" sel " DownR}"
Return

RBup:
SetKeyDelay -1
Send % "{Blind}{" sel " up}"
Return
If you are new to AHK, I recommend using its current version, which is v2, instead of this older deprecated version that is no longer developed.

Return to “Ask for Help (v1)”

Who is online

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