chage value of a variable with a hot key Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ananthuthilakan
Posts: 188
Joined: 08 Jul 2019, 05:37
Contact:

chage value of a variable with a hot key

08 Jul 2019, 05:59

I have a something like this

Code: Select all

DllCall("mouse_event", "UInt", 0x01, "UInt", 5*Multiplier, "UInt", 56*Multiplier)
sleep 100
if !GetKeyState(MButton)


what I m trying is that

the value of Multiplier by default should be equal to 1
when i press shift+alt+2 the value should change to 2
when i press shift+alt+3 the value should change to 3
when i press shift+alt+4 the value should change to 4
etc

and when using another hotkey say f1 it should restore to 1 again

i am noob to ahk
any help would be appreciated
Odlanir
Posts: 659
Joined: 20 Oct 2016, 08:20

Re: chage value of a variable with a hot key

08 Jul 2019, 07:26

Code: Select all

multiplier := 1
f1::
+!2::
+!3::
+!4::
multiplier := substr(A_ThisHotkey,-0)
gosub DoTheWork
return

DoTheWork:
	MsgBox % 5*Multiplier "`n"  56*Multiplier
return
Esc::
  ExitApp
____________________________________________________________________________
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode
ananthuthilakan
Posts: 188
Joined: 08 Jul 2019, 05:37
Contact:

Re: chage value of a variable with a hot key

09 Jul 2019, 21:30

Odlanir wrote:
08 Jul 2019, 07:26

Code: Select all

multiplier := 1
f1::
+!2::
+!3::
+!4::
multiplier := substr(A_ThisHotkey,-0)
gosub DoTheWork
return

DoTheWork:
	MsgBox % 5*Multiplier "`n"  56*Multiplier
return
Esc::
  ExitApp
THIS IS PERFECT !! THANK YOU
WHAT TO DO IF I WANT TO ASSIGN A KEY FOR EXAMPLE SAY "C"
TO MAKE MULTIPLIER A RANDOM VALUE SAY 0.832
Odlanir
Posts: 659
Joined: 20 Oct 2016, 08:20

Re: chage value of a variable with a hot key  Topic is solved

10 Jul 2019, 01:06

Code: Select all

multiplier := 1
c::
f1::
+!2::
+!3::
+!4::
if (A_ThisHotkey = "c") {
   random, Multiplier, 0.0, 1.0 ; random floating number between 0 an 1
} else {
   multiplier := substr(A_ThisHotkey,-0)
}
gosub DoTheWork
return

DoTheWork:
	MsgBox % 5*Multiplier "`n"  56*Multiplier
return
Esc::
  ExitApp
____________________________________________________________________________
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 142 guests