I made you a code.. look at it.
#a hotkey calls the main script (infinite loop.. to exit, write "exit").
For debbugin purposes:
#z hotkey is just for you to test...
#q hotkey is for you to discover you real excel title..
#ins hotkey is for you to reload the script whenever you want
The routine that you have to change is
My_Routine().. there you put your {DELETE 10}{ENTER}{...}.
Change "WRITE_YOUR_EXCEL_TITLE_HERE" to your excel real title. if you dont know for sure it, go to your document and press #q.
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#MaxThreadsPerHotkey 2
#a:: ; WINDOWS KEY + A
{
Title := "WRITE_YOUR_EXCEL_TITLE_HERE"
Loop ; INFINITE LOOP, UNTILL YOU WRITE "EXIT" AND PRESS ENTER
{
scannedcharacters = ; CLEAR VARIABLE
scannedcharacters_UPPER =
inputbox, scannedcharacters, SCAN NOW, TYPE "EXIT" TO QUIT ; OPEN INPUTBOX AND CLOSES IT WHEN ENTER KEY IS SENT OR WHEN A BARCODESCANNER SENDS IT LAST CHARACTER THAT IS USUALLY AN ENTER.
StringUpper, scannedcharacters_UPPER, scannedcharacters ; verify if you want to exit script
if(scannedcharacters_UPPER == "EXIT") ; verify if you want to exit script
{
reload
}
rRafa_WinActivate := Rafa_WinActivate(Title) ; GARANTEE THAT EXCEL DOCUMENT IS GOING TO BE ACTIVATED
if (rRafa_WinActivate == "OK") ; GARANTEE THAT EXCEL DOCUMENT IS GOING TO BE ACTIVATED
{
My_Routine(scannedcharacters)
}
else ; IF NOT, STOP
{
msgbox, ERROR: Excel not detected! `n`nIF YOU DONT KNOW THE TITLE OF YOU EXCEL DOCUMENT, ACTIVATE IT AND PRESS #Q (WINDOWS KEY + Q).
reload
}
}
return
}
return
#z:: ; WINDOWS KEY + Z ; TEST
{
scannedcharacters := "abcde|fghij| klm`opqx"
My_Routine(scannedcharacters)
}
return
My_Routine(scannedcharacters)
{
sleep 500 ; time untill you release the hotkey #z
Length := StrLen(scannedcharacters)
loop, %Length%
{
if a_index <= 0
continue
char := SubStr(scannedcharacters, a_index, 1)
IfInString, char, |
{
send, (1) ; <<< PUT SOME CODE HERE
continue
}
IfInString, char, ``
{
send, (2) ; <<< PUT SOME CODE HERE
continue
}
Sendraw, %char%
}
return
}
return
#q:: ; DISCOVER YOU ACTIVE TITLE
{
wingetactivetitle, title
msgbox, The following title is now on your clipboad:`n%title%
clipboard := title
}
return
Rafa_WinActivate(Title) ; MY PERSONAL FUNCTIONS
{
while 1
{
rRafa_SetForegroundWindow := Rafa_SetForegroundWindow(Title)
if(rRafa_SetForegroundWindow == "ERROR_1") ; SCREEN DOESNT EXIST
{
return "ERROR"
}
else if(rRafa_SetForegroundWindow == "ERROR_2") ; SCREEN NOT ACTIVATED YET
{
continue
}
else if (rRafa_SetForegroundWindow == "OK") ; SCREEN ACTIVATED
{
return "OK"
}
}
}
return
Rafa_SetForegroundWindow(Title) ; MY PERSONAL FUNCTIONS
{
IfWinExist, %Title%
{
WinGet, hWnd, ID, %Title%
DllCall("SetForegroundWindow", UInt, hWnd)
CalledWindow_ID := hWnd
WinWaitActive
}
else
{
CalledWindow_ID := "ERROR"
}
WinGet, ActiveWindow_ID, ID, A
if (CalledWindow_ID == "ERROR")
return "ERROR_1" ; SCREEN DOESNT EXIST
if (ActiveWindow_ID != CalledWindow_ID)
{
return "ERROR_2" ; SCREEN NOT SUCCESSFULLY ACTIVATED
}
else
{
return "OK"
}
}
ins:: ; PRESS INSERT TO RELOAD THE SCRIPT
{
reload
}
return