Hotstring Length - Hit enter after select amount of characters for all hotstrings? Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
arochon
Posts: 32
Joined: 04 Apr 2018, 07:49

Hotstring Length - Hit enter after select amount of characters for all hotstrings?

17 Apr 2018, 11:04

I have an old computer application that I use for work where there are 60 spaces to input characters. After that you have to hit enter to go to the next line to continue typing.

This creates a problem when using hotstrings that are lengthy. This is because when you get to 60 characters and enter is not pressed the program does not automatically go to the next line, and the rest of the characters in the hotstring are not entered.

Is there a way to format hotstrings to hit enter after a select # of character spaces?

I know you can do this

Code: Select all

::fbrkp::
(
Replaced the front brake pads and resurfaced the rotors. 
Inspected brake calipers, and all hardware and brake lines. 
Road tested the vehicle to confirm the repair.
)

::tbsp::
(
Removed the throttle body boot and scrubbed off the carbon 
build up from the throttle body.
)

::tbeltp::
(
Replaced the timing belt, adjusted tension, reset timing, 
and inspected all the associated components.
)


But is there a way to format all of your hotstrings you have in a script without doing this individually to each phrase?

To be clear:
I want to change an option or insert a line of code if possible to make the code below function as the code presented above without having to put parentheses in the code and counting characters.

Code: Select all

::fbrkp::Replaced the front brake pads and resurfaced the rotors. Inspected brake calipers, and all hardware and brake lines. Road tested the vehicle to confirm the repair.
::tbsp::Removed the throttle body boot and scrubbed off the carbon build up from the throttle body.
::tbeltp::Replaced the timing belt, adjusted tension, reset timing,and inspected all the associated components.
Thank you in advance for any help!

Cheers
arochon
Odlanir
Posts: 274
Joined: 20 Oct 2016, 08:20

Re: Hotstring Length - Hit enter after select amount of characters for all hotstrings?

17 Apr 2018, 12:10

Try this:

Code: Select all

var1 := "Replaced the front brake pads and resurfaced the rotors. Inspected brake calipers, and all hardware and brake lines. Road tested the vehicle to confirm the repair."
var2 := "Removed the throttle body boot and scrubbed off the carbon build up from the throttle body."
var3 := "Replaced the timing belt, adjusted tension, reset timing,and inspected all the associated components."

::fbrkp::
Split(var1)
return
::tbsp::
Split(var2)
return
::tbeltp::
Split(var3)
return

return

Split(string) {
	str := "", len := 0
	Arr := StrSplit(string," ")
	loop % Arr.MaxIndex() {
		if ( len + ( Strlen(Arr[a_index] " ")) <= 60) {
			str .= Arr[a_index] " "		
			len += strlen(Arr[a_index] " ")
		} else {
			str .= "`n" Arr[a_index] " "
			len := strlen(Arr[a_index] " ")		
		}
	} 
	send % substr(str,1,-1)
}
____________________________________________________________________________
Windows 7 Home Premium 64 bit - Autohotkey v1.1.24.02 64-bit Unicode
arochon
Posts: 32
Joined: 04 Apr 2018, 07:49

Re: Hotstring Length - Hit enter after select amount of characters for all hotstrings?

17 Apr 2018, 15:13

Odlanir,

Thank you for the example!

arochon
arochon
Posts: 32
Joined: 04 Apr 2018, 07:49

Re: Hotstring Length - Hit enter after select amount of characters for all hotstrings?

21 Apr 2018, 22:27

How would I be able to put a variable in for 60 without throwing an error?

For example

cpl_thirty := 30
cpl_fourty := 40
cpl_fifty := 50
cpl_sixty := 60
cpl_seventy := 70
cpl_eighty := 80
cpl_ninety := 90

It does not work when I insert %cpl_sixty% where 60 was...

Code: Select all

Split(string) {
	str := "", len := 0
	Arr := StrSplit(string," ")
	loop % Arr.MaxIndex() {
		if ( len + ( Strlen(Arr[a_index] " ")) <= %cpl_sixty%) {
			str .= Arr[a_index] " "		
			len += strlen(Arr[a_index] " ")
		} else {
			str .= "`n" Arr[a_index] " "
			len := strlen(Arr[a_index] " ")		
		}
	} 
	send % substr(str,1,-1)
}
User avatar
Exaskryz
Posts: 2873
Joined: 17 Oct 2015, 20:28

Re: Hotstring Length - Hit enter after select amount of characters for all hotstrings?

21 Apr 2018, 22:42

What happens if you just use if ( len + ( Strlen(Arr[a_index] " ")) <= cpl_sixty) { ? I haven't run the code, but notice how we didn't use %len% in there -- When you wrap the If expression in parentheses, every word put in there are treated as the names of variables instead of strings, so you don't want to use the %s.
arochon
Posts: 32
Joined: 04 Apr 2018, 07:49

Re: Hotstring Length - Hit enter after select amount of characters for all hotstrings?

21 Apr 2018, 22:54

Exaskryz,

This happens:

CUSTOMER
STATES
CHECK
ENGINE
LIGHT
ON
-
PLEASE
DIAGNOSE
AND
ADVISE

Code: Select all

cpl_sixty := 60

Split(string) {
	str := "", len := 0
	Arr := StrSplit(string," ")
	loop % Arr.MaxIndex() {
		if ( len + ( Strlen(Arr[a_index] " ")) <= cpl_sixty) {
			str .= Arr[a_index] " "		
			len += strlen(Arr[a_index] " ")
		} else {
			str .= "`n" Arr[a_index] " "
			len := strlen(Arr[a_index] " ")		
		}
	} 
	send % substr(str,1,-1)



:C:CEL1::
Split("CUSTOMER STATES CHECK ENGINE LIGHT ON - PLEASE DIAGNOSE AND ADVISE")



arochon
Posts: 32
Joined: 04 Apr 2018, 07:49

Re: Hotstring Length - Hit enter after select amount of characters for all hotstrings?  Topic is solved

21 Apr 2018, 23:28

Found this way to accomplish it

Code: Select all


if (CharLine = "20 Characters Per Line")
	mycharacterselection := cpl_twenty
else if (CharLine = "30 Characters Per Line")
	mycharacterselection := cpl_thirty
else if (CharLine = "40 Characters Per Line")
	mycharacterselection := cpl_fourty
else if (CharLine = "50 Characters Per Line")
	mycharacterselection := cpl_fifty
else if (CharLine = "60 Characters Per Line")
	mycharacterselection := cpl_sixty
else if (CharLine = "70 Characters Per Line")
	mycharacterselection := cpl_seventy
else if (CharLine = "80 Characters Per Line")
	mycharacterselection := cpl_eighty
else if (CharLine = "90 Characters Per Line")
	mycharacterselection := cpl_ninety
else if (CharLine = "100+ Characters Per Line")
	mycharacterselection := cpl_hundred
return


cpl_ten := 10
cpl_twenty := 20
cpl_thirty := 30
cpl_fourty := 40
cpl_fifty := 50
cpl_sixty := 60
cpl_seventy := 70
cpl_eighty := 80
cpl_ninety := 90
cpl_hundred := 1000



Split10(string) {
	str := "", len := 0
	Arr := StrSplit(string," ")
	loop % Arr.MaxIndex() {
		if ( len + ( Strlen(Arr[a_index] " ")) <= 10) {
			str .= Arr[a_index] " "		
			len += strlen(Arr[a_index] " ")
		} else {
			str .= "`n" Arr[a_index] " "
			len := strlen(Arr[a_index] " ")		
		}
	} 
	send % substr(str,1,-1)
}
return

Split20(string) {
	str := "", len := 0
	Arr := StrSplit(string," ")
	loop % Arr.MaxIndex() {
		if ( len + ( Strlen(Arr[a_index] " ")) <= 20) {
			str .= Arr[a_index] " "		
			len += strlen(Arr[a_index] " ")
		} else {
			str .= "`n" Arr[a_index] " "
			len := strlen(Arr[a_index] " ")		
		}
	} 
	send % substr(str,1,-1)
}
return

Split30(string) {
	str := "", len := 0
	Arr := StrSplit(string," ")
	loop % Arr.MaxIndex() {
		if ( len + ( Strlen(Arr[a_index] " ")) <= 30) {
			str .= Arr[a_index] " "		
			len += strlen(Arr[a_index] " ")
		} else {
			str .= "`n" Arr[a_index] " "
			len := strlen(Arr[a_index] " ")		
		}
	} 
	send % substr(str,1,-1)
}
return


:C:CEL1::
Split%mycharacterselection%("CUSTOMER STATES CHECK ENGINE LIGHT ON - PLEASE DIAGNOSE AND ADVISE")
swagfag
Posts: 1246
Joined: 11 Jan 2017, 17:59

Re: Hotstring Length - Hit enter after select amount of characters for all hotstrings?

22 Apr 2018, 04:16

Code: Select all

var1 := "Replaced the front brake pads and resurfaced the rotors. Inspected brake calipers, and all hardware and brake lines. Road tested the vehicle to confirm the repair."
var2 := "Removed the throttle body boot and scrubbed off the carbon build up from the throttle body."
var3 := "Replaced the timing belt, adjusted tension, reset timing,and inspected all the associated components."

::fbrkp::
Split(var1, 10)
return
::tbsp::
Split(var2, 30)
return
::tbeltp::
Split(var3, 60)
return

return

Split(string, charsPerLine) {
	str := "", len := 0
	Arr := StrSplit(string," ")
	loop % Arr.MaxIndex() {
		if ( len + ( Strlen(Arr[a_index] " ")) <= charsPerLine) {
			str .= Arr[a_index] " "		
			len += strlen(Arr[a_index] " ")
		} else {
			str .= "`n" Arr[a_index] " "
			len := strlen(Arr[a_index] " ")		
		}
	} 
	send % substr(str,1,-1)
}

Return to “Ask For Help”

Who is online

Users browsing this forum: codude, pneumatic, swagfag and 28 guests