AHK-v2-script-converter icon indicating copy to clipboard operation
AHK-v2-script-converter copied to clipboard

QuickConvertorV2.ahk Error

Open ThirdRise opened this issue 2 years ago • 3 comments

When attempting to convert code:

`#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. ; Control == ^ Alt == ! Shift == +

; Main Program ; Generic Variables global currentVersion := "Version .7" global createNewX := 0 global createNewY := 0 global extraDelayValue := 0 global extraTabDelayValue := 0 global activeExcelPath := 0

; Save clipboard contents then clear, set ClipboardTimeout to allow for longer delay if clipboard is locked. #ClipboardTimeout, 2000 clipSaved := ClipboardAll Clipboard =

; Overlay GUI Setup OSDColour2 = EAAA99 ; Can be any RGB color (it will be made transparent below). Gui, 2: +LastFound +AlwaysOnTop -Caption +ToolWindow ; +ToolWindow avoids a taskbar button and an alt-tab menu item. Gui, 2:Font, s128, Times New Roman ; Set a large font size (32-point). Gui, 2:Add, Text, vOSDControl cBlue x60 y200, XXXXXXYYYYYY ; XX & YY serve to auto-size the window; add some random letters to enable a longer string of text (but it might not fit on the screen). Gui, 2:Color, %OSDColour2% WinSet, TransColor, %OSDColour2% 110 ; Make all pixels of this color transparent and make the text itself translucent (150) Gui, 2:Show, NoActivate, OSDGui Gui, 2:Show, Hide

; Check for and create a store file if necessary createStoreFile() ; Load default gui values for display along with saved mouse creation coords if they exist, creates a storage file if one does not exist. loadDefaultGuiValue()

; Generate GUI for Gathering Ticket Info Gui, New,, Bulk SCTask Creation Tool by [email protected] %currentVersion% gui, add, text,, * Starting on Excel Row gui, add, text,, * Ending on Excel Row gui, add, text,, Extra Delay (1000 == 1 Second) gui, add, text,, Tab Extra Delay (1000 == 1 Second) gui, add, text,, * Requested for someone else gui, add, text,, Requested for gui, add, text,, * Phone Number gui, add, text,, Extension gui, add, text,, * Building Number gui, add, text,, * Room Number gui, add, text,, * Requested for Employee Type gui, add, text,, * Brief Description gui, add, text, r7.3, * Description gui, add, text,, System Name, EE Number, or Hostname gui, add, text,, Assignment Group gui, add, text,, State gui, add, text,, Assigned To gui, add, button,, Choose Excel File gui, add, edit, number vstartingRow w400 ym, %guiDisplayStartingRow% gui, add, edit, number vendingRow w400, %guiDisplayEndingRow% gui, add, edit, number vextraDelayValue w400, %guiDisplayextraDelay% gui, add, edit, number vextraTabDelayValue w400, %guiDisplayextraTabDelay% gui, add, DropDownList, AltSubmit vrequestedForSomeoneElseDDL w400, 1-Yes|2-No|| gui, add, edit, vrequestedFor w400, %guiDisplayRequestedFor% gui, add, edit, vphoneNumber w400, %guiDisplayPhoneNumber% gui, add, edit, vphoneExtension w400, %guiDisplayPhoneExtension% gui, add, edit, vbuildingNumber w400, %guiDisplayBuildingNumber% gui, add, edit, vroomNumber w400, %guiDisplayRoomNumber% gui, add, DropDownList, AltSubmit vrequestedForEmployeeTypeDDL w400, 1-Employee||2-Contractor|3-HPT / Trainee / Resident / Student|4-Volunteer / WOC / Non-VA Personnel|5- Temporary Account gui, add, edit, vbriefDescription w400, %guiDisplayBriefDescription% gui, add, edit, r6 w400 hscroll vdescription, %guiDisplayDescription% gui, add, edit, vsystemName w400, %guiDisplaySystemName% gui, add, edit, vassignmentGroup w400, %guiDisplayAssignmentGroup% gui, add, DropDownList, AltSubmit vstateDDL w400, Pending|Open||Work In Progress|Closed Complete|Closed Incomplete|Closed Skipped gui, add, edit, vassignedTo w400, %guiDisplayAssignedTo% gui, add, button, vrunLoop, Run Loop GuiControl, Disable, runLoop gui, add, button, default ym, Load Last Used Info gui, add, button,, Help Me gui, add, text,, gui, add, button,, Load Previous Template gui, add, button,, Save Current Template Gui, Show, xcenter ycenter return

; Exit script with Escape key Esc:: xl.Quit xl := "" Clipboard := clipSaved clipSaved = ExitApp

; Exit script when gui closed GuiClose: xl.Quit xl := "" Clipboard := clipSaved clipSaved = ExitApp

; Continue main program after OK button is pressed ButtonRunLoop:

; Gather current Gui Values gui, Submit gui, Destroy

; Add GUI Overlay to provide status of ticket loop OSD("Starting Ticket Loop.") ; Example call: OSD("I'm an aeroplane", "Red", "Arial", "14")

; Save values to last used saveGuiValueToStoreFile()

; Prime information for ticket loop rowCount := startingRow - 1 loopCount := 0 ticketCount := endingRow - startingRow + 1 stateDDL := stateDDL - 2

; Prepare Excel File for use xl := ComObjCreate("Excel.Application") global xlbook := xl.Workbooks.Open(activeExcelPath)

; For Funsies ; SoundPlay, %A_ScriptDir%\soundclip.mp3

loop %ticketCount% { ; Give time for user to activate SNOW window on first loop, and page load for next loops. Sleep 5000 + extraDelayValue

; Increment loop variables
rowCount := rowCount + 1
loopCount := loopCount + 1

; Update Loop Overlay for current iteration 
newOverlayText := "Ticket " loopcount " of " ticketCount
OSD(newOverlayText)

; Send Webpage URL
Send !d
Sleep 100 + extraDelayValue
weblink := "https://some.very.long.web.link"
Send %weblink%
Sleep 1000 + extraDelayValue
Send {Enter} 
Sleep 5000 + extraDelayValue
; Requested For Drop Down List, this is default starting field on web page load
downLoop(Abs(requestedForSomeoneElseDDL))
Sleep 100 + extraDelayValue
; Branch based on if requested for another user
if (requestedForSomeoneElseDDL > 1)
{
    ; Amount of tabs between Requested For DDL and Requested For Phone Number, adjust if SNOW changes
    tabLoop(3)
    sleep 100 + extraDelayValue 
}
else if (requestedForSomeoneElseDDL > 2)
{
    ; Amount of tabs between Requested For DDL and Requested For, adjust if SNOW changes
    tabLoop(1)
    sleep 100 + extraDelayValue 
    ; Requested For Field
    sendValue(requestedFor, rowCount)
    ; Amount of tabs between Requested For and Requested for Phone Number, adjust if SNOW changes
    tabLoop(2)
    sleep 100 + extraDelayValue 
}
; Requested For Phone Number Field
sendValue(phoneNumber, rowCount)
sleep 100 + extraDelayValue 
; Amount of tabs between Requsted For Phone Number and Requested For Phone Extension, adjust if SNOW changes
tabLoop(2)
sleep 100 + extraDelayValue
; Requested for Phone Extension Field
sendValue(phoneExtension, rowCount)
; Amount of tabs between Requsted For Phone Extension and Requested For Building Number, adjust if SNOW changes
tabLoop(3)
sleep 100 + extraDelayValue 
; Requested for Building Number Field
sendValue(buildingNumber, rowCount)
; Amount of tabs between Requsted For Building Number and Requested For Room Number, adjust if SNOW changes
tabLoop(1)
sleep 100 + extraDelayValue 
; Requested for Building Number Field
sendValue(roomNumber, rowCount)
; Amount of tabs between Requsted For Room Number and Requested For Employee Type, adjust if SNOW changes
tabLoop(1)
sleep 100 + extraDelayValue 
; Requested for Employee Type DDL
downLoop(Abs(requestedForEmployeeTypeDDL))
Sleep 100 + extraDelayValue
; Amount of tabs between Requsted For Employee Type and Brief Description, adjust if SNOW changes
tabLoop(3)
sleep 100 + extraDelayValue 
; Brief Description Field
sendValue(briefDescription, rowCount)
; Amount of tabs between Brief Description and Description, adjust if SNOW changes
tabLoop(2)
sleep 100 + extraDelayValue 
; Description Field
sendValue(description, rowCount)
; Amount of tabs between Description and System Name, adjust if SNOW changes
tabLoop(2)
sleep 100 + extraDelayValue 
; System Name Field
sendValue(systemName, rowCount)
; Amount of tabs between System Name and Request Assignment Group, adjust if SNOW changes
tabLoop(2)
sleep 100 + extraDelayValue 
; Assignment Group
sendValue(assignmentGroup, rowCount)
sleep 500 + extraDelayValue
; Amount of tabs between Request Assignment Group and submit, adjust if SNOW changes
tabLoop(1)
sleep 100 + extraDelayValue 
; Submit Button
Sleep 1000 + extraDelayValue
send, {Enter}
Sleep 5000 + extraDelayValue
; Amount of tabs to Navigate to RITM Page, adjust if SNOW changes
tabLoop(6)
sleep 100 + extraDelayValue
send {Enter}
sleep 5000 + extraDelayValue
; Amount of tabs to Navigate to SCTask Page, adjust if SNOW changes
tabLoop(81)
sleep 100 + extraDelayValue
send {Enter}
sleep 5000 + extraDelayValue
; Amount of tabs to State Drop Down List, adjust if SNOW changes
tabLoop(3)
; State Drop Down List
; State starts on open, the bottom of the list. I adjust that above with a -2, then logic follows to complete.
if (stateDDL > 0)
{
    downLoop(stateDDL)
    Sleep 100 + extraDelayValue
}
else if (stateDDL < 0)
{
    upLoop(Abs(stateDDL))
    Sleep 100 + extraDelayValue
}
else if (stateDDL = 0)
{
    sleep 100 +extraDelayValue
}
; Amount of tabs between State Drop Down List and Assigned to, adjust if SNOW changes
tabLoop(2)
; Assigned to Field
sendValue(assignedTo, rowCount)
sleep 500 + extraDelayValue
; Amount of tabs between Assigned to and Short Description, adjust if SNOW changes
tabLoop(1)
; Short Description to Field
sendValue(briefDescription, rowCount)
sleep 100 + extraDelayValue
; Amount of tabs to get back to update button at top of page, adjust if SNOW changes
shiftTabLoop(12)
sleep 500 + extraDelayValue
send {Enter}

}

; Clear Excel ComObject Call xl.Quit xl := "" Clipboard := clipSaved clipSaved =

; Exit program here all tickets completed ExitApp

; Building Area

; function stump ; But what does it do? - Yarusch ; Current State == Not Functional basicFunction(vari1, vari2) {

}

; Completed Functions and subroutines

; Send Tabs based on value given, cleans code above to be more readable ; Current State == Functional tabLoop(tabCount) { loop %tabCount% { SendInput, {Tab} Sleep %extraTabDelayValue%
} return }

; Send Shift Tabs based on value given, cleans code above to be more readable ; Current State == Functional shiftTabLoop(tabCount) { loop %tabCount% { SendInput, +{Tab} Sleep %extraTabDelayValue%
} return }

; Send the value provided, cleans code above to be more readable ; Current State == Functional sendValue(sendValue, sendRow) { value := checkDynamicSend(sendValue, sendRow) sendValueClipboard(value) value = sleep 100 + extraDelayValue return }

; Checks value for strength length then sends via clipboard or direct depending on length. ; Current State == Complete and Functional sendValueClipboard(sendValue) { if (StrLen(sendValue) > 100) { clipboard = %sendValue% ClipWait, 2 if ErrorLevel { MsgBox, The attempt to copy text onto the clipboard failed. Take note of which item loop broke on below. Press escape to break out of loop. xl.Quit xl := "" Clipboard := clipSaved clipSaved = ExitApp } send, ^v sleep 100 + extraDelayValue clipboard = } else { send, %sendValue% sleep 100 + extraDelayValue } return
}

; Run routine when load last file button is pressed ; All working except for updating the values of the coords for create new and submit ButtonLoadLastUSedInfo: loadGuiValuesFromStoreFile() updateGuiValues() return

; Parses a string and returns the value including dynamic information pulled from dynamic excel switch based on switch in the string and current row being used in loop. ; Current State = Complete and Functional translateDynamicExcel(translateString, currentRow) { global translatedOutput := "" Loop, parse, translateString, `, { length := StrLen(A_LoopField) if length = 1 { if A_LoopField is Alpha { cellString = %A_LoopField%%currentRow% functionValue := xlbook.Sheets(1).Range(cellString).Text translatedOutput = %translatedOutput% %functionValue% } else { translatedOutput = %translatedOutput%%A_LoopField% } } else { translatedOutput = %translatedOutput%%A_LoopField% } } return translatedOutput }

; LoadValues from Stored File if it exists, creates it if it doesn't ; Current State = Complete and Functional loadGuiValuesFromStoreFile() { global createStoreFile() IniRead, guiDisplayStartingRow, lastUsedReq.ini, templateValues, startingRow, %A_Space% IniRead, guiDisplayEndingRow, lastUsedReq.ini, templateValues, endingRow, %A_Space% IniRead, guiDisplayextraDelay, lastUsedReq.ini, templateValues, extraDelayValue, %A_Space% IniRead, guiDisplayextraTabDelay, lastUsedReq.ini, templateValues, extraTabDelayValue, %A_Space% IniRead, guiDisplayRequestedForDDL, lastUsedReq.ini, templateValues, requestedForSomeoneElseDDL, %A_Space% IniRead, guiDisplayRequestedFor, lastUsedReq.ini, templateValues, requestedFor, %A_Space% IniRead, guiDisplayPhoneNumber, lastUsedReq.ini, templateValues, phoneNumber, %A_Space% IniRead, guiDisplayPhoneExtension, lastUsedReq.ini, templateValues, phoneExtension, %A_Space% IniRead, guiDisplayBuildingNumber, lastUsedReq.ini, templateValues, buildingNumber, %A_Space% IniRead, guiDisplayRoomNumber, lastUsedReq.ini, templateValues, roomNumber, %A_Space% IniRead, guiDisplayRequestedForEmployeeTypeDDL, lastUsedReq.ini, templateValues, requestedForEmployeeTypeDDL, %A_Space% IniRead, guiDisplayBriefDescription, lastUsedReq.ini, templateValues, briefDescription, %A_Space% IniRead, readDescription, lastUsedReq.ini, templateValues, description, %A_Space% guiDisplayDescription := StrReplace(readDescription, "", "`n") IniRead, guiDisplaySystemName, lastUsedReq.ini, templateValues, systemName, %A_Space% IniRead, guiDisplayAssignmentGroup, lastUsedReq.ini, templateValues, assignmentGroup, %A_Space% IniRead, guiDisplayStateDDL, lastUsedReq.ini, templateValues, stateDDL, %A_Space% IniRead, guiDisplayAssignedTo, lastUsedReq.ini, templateValues, assignedTo, %A_Space% return }

; Update current fields in gui to reflect values of variables. ; Current State = Complete and Functional updateGuiValues() { global GuiControl,, startingRow, %guiDisplayStartingRow% GuiControl,, endingRow, %guiDisplayEndingRow% GuiControl,, extraDelayValue, %guiDisplayextraDelay% GuiControl,, extraTabDelayValue, %guiDisplayextraTabDelay% GuiControl, Choose, requestedForSomeoneElseDDL, %guiDisplayRequestedForDDL% GuiControl,, requestedFor, %guiDisplayRequestedFor% GuiControl,, phoneNumber, %guiDisplayPhoneNumber% GuiControl,, phoneExtension, %guiDisplayPhoneExtension% GuiControl,, buildingNumber, %guiDisplayBuildingNumber% GuiControl,, roomNumber, %guiDisplayRoomNumber% GuiControl, Choose, requestedForEmployeeTypeDDL, %guiDisplayRequestedForEmployeeTypeDDL% GuiControl,, briefDescription, %guiDisplaybriefDescription% GuiControl,, description, %guiDisplayDescription% GuiControl,, systemName, %guiDisplaySystemName% GuiControl,, assignmentGroup, %guiDisplayAssignmentGroup% GuiControl, Choose, stateDDL, %guiDisplayStateDDL% GuiControl,, assignedTo, %guiDisplayAssignedTo% Return }

; Test a string provided and return boolean value if dynamic excel switch is in string. ; Dynamic Excel Swith = ,x, where x is the letter representing the column to pull information from. ; Current State = Complete and Functional containsExcelDynamic(contentString) { isDynamic = False Loop, parse, contentString, `, { length := StrLen(A_LoopField) if length = 1 { isDynamic = True } } return isDynamic }

; Creates the default store file if it doesn't exist ; Current State = Complete and Functional createStoreFile() { global if !FileExist(A_ScriptDir "\lastUsedReq.ini") { IniWrite, "Which excel row to start on?", lastUsedReq.ini, templateValues, startingRow IniWrite, "Which excel row is the last one to be used?", lastUsedReq.ini, templateValues, endingRow IniWrite, "Must be a number minimum 0 suggested 100", lastUsedReq.ini, templateValues, extraDelayValue IniWrite, "Must be a number minimum 0", lastUsedReq.ini, templateValues, extraTabDelayValue IniWrite, 2, lastUsedReq.ini, templateValues, requestedForEmployeeTypeDDL IniWrite, "Leave Blank for self request (I'd use this), use exact name FirstName LastName if for another", lastUsedReq.ini, templateValues, requestedFor IniWrite, "10 or 11 Digit Number", lastUsedReq.ini, templateValues, phoneNumber IniWrite, "Extension, can be left blank", lastUsedReq.ini, templateValues, phoneExtension IniWrite, "Building Number", lastUsedReq.ini, templateValues, buildingNumber IniWrite, "Room Number", lastUsedReq.ini, templateValues, roomNumber IniWrite, 1, lastUsedReq.ini, templateValues, requestedForSomeoneElseDDL IniWrite, "Short Decription of Case", lastUsedReq.ini, templateValues, briefDescription IniWrite, "Description of Case", lastUsedReq.ini, templateValues, description IniWrite, "System Name or EE Number", lastUsedReq.ini, templateValues, systemName IniWrite, "Assignment Group as it appears in SNOW, ie group", lastUsedReq.ini, templateValues, assignmentGroup IniWrite, 2, lastUsedReq.ini, templateValues, stateDDL IniWrite, "Assigned to use full @nope.nope email address for best results", lastUsedReq.ini, templateValues, assignedTo } return }

; Save values to the storage file to be used later ; Current State = Complete and Functional saveGuiValueToStoreFile() { global IniWrite, %startingRow%, lastUsedReq.ini, templateValues, startingRow IniWrite, %endingRow%, lastUsedReq.ini, templateValues, endingRow IniWrite, %extraDelayValue%, lastUsedReq.ini, templateValues, extraDelayValue IniWrite, %extraTabDelayValue%, lastUsedReq.ini, templateValues, extraTabDelayValue IniWrite, %requestedForSomeoneElseDDL%, lastUsedReq.ini, templateValues, requestedForSomeoneElseDDL IniWrite, %requestedFor%, lastUsedReq.ini, templateValues, requestedFor IniWrite, %phoneNumber%, lastUsedReq.ini, templateValues, phoneNumber IniWrite, %phoneExtension%, lastUsedReq.ini, templateValues, phoneExtension IniWrite, %roomNumber%, lastUsedReq.ini, templateValues, roomNumber IniWrite, %buildingNumber%, lastUsedReq.ini, templateValues, buildingNumber IniWrite, %requestedForEmployeeTypeDDL%, lastUsedReq.ini, templateValues, requestedForEmployeeTypeDDL IniWrite, %briefDescription%, lastUsedReq.ini, templateValues, briefDescription IniWrite, % StrReplace(description, "`n",""), lastUsedReq.ini, templateValues, description IniWrite, %systemName%, lastUsedReq.ini, templateValues, systemName IniWrite, %assignmentGroup%, lastUsedReq.ini, templateValues, assignmentGroup IniWrite, %stateDDL%, lastUsedReq.ini, templateValues, stateDDL IniWrite, %assignedTo%, lastUsedReq.ini, templateValues, assignedTo return }

; Check which value to send based on if there is dynamic content or not, then return the value that should be sent as a string. ; Current State = Complete and Functional checkDynamicSend(contentString, excelRow) { isDynamic := containsExcelDynamic(contentString) translatedContent := "" if (%isDynamic% = False) { translatedContent = %contentString% } else { translatedContent := translateDynamicExcel(contentString, excelRow) } return %translatedContent% }

; Repeats down key action with pauses based on variable provided ; Current State = Complete and Functional downLoop(loopCount) { SendInput, {Down} Sleep 300 + extraDelayValue if (loopCount > 1) { downLoop(loopcount - 1) } return }

; Repeats up key action with pauses based on variable provided ; Current State = Complete and Functional upLoop(loopCount) { SendInput, {Up} Sleep 300 + extraDelayValue if (loopCount > 1) { upLoop(loopcount - 1) } return }

; Load default values to populate in GUI along with stored values for click positions ; Current State = Complete and Functional loadDefaultGuiValue() { global guiDisplayStartingRow := "Which excel row to start on?" guiDisplayEndingRow := "Which excel row is the last one to be used?" guiDisplayextraDelay := "Must be a number, minimum 0, suggested 100" guiDisplayextraTabDelay := "Must be a number, minimum 0" guiDisplayPhoneNumber := "10 or 11 Digit Number, suggested (xxx) yyy-zzzz format" guiDisplayPhoneExtension := "Extension, can be left blank" guiDisplayBuildingNumber := "Building Number" guiDisplayRoomNumber := "Room Number" guiDisplayBriefDescription := "Short Decription of Case" guiDisplayDescription := "Description of Case" guiDisplaysystemName := "System Name or EE Number" guiDisplayAssignmentGroup := "Assignment Group as it appears in SNOW, ie group" guiDisplayAssignedTo := "Assigned to use full @nope.nope email address for best results" return }

; Uses file prompt to allow use to select the excel file then enables the run loop button. ; Current State == Complete and Functional ButtonChooseExcelFile: FileSelectFile, activeExcelPath GuiControl, Enable, runLoop return

; Loads tutorial for user as a pop box ; Current State == Complete and Functional ButtonHelpMe: msgbox, "So this will actually be the tutorial for the incident version of the tool cause I haven't written a task one.`nBut most of the stuff is the same." run https://some.other.web.link

; Loads previous template via file open box. ; Current State == Complete and Functional ButtonLoadPreviousTemplate: FileSelectFile, toOpenFileName, 3, %A_WorkingDir%, Open Template, Template (*.ini) toOpenFileName := StrReplace(toOpenFileName, ".ini") IniRead, guiDisplayStartingRow, %toOpenFileName%.ini, templateValues, startingRow, %A_Space% IniRead, guiDisplayEndingRow, %toOpenFileName%.ini, templateValues, endingRow, %A_Space% IniRead, guiDisplayextraDelay, %toOpenFileName%.ini, templateValues, extraDelayValue, %A_Space% IniRead, guiDisplayextraTabDelay, %toOpenFileName%.ini, templateValues, extraTabDelayValue, %A_Space% IniRead, guiDisplayRequestedForSomeoneElseDDL, %toOpenFileName%.ini, templateValues, requestedForSomeoneElseDDL, %A_Space% IniRead, guiDisplayPhoneNumber, %toOpenFileName%.ini, templateValues, phoneNumber, %A_Space% IniRead, guiDisplayPhoneExtension, %toOpenFileName%.ini, templateValues, phoneExtension, %A_Space% IniRead, guiDisplayBuildingNumber, %toOpenFileName%.ini, templateValues, buildingNumber, %A_Space% IniRead, guiDisplayRoomNumber, %toOpenFileName%.ini, templateValues, roomNumber, %A_Space% IniRead, guiDisplayRequestedForEmployeeTypeDDL, %toOpenFileName%.ini, templateValues, requestedForEmployeeTypeDDL, %A_Space% IniRead, guiDisplaybriefDescription, %toOpenFileName%.ini, templateValues, briefDescription, %A_Space% IniRead, readDescription, %toOpenFileName%.ini, templateValues, description, %A_Space% guiDisplayDescription := StrReplace(readDescription, "", "`n") IniRead, guiDisplaysystemName, %toOpenFileName%.ini, templateValues, systemName, %A_Space% IniRead, guiDisplayAssignmentGroup, %toOpenFileName%.ini, templateValues, assignmentGroup, %A_Space% IniRead, guiDisplaystateDDL, %toOpenFileName%.ini, templateValues, stateDDL, %A_Space% IniRead, guiDisplayAssignedTo, %toOpenFileName%.ini, templateValues, assignedTo, %A_Space% updateGuiValues() return

; Saves current template via file save box ; Current State == Complete and Functional ButtonSaveCurrentTemplate: FileSelectFile, toSaveFileName, S24, %A_WorkingDir%, Save Template, Template (*.ini) toSaveFileName := StrReplace(toSaveFileName, ".ini") Gui, submit, NoHide IniWrite, %startingRow%, %toSaveFileName%.ini, templateValues, startingRow IniWrite, %endingRow%, %toSaveFileName%.ini, templateValues, endingRow IniWrite, %extraDelayValue%, %toSaveFileName%.ini, templateValues, extraDelayValue IniWrite, %extraTabDelayValue%, %toSaveFileName%.ini, templateValues, extraTabDelayValue IniWrite, %requestedForSomeoneElseDDL%, %toSaveFileName%.ini, templateValues, requestedForSomeoneElseDDL IniWrite, %phoneNumber%, %toSaveFileName%.ini, templateValues, phoneNumber IniWrite, %phoneExtension%, %toSaveFileName%.ini, templateValues, phoneExtension IniWrite, %buildingNumber%, %toSaveFileName%.ini, templateValues, buildingNumber IniWrite, %roomNumber%, %toSaveFileName%.ini, templateValues, roomNumber IniWrite, %requestedForEmployeeTypeDDL%, %toSaveFileName%.ini, templateValues, requestedForEmployeeTypeDDL IniWrite, %briefDescription%, %toSaveFileName%.ini, templateValues, briefDescription IniWrite, % StrReplace(description, "`n",""), %toSaveFileName%.ini, templateValues, description IniWrite, %systemName%, %toSaveFileName%.ini, templateValues, systemName IniWrite, %assignmentGroup%, %toSaveFileName%.ini, templateValues, assignmentGroup IniWrite, %stateDDL%, %toSaveFileName%.ini, templateValues, stateDDL IniWrite, %assignedTo%, %toSaveFileName%.ini, templateValues, assignedTo return

OSD(Text="OSD",Colour="Blue",Font="Times New Roman",Size="128") { ; Displays an On-Screen Display, a text in the middle of the screen. Gui, 2:Font, c%Colour% s%Size%, %Font% ; If desired, use a line like this to set a new default font for the window. GuiControl, 2:Font, OSDControl ; Put the above font into effect for a control. GuiControl, 2:, OSDControl, %Text% Gui, 2:Show, NoActivate, OSDGui ; NoActivate avoids deactivating the currently active window; add "X600 Y800" to put the text at some specific place on the screen instead of centred. Return }`

An error is received: Error: Parameter #2 of InStr is invalid.

Specifically: empty string

---- C:\Temp\AHK-v2-script-converter-master\AHK-v2-script-converter-master\ConvertFuncs.ahk
1411: {
1412: ControlName := RegExReplace(Var3, "^.*\bv([\w]*)\b.*$", "$1")

▶ 1414: ControlObject := InStr(ControlName, SubStr(Var2, 1, 4)) ? "ogc" ControlName : "ogc" Var2 ControlName 1415: mGuiCObject[ControlName] := ControlObject 1416: If (Var2 != "Pic" and Var2 != "Picture" and Var2 != "Text" and Var2 != "Button" and Var2 != "Link" and Var2 != "Progress" and Var2 != "GroupBox" and Var2 != "Statusbar" and Var2 != "ActiveX")

Call stack: C:\Temp\AHK-v2-script-converter-master\AHK-v2-script-converter-master\ConvertFuncs.ahk (1414) : [InStr] ControlObject := InStr(ControlName, SubStr(Var2, 1, 4)) ? "ogc" ControlName : "ogc" Var2 ControlName C:\Temp\AHK-v2-script-converter-master\AHK-v2-script-converter-master\ConvertFuncs.ahk (1414) : [_Gui] ControlObject := InStr(ControlName, SubStr(Var2, 1, 4)) ? "ogc" ControlName : "ogc" Var2 ControlName C:\Temp\AHK-v2-script-converter-master\AHK-v2-script-converter-master\ConvertFuncs.ahk (749) : [Convert] Line := Indentation . FuncObj(Param) C:\Temp\AHK-v2-script-converter-master\AHK-v2-script-converter-master\QuickConvertorV2.ahk (386) : [ButtonConvert] V2Edit.Text := Convert(V1Edit.Text) C:\Temp\AHK-v2-script-converter-master\AHK-v2-script-converter-master\QuickConvertorV2.ahk (900) : [Sleep] Sleep(100) C:\Temp\AHK-v2-script-converter-master\AHK-v2-script-converter-master\QuickConvertorV2.ahk (900) : [<Hotkey>] Sleep(100)

~LButton

image

ThirdRise avatar Feb 22 '23 21:02 ThirdRise

Sorry if the post is hard to read or formatted wrong, I'm new here.

ThirdRise avatar Feb 22 '23 21:02 ThirdRise

It seems SubStr(Var2,1,4) returns an empty string, that seems to be the error.

If you can provide the correct conversion, I can try to add it to the convertor.

Please try to filter the code to a simple short version that demonstrates the error, to make it easy for us to fix the conversion.

dmtr99 avatar Mar 23 '23 22:03 dmtr99

Example minimal code:

Gui, Add, ListBox, w300 h200 hwndhOutput

SunSerega avatar Nov 19 '23 13:11 SunSerega

The reason this was failing was because the gui line had an hwnd output, but no 4th parameter. To access the the value v2 requires saving the control as a variable the using the .hwnd property, to create this variable name the converter based the name off of the 4th parameter, and if it wasn't defined the script then errored.

To fix this I added if 4th param is blank to base the name off of the Control type (followed by a number to avoid conflicts) If anyone has a better way please reply

Banaanae avatar Jun 12 '24 05:06 Banaanae