Contextual - Text Expansion

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
rokkyboy
Posts: 16
Joined: 01 Sep 2017, 07:04

Contextual - Text Expansion

12 Jan 2020, 23:25

Happy new year everyone.

I wasn't sure how to properly title this one so let me know if you have a better one:

I would like to type a text consisting of different nomenclature and later make it expand.

Below would be how the text is built:

-
Company A/B/C

-
Area 001/002/003

-
A - Architecture
S - Structure
C - Civil

-
WP - Short for Workpack, 50 workpack each.

---

A001AWP001 = Company A, Working in Area 001, Architecture, and workpack 001.

When "A001AWP001" is typed, how can I make it type: "D:\Company A\Area001\Architecture\Workpack 001"?

The idea behind this script is to make it easier to navigate folder higherarchy on a project.

I think the logic would be something like:


1. Create an Array with key/value pair for each nomenclature group (A = Company A, B = Company B, etc)
2. when assigned key is pressed:
2.1 Window Pops Up
2.2 Computer starts to listen to what is being typed and save into a string variable
3. Break down the string input (Company = first char, Area = position 1 ~ 4, etc)
4. Build another string that concatenates with "\" in the middle
5. Make the final input


Any advice would be welcome!

Also, I'm not sure if we can use hotstring for such use?

Thanks :)
Rohwedder
Posts: 7672
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Contextual - Text Expansion

13 Jan 2020, 04:06

Hallo,
somethink like this?

Code: Select all

ASC := {A:"Architecture",S:"Structure",C:"Civil"}
q::
InputBox, Text,Nomenclature,,,,100,,,,,A001AWP001
Company := SubStr(Text,1,1)
Area := SubStr(Text,2,3)
ASCn := SubStr(Text,5,1)
Wpn := SubStr(Text,8)
Path := "D:\Company " Company "\Area" Area "\" ASC[ASCn] "\Workpack " Wpn
MsgBox,% Path
Return
rokkyboy
Posts: 16
Joined: 01 Sep 2017, 07:04

Re: Contextual - Text Expansion

13 Jan 2020, 07:48

Hello,

Thank you for the help!
This looks perfect to get me started.

Can you also help why it wouldn't work when I change the Key/Value pair from one digit to two digits?

For example:

ASC := {AR:"Architecture",ST:"Structure",CI:"Civil"}

I obviously changed the position of the string as well:

ASCn := SubStr(Text,5,2)

I couldn't get this to call the value.

Thanks!
Rohwedder
Posts: 7672
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Contextual - Text Expansion

13 Jan 2020, 08:49

Try:

Code: Select all

ASC := {AR:"Architecture",ST:"Structure",CI:"Civil"}
q:: ;changed A001AWP001 to A001ARWP001
InputBox, Text,Nomenclature,,,,100,,,,,A001ARWP001
Company := SubStr(Text,1,1)
Area := SubStr(Text,2,3)
ASCn := SubStr(Text,5,2)
Wpn := SubStr(Text,9)
Path := "D:\Company " Company "\Area" Area "\" ASC[ASCn] "\Workpack " Wpn
MsgBox,% Path
Return
rokkyboy
Posts: 16
Joined: 01 Sep 2017, 07:04

Re: Contextual - Text Expansion

13 Jan 2020, 09:11

Yep, tried... but still getting:

Cap 2020-01-13 23-11-32-216.png
Cap 2020-01-13 23-11-32-216.png (2.93 KiB) Viewed 1168 times
Rohwedder
Posts: 7672
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Contextual - Text Expansion

13 Jan 2020, 10:23

Strange!
Try:

Code: Select all

MsgBox,% A_IsUnicode ? "Unicode" : "ANSI"
It should be Unicode.
guest3456
Posts: 3463
Joined: 09 Oct 2013, 10:31

Re: Contextual - Text Expansion

13 Jan 2020, 10:30

rokkyboy wrote:
13 Jan 2020, 09:11
Yep, tried... but still getting:


Cap 2020-01-13 23-11-32-216.png
but the one char version works fine?

rokkyboy
Posts: 16
Joined: 01 Sep 2017, 07:04

Re: Contextual - Text Expansion

13 Jan 2020, 10:48

Yep Weird... any ideas?
guest3456
Posts: 3463
Joined: 09 Oct 2013, 10:31

Re: Contextual - Text Expansion

13 Jan 2020, 11:07

rokkyboy wrote:
13 Jan 2020, 10:48
Yep Weird... any ideas?
what does the unicode msgbox say? and what encoding are you saving the script file in?

rokkyboy
Posts: 16
Joined: 01 Sep 2017, 07:04

Re: Contextual - Text Expansion

14 Jan 2020, 06:16

guest3456 wrote:
13 Jan 2020, 11:07
rokkyboy wrote:
13 Jan 2020, 10:48
Yep Weird... any ideas?
what does the unicode msgbox say? and what encoding are you saving the script file in?
The unicode msgbox says "unicode" and I'm not sure how to check the encoding of the script file. How do I go about doing that?
guest3456
Posts: 3463
Joined: 09 Oct 2013, 10:31

Re: Contextual - Text Expansion

14 Jan 2020, 09:39

rokkyboy wrote:
14 Jan 2020, 06:16
The unicode msgbox says "unicode" and I'm not sure how to check the encoding of the script file. How do I go about doing that?
easiest way would be to right click the script, choose Open With -> Notepad, then inside Notepad, use the menu item View->Status Bar, to make sure the status bar at the bottom is showing, and then look for the file encoding at the bottom. ideally you want UTF8 with BOM, or UTF16


Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], kshitij90 and 336 guests