 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Sergio
Joined: 16 Mar 2008 Posts: 25 Location: Brooklyn
|
Posted: Sun Mar 30, 2008 6:33 am Post subject: Calling one hotkey from another |
|
|
I created a script where one hotkey calls the other. The one problem is that in AHK Hotkey #2 does not wait for #1 to finish. Instead they work in Tandem. Is there a code that will tell hotkey #2 not to proceed until the called function has completed its function?
| Code: | ^1::
Msgbox, The code does something
Sleep, 10000 ; waits ten seconds
Msgbox, Does something again
return
^2::
Msgbox, The code does something else
Send, ^1 ; calls the first one
; HERE IS MY PROBLEM. Hotkey ^2 does not wait for ^1 to be finished before it continues. From here on out they work in Tandem. This is conflicting on this particular project because they require the copy/paste features.
Msgbox, Does something else again |
_________________
 |
|
| Back to top |
|
 |
interiot
Joined: 06 Nov 2005 Posts: 64
|
Posted: Sun Mar 30, 2008 6:45 am Post subject: |
|
|
Use that instead of "Send, ^1". |
|
| Back to top |
|
 |
Sergio
Joined: 16 Mar 2008 Posts: 25 Location: Brooklyn
|
Posted: Sun Mar 30, 2008 7:09 am Post subject: |
|
|
Gosub seems to be just what I needed - at least according to the description. But when I substituted Send with Gosub it inserted the text as a literal string.
I don't know if this helps but the nature of the code is to manipulate text that is copied to the clipboard. So ^1 copies text and it calls ^2 to trim from the left and right.
If it helps, here is the actual code.
| Code: | ; ------------- COPIES DATA FROM EXCEL ARCHIVES AND CREATES AN E-MAIL
; ------------- TO REMIND CUSTOMERS TO MAKE PAYMENT
^F1::
Send, {CTRLDOWN}{LEFT 3}{CTRLUP}
Sleep, 10
Send, {CTRLDOWN}c{CTRLUP}{TAB}
Sleep, 10
varUserId:=Clipboard
ClipWait, 2
Send, {CTRLDOWN}c{CTRLUP}{TAB}
Sleep, 10
StringReplace, clipboard, clipboard, `r`n, , All
varItemNumber:=Clipboard
ClipWait, 2
Send, {CTRLDOWN}c{CTRLUP}
StringReplace, clipboard, clipboard, `r`n, , All
Sleep, 10
varTitle:=Clipboard
ClipWait, 2
sleep, 10
Send, {TAB 6}
Send, ^c
Clipwait, 2
varDate:=Clipboard
[b]Send, ^0
Sleep, 200 ; IF I USE THE SEND COMMAND, I ALSO NEED TO USE THE SLEEP COMMAND AND ESTIMATE THE AMOUNT OF TIME IT WILL TAKE.[/b]
Send, {TAB 3}
Send, {CTRLDOWN}c{CTRLUP}
Sleep, 10
varEmail:=Clipboard
ClipWait, 2
return
; ------------- COPIES A DATE (FORMAT 01.23.45) DELETES SIX CHARACTERS FROM THE RIGHT, CONVERTS THE FIRST TWO CHARACTERS INTO A MONTH, PASTES THAT MONTH
^0::
varDayTemp:=varDate
varMonthTemp:=varDate
varYearTemp:=varDate
; 001 ------------------ TRIMS SIX CHARACTERS FROM THE RIGHT
Stringtrimright,varMonth,varMonthTemp,8
Sleep, 50
Clipboard:=varMonth
Sleep, 50
; ------------------ CONVERTS THE PRODUCT CODE TO A BRIEF DESCRIPTION
varMonthWhole= ; your array
(
01|January
02|February
03|March
04|April
05|May
06|June
07|July
08|August
09|September
10|October
11|November
12|December
)
FileOneText:=varMonth ; variable from file one as an example
Loop, Parse, varMonthWhole , `r`n
{
StringSplit, c, A_LoopField,|
If (FileOneText = c1)
FileOneText:=c2
}
varMonth:=FileOneText
; 002 ------------------ TRIMS THREE CHARACTERS FROM EACH SIDE LEAVING ONLY THE DATE
Stringtrimleft,varDay2,varDayTemp,3
Stringtrimright,varDay,varDay2,5
; 003 ------------------ TRIMS SIX CHARACTERS FROM THE LEFT
Stringtrimleft,varYear,varYearTemp,6
return
|
_________________
 |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|