Jump to content

Replace full path by relative path before compiling


Miguel
 Share

Recommended Posts

Hello everybody,

After spending some hours searching the forum i gave up,

i´m using Koda to GUI design and i want to automaticly replace the icon full path by relative path before compiling

In this case, replacing "C:\Documents and Settings\Miguel\Os meus documentos\Meus Scripts\Google Maps\Icons\Ok_check.ico" by @WorkingDir&"\icons\Ok_chech.ico"

Is this possible? How could i do it ?

this is my GUI design code

#Region ### START Koda GUI section ### Form=c:\documents and settings\miguel\os meus documentos\dropbox\meus scripts\google maps\opt_zonas_gui.kxf
$Opt_zonas_gui = GUICreate("zonas", 105, 347, 0, 0, BitOR($WS_SIZEBOX,$WS_THICKFRAME,$WS_POPUP,$WS_CLIPSIBLINGS), 0, $Main_Gui)
$ListView_opt_zonas = GUICtrlCreateListView("", 8, 8, 73, 289, BitOR($LVS_REPORT,$LVS_SINGLESEL,$LVS_SHOWSELALWAYS,$WS_GROUP), BitOR($WS_EX_CLIENTEDGE,$LVS_EX_CHECKBOXES))
$Icon_Ok = GUICtrlCreateIcon("C:\Documents and Settings\Miguel\Os meus documentos\Meus Scripts\Google Maps\Icons\Ok_check.ico", -1, 36, 305, 32, 32, BitOR($SS_NOTIFY,$WS_GROUP))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

thanks in advance

Link to comment
Share on other sites

Why do you need both? Why not just have them all as relative paths in the first place?

The only way I can think of doing it if you insist is

If @Compiled then
  $Icon_OK_Check = @WorkingDir & "iconsOk_check.ico"
  Else
   $Icon_OK_Check = "C:Documents and SettingsMiguelOs meus documentosMeus ScriptsGoogle MapsIconsOk_check.ico"
Endif

$Icon_Ok = GUICtrlCreateIcon($Icon_OK_Check, -1, 36, 305, 32, 32, BitOR($SS_NOTIFY,$WS_GROUP))
Edited by ChrisL
Link to comment
Share on other sites

I you are talking about a function to parse your code to do something like that, I don't think it is trivial.

First you would need a RegExp to locate all the paths, then a recursive search to find its relative position

etc...

But maybe I'm wrong about what you want to achieve. In any case you should not assume that the working directory

is on dir or another, and should set it with native function FileChangeDir().

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

My problem is that Koda puts the full path in the icon and if i forgot to change the path to relative path before compiling, that image wont be shown.

thats why i am trying to find a way to change the path before compiling, maybe doing it using auto it wrapper. But my knowledges are not enough to achieve it.

Link to comment
Share on other sites

Maybe the only way to achieve it will be like this...... :)

#cs ***********   DONT FORGET BEFORE COMPILING *************
Search -> Replace
"C:Documents and SettingsMiguelOs meus documentosDropboxMeus ScriptsGoogle MapsIcons"  -> @WorkingDir &"Icons"

#ce
Edited by Miguel
Link to comment
Share on other sites

Why not use AutoItWrapper to embed the icon in the compiled script? Or am I missing something?

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Fixed !!!!

Created a script called _RunBeforeCompiling

This way all full paths placed by Koda wil be replaced by relative path

#include <File.au3>
$find = """C:Documents and SettingsMiguelOs meus documentosDropboxMeus ScriptsGoogle Maps"
$replace = "@WorkingDir&"""
$filename = @WorkingDir&"GmapsMarkers.au3"

$retval = _ReplaceStringInFile($filename,$find,$replace)
if $retval = -1 then
    msgbox(0, "ERROR", "The pattern could not be replaced in file: " & $filename & " Error: " & @error)
    exit
else
    msgbox(0, "INFO", "Found " & $retval & " occurances of the pattern: " & $find & " in the file: " & $filename)
endif
Link to comment
Share on other sites

Have a look here >> http://www.autoitscript.com/autoit3/scite/docs/AutoIt3Wrapper.htm and the section "Adding Extra Ico's to the program resources."

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

In case it's ever any help, I have had the same problem many times with koda and this is how I deal with it.

In the Koda design I don't use the icon I really want to use, I do something like

$IconStEnd2Pt = GUICtrlCreateIcon("shell32.dll", -9, 970, 181, 34, 34, BitOR($GUI_SS_DEFAULT_ICON, $SS_SUNKEN))

Those kind of icon will be found on any PC I hope.

The after the Koda section of my script I have lines like this

GUICtrlSetImage($IconStEnd2Pt, @ScriptFullPath & 'imagespic5.ico')

or something like

GUICtrlSetImage($IconStEnd2Pt, @ScriptFullPath, -25) ; if I'm using AutoIt resources

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...