AutoHotkey Community

It is currently May 27th, 2012, 3:50 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: August 8th, 2010, 9:11 pm 
Offline

Joined: November 24th, 2009, 6:20 am
Posts: 10
Hi, I'm trying to figure out a function that enables me to do on demand mapping.

My algorithm/logic (in layman's language is as follows):

1. Press F7 (to initiate on demand mapping)
2. Wait for user to push 4 letters in sequence.
3. Push 4 letters in sequence; store each letter as variables v1 to v4

4. Somewhere in the AHK file do mappings for:
A:v1
B:v2
C:v3
D:v4

So A will map to the first key, B to the second etc.

Maybe additionally, push F8 to remap v1 to v4 back to A, B, C, D (ie their original function).

All help would be appreciated.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 8th, 2010, 10:04 pm 
Offline

Joined: November 28th, 2009, 4:45 am
Posts: 3089
What you are asking for is not very dificult but most people here won't just give you scripts unless you show some effort. Read about Hotkey command, Hotkeys, Input, and the Tutorial.
Try some things and if you can't get it to work post the nonworking code to show you tried.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 9th, 2010, 9:18 am 
Offline

Joined: November 24th, 2009, 6:20 am
Posts: 10
Thanks None, I'm not a programmer so I'm a little slow picking up on these things; but with the clues you've provided, I've came up with this:

Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Defining Variables (for initial loading)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
v1 = q
v2 = w
v3 = r
v4 = v

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;On Demand Loading using F7
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Hotkey, F7, SetupAbilities
return

SetupAbilities:
Input , v1 , L1 I
Input , v2 , L1 I
Input , v3 , L1 I
Input , v4 , L1 I
Keywait , %v4%

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Mapping QWRV to v1 to v4
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

q::  ;Maps q to variable v1.  Modifiers plus "q" work as per normal.
   SendInput, {%v1%}
return

w::  ;Maps q to variable v2.  Modifiers plus "w" work as per normal.
   SendInput, {%v2%}
return

r::  ;Maps q to variable v1.  Modifiers plus "r" work as per normal.
   SendInput, {%v3%}
return

v::  ;Maps q to variable v1.  Modifiers plus "v" work as per normal.
   SendInput, {%v4%}
return


The F7 thing seems to work, but for some reason, the initial loading of variables don't; I keep getting errors.

The way I wish it to work is for the keys qwrv to map to qwrv (ie no change) as default, until I need to change them on demand, in which case I press F7 and 4 letters, to remap them.

None wrote:
What you are asking for is not very dificult but most people here won't just give you scripts unless you show some effort. Read about Hotkey command, Hotkeys, Input, and the Tutorial.
Try some things and if you can't get it to work post the nonworking code to show you tried.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 10th, 2010, 1:08 am 
Offline

Joined: November 28th, 2009, 4:45 am
Posts: 3089
This is what I would do
Code:
v1:="a",v2:="b",v3:="c",v4:="d" ;preset sends

F7:: ;to change what is sent
Input , v1 , L1 I
Input , v2 , L1 I
Input , v3 , L1 I
Input , v4 , L1 I
SoundBeep ;to indicate done
Return

F8:: ;to turn hotkeys on and off
Hotkey, q, Toggle
Hotkey, w, Toggle
Hotkey, r, Toggle
Hotkey, v, Toggle
Return

q::SendInput, {%v1%}
w::SendInput, {%v2%}
r::SendInput, {%v3%}
v::SendInput, {%v4%}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 10th, 2010, 5:34 am 
Offline

Joined: November 24th, 2009, 6:20 am
Posts: 10
Thanks None, I'll try your version out.

The key difference I see is that the initial presetting of variables is done using := instead of = and the use of quotes. What's the difference in this?

v1:="a"

and

v1 = a

This could explain why mine didn't work at the start.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 10th, 2010, 5:39 am 
Offline

Joined: April 8th, 2009, 8:23 pm
Posts: 3036
Location: Rio de Janeiro - RJ - Brasil
Code:
$q::SendInput, {%v1%}
$w::SendInput, {%v2%}
$r::SendInput, {%v3%}
$v::SendInput, {%v4%}

You probably need the $ modifier there.
Read: Table of Hotkey Prefix Symbols (Modifiers)

The assignment syntax should not be the problem.
Read: Syntax for Assignment and Comparison in AutoHotkey

_________________
"Read the manual. Read it again. Search the forum.
Try something before asking. Show what you've tried.
"
Image
Antonio França
My stuff: Google Profile


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot] and 22 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group