Untitled
unknown
plain_text
a year ago
35 kB
10
Indexable
#Requires AutoHotkey v2.0
#SingleInstance Force
; Global variables - declare at the top
global Field1Content := “”
global Field2Content := “”
global Field3Content := “”
global AvailableQty := “”
^o:: {
ShowIntroVan()
ShowGui()
}
; Modern Message Box Function
ShowModernMessage(title, message, type := “info”, buttons := “OK”) {
; Create modern styled message box
msgGui := Gui(”+AlwaysOnTop +Owner” . WinGetID(A_ScriptHwnd) . “ -MaximizeBox -MinimizeBox”, title)
msgGui.BackColor := 0x2D2D30
msgGui.MarginX := 20
msgGui.MarginY := 20
msgGui.SetFont(“s10”, “Segoe UI Variable”)
```
; Icon based on type
iconText := ""
iconColor := 0xFFFFFF
switch type {
case "error":
iconText := "❌"
iconColor := 0xFF4444
case "warning":
iconText := "⚠️"
iconColor := 0xFFAA00
case "success":
iconText := "✅"
iconColor := 0x00FF88
case "question":
iconText := "❓"
iconColor := 0x00A6FF
default:
iconText := "ℹ️"
iconColor := 0x00A6FF
}
; Add icon
iconCtrl := msgGui.AddText("x20 y20 w40 h40 Center", iconText)
iconCtrl.SetFont("s24")
iconCtrl.BackColor := 0x2D2D30
iconCtrl.TextColor := iconColor
; Add message text
msgCtrl := msgGui.AddText("x70 y20 w300 h80 +Wrap", message)
msgCtrl.BackColor := 0x2D2D30
msgCtrl.TextColor := 0xFFFFFF
msgCtrl.SetFont("s10", "Segoe UI Variable")
; Calculate proper height based on text
textHeight := 40
if (StrLen(message) > 50) {
textHeight := 80
}
if (StrLen(message) > 100) {
textHeight := 120
}
; Position buttons
buttonY := 30 + textHeight
result := ""
if (buttons = "YesNo") {
; Yes/No buttons
btnYes := msgGui.AddButton("x120 y" . buttonY . " w80 h35", "Yes")
btnYes.SetFont("s10 Bold", "Segoe UI Variable")
btnYes.BackColor := 0x0078D4
btnYes.TextColor := 0xFFFFFF
btnYes.OnEvent("Click", (*) => (result := "Yes", msgGui.Close()))
btnNo := msgGui.AddButton("x210 y" . buttonY . " w80 h35", "No")
btnNo.SetFont("s10 Bold", "Segoe UI Variable")
btnNo.BackColor := 0x666666
btnNo.TextColor := 0xFFFFFF
btnNo.OnEvent("Click", (*) => (result := "No", msgGui.Close()))
btnYes.Focus()
} else {
; OK button
btnOK := msgGui.AddButton("x165 y" . buttonY . " w80 h35", "OK")
btnOK.SetFont("s10 Bold", "Segoe UI Variable")
btnOK.BackColor := 0x0078D4
btnOK.TextColor := 0xFFFFFF
btnOK.OnEvent("Click", (*) => (result := "OK", msgGui.Close()))
btnOK.Focus()
}
; Show the dialog
msgGui.Show("w400 h" . (buttonY + 55))
; Wait for user response with timeout protection
timeoutCounter := 0
while (result = "" && timeoutCounter < 600) { ; 30 second timeout
Sleep(50)
timeoutCounter++
}
if (timeoutCounter >= 600) {
result := "OK" ; Default response on timeout
}
try {
msgGui.Destroy()
} catch {
; Ignore if already destroyed
}
return result
```
}
; Modern Status Notification
ShowModernNotification(message, duration := 2500, type := “info”) {
; Create notification window
notifyGui := Gui(”+AlwaysOnTop +ToolWindow -Caption”, “Notification”)
notifyGui.BackColor := 0x2D2D30
notifyGui.MarginX := 15
notifyGui.MarginY := 10
```
; Icon and color based on type
iconText := ""
iconColor := 0xFFFFFF
switch type {
case "error":
iconText := "❌"
iconColor := 0xFF4444
case "warning":
iconText := "⚠️"
iconColor := 0xFFAA00
case "success":
iconText := "✅"
iconColor := 0x00FF88
default:
iconText := "ℹ️"
iconColor := 0x00A6FF
}
; Add icon
iconCtrl := notifyGui.AddText("x15 y10 w30 h30 Center", iconText)
iconCtrl.SetFont("s16")
iconCtrl.BackColor := 0x2D2D30
iconCtrl.TextColor := iconColor
; Add message
msgCtrl := notifyGui.AddText("x50 y15 w250 h20", message)
msgCtrl.BackColor := 0x2D2D30
msgCtrl.TextColor := 0xFFFFFF
msgCtrl.SetFont("s9", "Segoe UI Variable")
; Show notification in top-right corner
notifyGui.Show("w320 h40 x" . (A_ScreenWidth - 340) . " y20")
; Auto-close after duration with proper cleanup
closeTimer := () => {
try {
if (IsObject(notifyGui) && notifyGui.Hwnd) {
notifyGui.Destroy()
}
} catch {
; Ignore if already destroyed
}
}
SetTimer(closeTimer, -duration)
```
}
ShowIntroVan() {
introGui := Gui(”+AlwaysOnTop -Caption +ToolWindow”, “Moving Van”)
introGui.BackColor := 0x2D2D30
introGui.SetFont(“s36”, “Segoe UI Emoji”)
```
; Create modern styled intro
titleText := introGui.AddText("x50 y20 w300 h40 Center", "A-TEAM Order System")
titleText.SetFont("s14 Bold", "Segoe UI Variable")
titleText.BackColor := 0x2D2D30
titleText.TextColor := 0xFFFFFF
; Create the van icon initially off-screen to the left
vanIcon := introGui.AddText("x-80 y60 w80 h80 Center vVanIcon", "🚐")
vanIcon.BackColor := 0x2D2D30
introGui.Show("w400 h150")
; Animate van: move from left to right
Loop 31 {
xPos := -80 + (A_Index * 12)
introGui["VanIcon"].Move(xPos, 60)
Sleep 40
}
Sleep 500 ; pause for a moment at the end
introGui.Destroy()
```
}
ShowGui() {
global myGui
if !IsSet(myGui) {
myGui := Gui(” +Resize -MaximizeBox”, “A-TEAM | Order System”)
myGui.BackColor := 0xF5F5F5
myGui.MarginX := 0
myGui.MarginY := 0
}
myGui.Show(“w380 h405”)
}
myGui := Gui(” +Resize -MaximizeBox”, “A-TEAM | Order System”)
myGui.BackColor := 0xF5F5F5
myGui.MarginX := 0
myGui.MarginY := 0
; Modern font setup
myGui.SetFont(“s10”, “Segoe UI Variable”)
; —– Header with gradient effect —–
headerBg := myGui.AddText(“x0 y0 w400 h70 +Background”, “”)
headerBg.BackColor := 0x2D2D30
headerIcon := myGui.AddText(“x30 y20 w40 h40 +Center”, “🚐”)
headerIcon.SetFont(“s24”)
headerIcon.BackColor := 0x2D2D30
headerIcon.TextColor := 0x00A6FF
headerTitle := myGui.AddText(“x80 y20 w300 h25”, “A-TEAM | Order System”)
headerTitle.SetFont(“s16 Bold”, “Segoe UI Variable”)
headerTitle.BackColor := 0x2D2D30
headerTitle.TextColor := 0xFFFFFF
global headerSubtitle := myGui.AddText(“x80 y45 w300 h20”, “Warrior Close”)
headerSubtitle.SetFont(“s9”, “Segoe UI Variable”)
headerSubtitle.BackColor := 0x2D2D30
headerSubtitle.TextColor := 0xCCCCCC
; —– Main Content Area —–
contentBg := myGui.AddText(“x20 y90 w380 h210 +Background”, “”)
contentBg.BackColor := 0x252526
; Location Selection Section
locationLabel := myGui.AddText(“x40 y85 w270”, “Source Warehouse”)
locationLabel.SetFont(“s10 Bold”, “Segoe UI Variable”)
locationLabel.BackColor := 0x252526
locationLabel.TextColor := 0xFFFFFF
; Location dropdown
global locationDropdown := myGui.AddDropDownList(“x40 y110 w300 h200 Choose1 vLocationSelect”, [“Warrior Close”, “Speedwell”, “Hamble SP1”, “Hamble SP4”])
locationDropdown.BackColor := 0x3C3C3C
locationDropdown.SetFont(“s10”, “Segoe UI Variable”)
; Product Number Section
productLabel := myGui.AddText(“x40 y160 w150”, “Product Number”)
productLabel.SetFont(“s10 Bold”, “Segoe UI Variable”)
productLabel.BackColor := 0x252526
productLabel.TextColor := 0xFFFFFF
productContainer := myGui.AddText(“x40 y180 w150 h35 +Background”, “”)
productContainer.BackColor := 0x3C3C3C
inputProduct := myGui.AddEdit(“x40 y185 w140 h25 +Background -Border +Number”)
inputProduct.BackColor := 0x3C3C3C
inputProduct.TextColor := 0xFFFFFF
inputProduct.SetFont(“s10”, “Segoe UI Variable”)
; Quantity Section
qtyLabel := myGui.AddText(“x200 y160 w120 “, “Quantity”)
qtyLabel.SetFont(“s10 Bold”, “Segoe UI Variable”)
qtyLabel.BackColor := 0x252526
qtyLabel.TextColor := 0xFFFFFF
inputQty := myGui.AddEdit(“x200 y185 w140 h25 +Background -Border +Number”)
inputQty.BackColor := 0x3C3C3C
inputQty.TextColor := 0xFFFFFF
inputQty.SetFont(“s10”, “Segoe UI Variable”)
inputQty.Value := 1
; Line Type Selection Section
lineTypeLabel := myGui.AddText(“x40 y240 w140”, “Line Type”)
lineTypeLabel.SetFont(“s10 Bold”, “Segoe UI Variable”)
lineTypeLabel.BackColor := 0x252526
lineTypeLabel.TextColor := 0xFFFFFF
radioDry := myGui.AddRadio(“x40 y265 w65 vRadioDry”, “Dry”)
radioDry.BackColor := 0x252526
radioDry.TextColor := 0xFFFFFF
radioDry.SetFont(“s9”, “Segoe UI Variable”)
radioDry.Value := 1
radioDry.OnEvent(“Click”, UpdateLineDropdown)
radioWet := myGui.AddRadio(“x115 y265 w65 vRadioWet”, “Wet”)
radioWet.BackColor := 0x252526
radioWet.TextColor := 0xFFFFFF
radioWet.SetFont(“s9”, “Segoe UI Variable”)
radioWet.OnEvent(“Click”, UpdateLineDropdown)
; Line Selection Section
categoryLabel := myGui.AddText(“x200 y240 w140”, “Line Selection”)
categoryLabel.SetFont(“s10 Bold”, “Segoe UI Variable”)
categoryLabel.BackColor := 0x252526
categoryLabel.TextColor := 0xFFFFFF
; Create complete category arrays
global dryLines := [
{Name: “”, Code: “”},
{Name: “—A Line—”, Code: “”},
{Name: “A IMM’s”, Code: “WC-MNT 1”},
{Name: “A F&C”, Code: “WC-MNT 2”},
{Name: “A Oven”, Code: “WC-MNT 3”},
{Name: “A Bagger”, Code: “WC-MNT 4”},
{Name: “”, Code: “”},
{Name: “—B Line—”, Code: “”},
{Name: “B IMM’s”, Code: “WC-MNT 5”},
{Name: “B F&C”, Code: “WC-MNT 6”},
{Name: “B Oven”, Code: “WC-MNT 7”},
{Name: “B Bagger”, Code: “WC-MNT 8”},
{Name: “”, Code: “”},
{Name: “—C Line—”, Code: “”},
{Name: “C IMM’s”, Code: “WC-MNT 9”},
{Name: “C F&C”, Code: “WC-MNT 10”},
{Name: “C Oven”, Code: “WC-MNT 11”},
{Name: “C Bagger”, Code: “WC-MNT 12”},
{Name: “”, Code: “”},
{Name: “—D Line—”, Code: “”},
{Name: “D IMM’s”, Code: “WC-MNT 13”},
{Name: “D F&C”, Code: “WC-MNT 14”},
{Name: “D Oven”, Code: “WC-MNT 15”},
{Name: “D Bagger”, Code: “WC-MNT 16”},
{Name: “”, Code: “”},
{Name: “—E Line—”, Code: “”},
{Name: “E IMM’s”, Code: “WC-MNT 17”},
{Name: “E F&C”, Code: “WC-MNT 18”},
{Name: “E Oven”, Code: “WC-MNT 19”},
{Name: “E Bagger”, Code: “WC-MNT 20”},
{Name: “”, Code: “”},
{Name: “—F Line—”, Code: “”},
{Name: “F IMM’s”, Code: “WC-MNT 21”},
{Name: “F F&C”, Code: “WC-MNT 22”},
{Name: “F Oven”, Code: “WC-MNT 23”},
{Name: “F Bagger”, Code: “WC-MNT 24”},
{Name: “”, Code: “”},
{Name: “—H Line—”, Code: “”},
{Name: “H IMM’s”, Code: “WC-MNT 25”},
{Name: “H F&C”, Code: “WC-MNT 26”},
{Name: “H Oven”, Code: “WC-MNT 27”},
{Name: “H Bagger”, Code: “WC-MNT 28”},
{Name: “”, Code: “”},
{Name: “—J Line—”, Code: “”},
{Name: “J IMM’s”, Code: “WC-MNT 29”},
{Name: “J F&C”, Code: “WC-MNT 30”},
{Name: “J Oven”, Code: “WC-MNT 31”},
{Name: “J Bagger”, Code: “WC-MNT 32”},
{Name: “”, Code: “”},
{Name: “—K Line—”, Code: “”},
{Name: “K IMM’s”, Code: “WC-MNT 33”},
{Name: “K F&C”, Code: “WC-MNT 34”},
{Name: “K Oven”, Code: “WC-MNT 35”},
{Name: “K Bagger”, Code: “WC-MNT 36”}
]
global wetLines := [
{Name: “”, Code: “”},
{Name: “—B Line—”, Code: “”},
{Name: “B Sortimat”, Code: “WC-MNT 37”},
{Name: “B HH”, Code: “WC-MNT 38”},
{Name: “”, Code: “”},
{Name: “—C Line—”, Code: “”},
{Name: “C Sortimat”, Code: “WC-MNT 39”},
{Name: “C HH”, Code: “WC-MNT 40”},
{Name: “”, Code: “”},
{Name: “—D Line—”, Code: “”},
{Name: “D Sortimat”, Code: “WC-MNT 41”},
{Name: “D HH”, Code: “WC-MNT 42”},
{Name: “”, Code: “”},
{Name: “—E Line—”, Code: “”},
{Name: “E Sortimat”, Code: “WC-MNT 43”},
{Name: “E HH”, Code: “WC-MNT 44”},
{Name: “”, Code: “”},
{Name: “—F Line—”, Code: “”},
{Name: “F Sortimat”, Code: “WC-MNT 45”},
{Name: “F HH”, Code: “WC-MNT 46”}
]
; Create dropdown with initial dry lines
global currentLines := dryLines
categoryDisplayNames := []
for item in currentLines
categoryDisplayNames.Push(item.Name)
categoryDropdown := myGui.AddDropDownList(“x200 y265 w140 h200 Choose1 vCategorySelect”, categoryDisplayNames)
categoryDropdown.BackColor := 0x3C3C3C
categoryDropdown.SetFont(“s10”, “Segoe UI Variable”)
; —– Action Buttons with Modern Styling —–
btnStart := myGui.AddButton(“Default x40 y320 w140 h40 +Background”, “▶ START”)
btnStart.OnEvent(“Click”, StartScript)
btnStart.SetFont(“s10 Bold”, “Segoe UI Variable”)
btnStart.BackColor := 0x0078D4
btnStart.TextColor := 0xFFFFFF
btnClear := myGui.AddButton(“x200 y320 w140 h40 +Background”, “🔄 RESET ALL”)
btnClear.OnEvent(“Click”, ClearAllFields)
btnClear.SetFont(“s10 Bold”, “Segoe UI Variable”)
btnClear.BackColor := 0x484848
btnClear.TextColor := 0xFFFFFF
CopyToClipboard(*) {
global Field1Content, Field2Content, Field3Content
myMessage := “Hi,`n`nWe are currently zero stock on the following:`n`n” Field2Content “`n" Field3Content "`n” Field1Content “`n`nCould you please check to see whether this has been reordered and provide us with an approximate lead time?`n`nMany Thanks”
```
A_Clipboard := ""
Sleep 100
A_Clipboard := myMessage
ShowModernNotification("Message copied to clipboard!", 2000, "success")
```
}
global btnCopy := unset
btnCopy := myGui.AddText(“x340 y325 w35 h30 Center”, “✉”)
btnCopy.SetFont(“s15”, “Segoe UI Variable”)
btnCopy.OnEvent(“Click”, CopyToClipboard)
btnCopy.BackColor := 0x2D2D30
btnCopy.TextColor := 0xCCCCCC
btnCopy.Visible := false
; —– Status Bar with Modern Styling —–
statusBg := myGui.AddText(“x0 y370 w400 h35 +Background”, “”)
statusBg.BackColor := 0x2D2D30
statusIcon := myGui.AddText(“x15 y380 w20 h15 +Center”)
statusIcon.BackColor := 0x2D2D30
statusIcon.TextColor := 0x00FF88
statusIcon.SetFont(“s12”)
statusText := myGui.AddText(“x40 y380 w340 h15”, “Ready to process orders”)
statusText.SetFont(“s9”, “Segoe UI Variable”)
statusText.BackColor := 0x2D2D30
statusText.TextColor := 0xCCCCCC
; Set window size and show
myGui.Show(“w380 h405”)
; Add input validation and formatting
inputProduct.OnEvent(“Change”, FormatProductNumber)
inputQty.OnEvent(“Change”, ValidateInputs)
categoryDropdown.OnEvent(“Change”, ValidateInputs)
; Global variable to track cursor position
lastProductLength := 0
; Enhanced tooltip system
SetTimer(CheckMousePosition, 50)
CheckMousePosition() {
static lastControl := “”
MouseGetPos(, , , ¤tControl, 2)
```
if (currentControl == locationLabel.Hwnd) {
if (lastControl != currentControl) {
ToolTip("Select the source warehouse for the item")
lastControl := currentControl
}
} else {
if (lastControl == locationLabel.Hwnd) {
ToolTip()
lastControl := ""
}
}
```
}
; Functions
FormatProductNumber(*) {
currentText := inputProduct.Text
cleanText := RegExReplace(currentText, “[^\d]”, “”)
```
if (StrLen(cleanText) > 9) {
cleanText := SubStr(cleanText, 1, 9)
inputProduct.Text := cleanText
inputProduct.Focus()
Send("{End}")
} else if (cleanText != currentText) {
inputProduct.Text := cleanText
}
ValidateInputs()
```
}
GetLocationCode() {
selectedLocation := locationDropdown.Text
switch selectedLocation {
case “Warrior Close”:
return “WC_ENG”
case “Speedwell”:
return “SW_ENG”
case “Hamble SP1”:
return “HM1_ENG”
case “Hamble SP4”:
return “HM4_ENG”
default:
return “WC_ENG”
}
}
GetLocationMessage(isLastOne) {
selectedLocation := locationDropdown.Text
if (selectedLocation = “Warrior Close”) {
if (isLastOne)
return “Taken from Warrior Store - 0 Stock”
else
return “Taken from Warrior Store”
} else {
if (isLastOne)
return “Please deliver to Warrior Close - 0 Stock”
else
return “Please deliver to Warrior Close”
}
}
UpdateLineDropdown(*) {
if (radioDry.Value) {
currentLines := dryLines
} else {
currentLines := wetLines
}
```
categoryDisplayNames := []
for item in currentLines
categoryDisplayNames.Push(item.Name)
currentSelection := categoryDropdown.Text
global currentLines
categoryDropdown.Delete()
categoryDropdown.Add(categoryDisplayNames)
selectionFound := false
Loop categoryDisplayNames.Length {
if (categoryDisplayNames[A_Index] = currentSelection) {
categoryDropdown.Choose(A_Index)
selectionFound := true
break
}
}
if (!selectionFound) {
categoryDropdown.Choose(1)
}
ValidateInputs()
```
}
ValidateInputs(*) {
productNum := inputProduct.Text
qty := inputQty.Text
selectedName := categoryDropdown.Text
```
selectedCode := ""
for item in currentLines {
if item.Name = selectedName {
selectedCode := item.Code
break
}
}
if (productNum != "" && qty != "" && IsNumber(qty) && qty > 0 && selectedCode != "" ) {
UpdateStatus("✅ Ready to start process", 0x00FF88)
btnStart.Enabled := true
btnStart.BackColor := 0x00AA44
} else {
UpdateStatus("⚠ Please complete all required fields", 0xFFAA00)
btnStart.Enabled := false
btnStart.BackColor := 0x666666
}
```
}
UpdateStatus(message, color := 0xCCCCCC) {
statusText.Text := message
statusIcon.TextColor := color
}
ClearAllFields(*) {
inputProduct.Text := “”
inputQty.Value := 1
locationDropdown.Choose(1)
headerSubtitle.Text := “Warrior Close”
radioDry.Value := 1
radioWet.Value := 0
UpdateLineDropdown()
categoryDropdown.Choose(1)
btnCopy.Visible := false
AvailableQty := “”
```
UpdateStatus("🔄 All fields cleared", 0x00A6FF)
btnStart.Enabled := true
btnStart.BackColor := 0x0078D4
ShowModernNotification("All fields have been reset", 1500, "info")
```
}
StartScript(*) {
productSuffix := inputProduct.Text
if (productSuffix == “”) {
UpdateStatus(“❌ Product number required”, 0xFF4444)
ShowModernMessage(“Missing Information”, “Product number is required to continue.”, “error”)
return
}
```
fullProductNumber := productSuffix
if (inputQty.Text == "" || !IsNumber(inputQty.Text) || inputQty.Text <= 0) {
UpdateStatus("❌ Valid quantity required", 0xFF4444)
ShowModernMessage("Invalid Quantity", "Please enter a valid quantity greater than 0.", "error")
return
}
UpdateStatus("🔄 Initializing process…", 0x00A6FF)
btnStart.Enabled := true
btnClear.Enabled := true
btnStart.BackColor := 0x666666
btnClear.BackColor := 0x333333
productNumber := fullProductNumber
quantity := inputQty.Text
requestedQty := Integer(quantity)
selectedName := categoryDropdown.Text
selectedCode := ""
for item in currentLines {
if (item.Name = selectedName) {
selectedCode := item.Code
break
}
}
if WinExist("Oracle Applications - cvprd ahk_class Transparent Windows Client ahk_exe wfica32.exe") {
WinActivate()
} else {
ShowModernMessage("Oracle Not Found", "Oracle is not running.`n`nPlease open the 'Move Order' page in Oracle.", "error")
UpdateStatus("💥 Oracle is not running - Please open 'Move Order' page.", 0xFF4444)
return
}
try {
selectedLocation := locationDropdown.Text
UpdateStatus("🔄 Processing " . selectedLocation . " details…", 0x00A6FF)
myGui.Minimize()
SetKeyDelay 40, 40
Sleep 200
Send "{Tab}"
Sleep 200
Send "+{Tab}"
A_Clipboard := ""
Send("^a")
Sleep 100
Send("^c")
ClipWait(1)
if (A_ClipBoard = "" || !RegExMatch(A_ClipBoard, "\w")) {
ShowModernMessage("Oracle Error", "Please open Oracle in the Move Orders Page", "error")
UpdateStatus("💥 Please open Oracle in Move Orders Page", 0xFF4444)
myGui.Show("w380 h405")
return
}
A_Clipboard := ""
Sleep 200
Send "{Tab}"
Sleep 200
Send "{Tab}"
Sleep 200
Send "Project Move Issue"
Sleep 200
Send "{Tab}"
Sleep 200
Send "CVI UK Warrior Close"
Sleep 200
Send "{Tab}"
Sleep 200
locationCode := GetLocationCode()
Send locationCode
Sleep 200
Send "{Tab}"
Sleep 200
Send "{Tab}"
Sleep 200
Send "{Tab}"
Sleep 200
Send "UKM - Dailies"
Sleep 200
Send "{Tab}"
Sleep 200
Send "{Enter}"
UpdateStatus("⚡ Processing order details…", 0x00A6FF)
Send productNumber
Sleep 200
Send "{Tab 4}"
Sleep 200
Send quantity
Sleep 200
Send "{Tab}"
Sleep 200
Send "11800"
Sleep 200
Send "{Tab}"
Sleep 200
Send selectedCode
Sleep 200
Send "{Tab 2}"
Sleep 200
Send("!o")
Sleep 200
Send "{Tab 4}"
Sleep 200
Loop 6 {
Send "{Enter}"
Sleep 200
Send "{Down}"
Sleep 200
}
Send "{Tab}"
Sleep 200
Send "{Right 2}"
Sleep 200
A_Clipboard := ""
Send("^c")
ClipWait(1)
if (A_ClipBoard = "") {
ShowModernMessage("Item Not Found", "The item was not found in the store.`n`nPlease check the product number and try again.", "error")
UpdateStatus("💥 Item was not found in store.", 0xFF4444)
myGui.Show("w380 h405")
return
} else {
global Field1Content
Field1Content := A_Clipboard
}
Sleep 200
Send "{Right}"
Sleep 200
A_Clipboard := ""
Send("^c")
ClipWait(1)
if (A_ClipBoard = "") {
ShowModernMessage("Field Error", "Could not retrieve Field 2 information.", "error")
UpdateStatus("💥 Item was not found in store for Field 2.", 0xFF4444)
myGui.Show("w380 h405")
return
} else {
global Field2Content
Field2Content := A_Clipboard
}
Sleep 200
Send "{Right}"
Sleep 200
A_Clipboard := ""
Send("^c")
ClipWait(1)
if (A_ClipBoard = "") {
ShowModernMessage("Field Error", "Could not retrieve Field 3 information.", "error")
UpdateStatus("💥 Item was not found in store for Field 3.", 0xFF4444)
myGui.Show("w380 h405")
return
} else {
global Field3Content
Field3Content := A_Clipboard
}
; ***** qty check *****
UpdateStatus("🔍 Checking available quantity…", 0x00A6FF)
Send "{Right 3}"
Sleep 200
A_Clipboard := ""
Send("^c")
ClipWait(1)
if (A_ClipBoard = "") {
ShowModernMessage("Quantity Error", "Could not read the available quantity from Oracle.", "error")
UpdateStatus("💥 Could not read available quantity.", 0xFF4444)
myGui.Show("w380 h405")
return
} else {
global AvailableQty
AvailableQty := A_Clipboard
}
; Convert strings to numbers for comparison
availableQtyNum := Integer(AvailableQty)
requestedQtyNum := Integer(quantity)
; Variable to track if this is the last item (auto-detected)
isLastOne := false
; Check if available quantity is less than requested quantity
if (availableQtyNum < requestedQtyNum) {
; Show modern message asking if user wants to continue with available quantity
message := "Requested quantity (" . quantity . ") is more than available quantity on-hand (" . AvailableQty . ").`n`nDo you want to continue with the available quantity on-hand?"
result := ShowModernMessage("Quantity Check", message, "question", "YesNo")
if (result = "No") {
UpdateStatus("❌ Process cancelled - insufficient quantity in store", 0xFF4444)
ShowModernNotification("Process cancelled by user", 2000, "warning")
myGui.Show("w380 h405")
return
} else {
quantity := AvailableQty
isLastOne := true
UpdateStatus("✅ Continuing with available quantity: " . AvailableQty . " (Auto-detected as last item)", 0x00A6FF)
ShowModernNotification("Using available quantity: " . AvailableQty, 2000, "success")
}
} else if (availableQtyNum = requestedQtyNum) {
isLastOne := true
UpdateStatus("✅ Available quantity matches requested quantity - Auto-detected as last item", 0x00A6FF)
ShowModernNotification("Auto-detected as last item", 2000, "info")
}
A_Clipboard := Field1Content
Sleep 200
Send("^{F4}")
Sleep 200
Send("^v")
Sleep 200
Send "{Tab 3}"
Sleep 200
Send "Damaged"
Sleep 200
Send "{Tab}"
Sleep 200
; Use the appropriate message based on location and last item status
locationMessage := GetLocationMessage(isLastOne)
Send locationMessage
Sleep 200
Send "{Tab 7}"
Sleep 200
Send quantity
; Show copy button if it's the last item
global btnCopy
if isLastOne {
btnCopy.Visible := true
ShowModernNotification("Email template available - click envelope icon", 3000, "info")
} else {
btnCopy.Visible := false
}
; Restore GUI and update status
lineType := radioDry.Value ? "Dry" : "Wet"
finalMessage := "🎉 Process completed! Product: " . productNumber . " | " . lineType . " Line: " . selectedCode
if (availableQtyNum <= requestedQtyNum && isLastOne) {
finalMessage .= " | Auto-detected as LAST ITEM"
}
UpdateStatus(finalMessage, 0x00FF88)
ShowModernNotification("Order processed successfully!", 2000, "success")
; Show completion summary
summaryMessage := "Order Details:`n"
summaryMessage .= "• Product: " . productNumber . "`n"
summaryMessage .= "• Quantity: " . quantity . "`n"
summaryMessage .= "• Location: " . selectedLocation . "`n"
summaryMessage .= "• Line: " . selectedName . " (" . selectedCode . ")`n"
if (isLastOne) {
summaryMessage .= "• Status: Last item (auto-detected)"
}
ShowModernMessage("Process Complete", summaryMessage, "success")
} catch Error as e {
UpdateStatus("💥 Error occurred during processing", 0xFF4444)
ShowModernMessage("Process Error", "An error occurred during processing:`n`n" . e.message, "error")
}
; Re-enable buttons
btnStart.Enabled := true
btnClear.Enabled := true
btnStart.BackColor := 0x00AA44
btnClear.BackColor := 0x484848
myGui.Show("w380 h405")
```
}
; Additional helper functions for enhanced user experience
ShowTopMessage(text) {
; Modern styled top message - replaced old function
ShowModernNotification(text, 3000, “warning”)
}
; Modern loading indicator
ShowLoadingDialog(title, message) {
loadingGui := Gui(”+AlwaysOnTop +Owner” . WinGetID(A_ScriptHwnd) . “ -MaximizeBox -MinimizeBox”, title)
loadingGui.BackColor := 0x2D2D30
loadingGui.MarginX := 20
loadingGui.MarginY := 20
loadingGui.SetFont(“s10”, “Segoe UI Variable”)
```
; Add loading spinner icon
spinnerCtrl := loadingGui.AddText("x20 y20 w40 h40 Center", "⏳")
spinnerCtrl.SetFont("s24")
spinnerCtrl.BackColor := 0x2D2D30
spinnerCtrl.TextColor := 0x00A6FF
; Add message text
msgCtrl := loadingGui.AddText("x70 y20 w250 h40 +Wrap", message)
msgCtrl.BackColor := 0x2D2D30
msgCtrl.TextColor := 0xFFFFFF
msgCtrl.SetFont("s10", "Segoe UI Variable")
; Add progress bar effect
progressCtrl := loadingGui.AddText("x20 y70 w300 h4 +Background", "")
progressCtrl.BackColor := 0x0078D4
loadingGui.Show("w340 h90")
; Return the GUI object so caller can manage it
return loadingGui
```
}
; Enhanced validation with modern feedback
ValidateOracleConnection() {
if WinExist(“Oracle Applications - cvprd ahk_class Transparent Windows Client ahk_exe wfica32.exe”) {
ShowModernNotification(“Oracle connection verified”, 1500, “success”)
return true
} else {
ShowModernMessage(“Oracle Connection Error”,
“Oracle Applications is not running or not accessible.`n`n” .
“Please ensure:`n" . "• Oracle is running`n” .
“• You are on the Move Orders page`n” .
“• The application is responding”, “error”)
return false
}
}
; Modern field validation with visual feedback
ValidateAllFields() {
errors := []
```
if (inputProduct.Text == "") {
errors.Push("• Product number is required")
} else if (StrLen(inputProduct.Text) < 3) {
errors.Push("• Product number must be at least 3 digits")
}
if (inputQty.Text == "" || !IsNumber(inputQty.Text) || inputQty.Text <= 0) {
errors.Push("• Quantity must be a positive number")
}
selectedName := categoryDropdown.Text
selectedCode := ""
for item in currentLines {
if (item.Name = selectedName) {
selectedCode := item.Code
break
}
}
if (selectedCode == "" || selectedName == "" || InStr(selectedName, "—")) {
errors.Push("• Please select a valid production line")
}
if (errors.Length > 0) {
errorMessage := "Please correct the following issues:`n`n"
for error in errors {
errorMessage .= error . "`n"
}
ShowModernMessage("Validation Error", errorMessage, "warning")
return false
}
return true
```
}
; Enhanced clipboard operations with feedback
SafeClipboardOperation(operation, successMessage := “”) {
A_Clipboard := “”
Sleep 100
```
try {
switch operation {
case "copy":
Send("^c")
ClipWait(2)
if (A_Clipboard != "") {
if (successMessage != "") {
ShowModernNotification(successMessage, 1500, "success")
}
return A_Clipboard
} else {
ShowModernMessage("Clipboard Error", "Failed to copy data from Oracle.`n`nPlease try again.", "error")
return false
}
case "paste":
Send("^v")
if (successMessage != "") {
ShowModernNotification(successMessage, 1500, "success")
}
return true
}
} catch Error as e {
ShowModernMessage("Clipboard Error", "Clipboard operation failed:`n`n" . e.message, "error")
return false
}
```
}
; Modern progress tracking
class ProgressTracker {
__New(totalSteps) {
this.totalSteps := totalSteps
this.currentStep := 0
this.startTime := A_TickCount
}
```
UpdateProgress(stepName) {
this.currentStep++
percentage := Round((this.currentStep / this.totalSteps) * 100)
UpdateStatus("🔄 " . stepName . " (" . percentage . "%)", 0x00A6FF)
; Show milestone notifications
if (this.currentStep == 1) {
ShowModernNotification("Starting Oracle automation...", 1500, "info")
} else if (this.currentStep == Round(this.totalSteps / 2)) {
ShowModernNotification("Process 50% complete...", 1500, "info")
} else if (this.currentStep == this.totalSteps) {
elapsed := Round((A_TickCount - this.startTime) / 1000, 1)
ShowModernNotification("Process completed in " . elapsed . " seconds", 2000, "success")
}
}
```
}
; Enhanced error recovery
HandleOracleError(errorType, context) {
switch errorType {
case “connection”:
ShowModernMessage(“Oracle Connection Error”,
“Lost connection to Oracle Applications.`n`n” .
“Context: “ . context . “`n`n” .
“Please check your Oracle connection and try again.”, “error”)
case “data”:
ShowModernMessage(“Data Error”,
“Could not retrieve data from Oracle.`n`n” .
“Context: “ . context . “`n`n” .
“This might be due to:`n" . "• Network connectivity issues`n” .
“• Oracle session timeout`n" . "• Incorrect page or field focus", "error") case "navigation": ShowModernMessage("Navigation Error", "Unable to navigate in Oracle.`n`n" . "Context: " . context . "`n`n" . "Please ensure you are on the correct Oracle page.", "error") default: ShowModernMessage("Unknown Error", "An unexpected error occurred.`n`n” .
“Context: “ . context, “error”)
}
}
; Modern confirmation dialogs with enhanced options
ShowAdvancedConfirmation(title, message, options := [“Yes”, “No”]) {
confirmGui := Gui(”+AlwaysOnTop +Owner” . WinGetID(A_ScriptHwnd) . “ -MaximizeBox -MinimizeBox”, title)
confirmGui.BackColor := 0x2D2D30
confirmGui.MarginX := 20
confirmGui.MarginY := 20
confirmGui.SetFont(“s10”, “Segoe UI Variable”)
```
; Add question icon
iconCtrl := confirmGui.AddText("x20 y20 w40 h40 Center", "❓")
iconCtrl.SetFont("s24")
iconCtrl.BackColor := 0x2D2D30
iconCtrl.TextColor := 0x00A6FF
; Add message
msgCtrl := confirmGui.AddText("x70 y20 w300 h60 +Wrap", message)
msgCtrl.BackColor := 0x2D2D30
msgCtrl.TextColor := 0xFFFFFF
msgCtrl.SetFont("s10", "Segoe UI Variable")
; Add buttons dynamically based on options
result := ""
buttonWidth := 80
totalWidth := (options.Length * buttonWidth) + ((options.Length - 1) * 10)
startX := (400 - totalWidth) / 2
for index, option in options {
xPos := startX + ((index - 1) * (buttonWidth + 10))
btn := confirmGui.AddButton("x" . xPos . " y90 w" . buttonWidth . " h35", option)
btn.SetFont("s10 Bold", "Segoe UI Variable")
if (index == 1) {
btn.BackColor := 0x0078D4 ; Primary button
btn.Focus()
} else {
btn.BackColor := 0x666666 ; Secondary buttons
}
btn.TextColor := 0xFFFFFF
; Create closure to capture the option value
btn.OnEvent("Click", ((opt) => (*) => (result := opt, confirmGui.Close()))(option))
}
confirmGui.Show("w400 h140")
; Wait for result with timeout protection
timeoutCounter := 0
while (result = "" && timeoutCounter < 1200) { ; 60 second timeout
Sleep(50)
timeoutCounter++
}
if (timeoutCounter >= 1200) {
result := options[1] ; Default to first option on timeout
}
try {
confirmGui.Destroy()
} catch {
; Ignore if already destroyed
}
return result
```
}
; Application exit handler with modern confirmation
OnExit(ExitCleanup)
ExitCleanup(ExitReason, ExitCode) {
if (ExitReason != “Reload” && ExitReason != “Single”) {
result := ShowModernMessage(“Exit Confirmation”,
“Are you sure you want to exit the A-TEAM Order System?”,
“question”, “YesNo”)
```
if (result = "No") {
return 1 ; Prevent exit
}
}
; Cleanup operations
try {
; Clear any active timers
SetTimer(CheckMousePosition, 0)
; Cleanup GUI
if IsSet(myGui) && IsObject(myGui) {
myGui.Destroy()
}
} catch {
; Ignore cleanup errors
}
; Only show notification if not reloading
if (ExitReason != "Reload") {
ShowModernNotification("A-TEAM Order System closed", 1000, "info")
}
```
}Editor is loading...
Leave a Comment