Jump to content
rm4453

File Selection Dialog That Grabs File Path And Saves As Variable

Recommended Posts

rm4453

I am using Koda to create a gui that will be used to login to a site and post a listing. I need to find a way to get Koda to add a file select button that opens the file selection window, and saves all of the images file paths that are selected, and keeps track of how many there were. That way it can paste the file path into the site along with a description of the image, and click submit for each of the images selected. I need it to store these variables in a .ini if possible as well that way everything will load back up exactly how it was, if it was to ever be closed. Here is the code that Koda has generated for me so far... "See attached for actual Koda Import File"

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=*******
$Form1 = GUICreate("Form1", 615, 437, 340, 172)
$Email = GUICtrlCreateInput("Email", 24, 35, 145, 21)
$Password = GUICtrlCreateInput("Password", 24, 61, 145, 21)
$Submit = GUICtrlCreateButton("Submit", 59, 88, 75, 25)
$LoginInfo = GUICtrlCreateGroup("LoginInfo", 8, 8, 177, 113)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$ListingInfo = GUICtrlCreateGroup("ListingInfo", 200, 8, 401, 417)
$Price = GUICtrlCreateInput("Price", 232, 40, 137, 21)
$Title = GUICtrlCreateInput("Title", 232, 72, 137, 21)
$Description = GUICtrlCreateEdit("", 232, 200, 337, 105)
GUICtrlSetData(-1, "Description")
$ListingType = GUICtrlCreateGroup("ListingType", 376, 24, 193, 81)
$For_Sale = GUICtrlCreateRadio("For_Sale", 384, 39, 193, 21)
$Item_Wanted = GUICtrlCreateRadio("Item_Wanted", 384, 71, 193, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Business_or_Private = GUICtrlCreateGroup("Business_or_Private", 232, 112, 337, 65)
$Business_Listing = GUICtrlCreateRadio("Business_Listing", 248, 136, 153, 25)
$Private_Listing = GUICtrlCreateRadio("Private_Listing", 408, 136, 153, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$ContactInfo = GUICtrlCreateGroup("ContactInfo", 232, 312, 337, 73)
$Phone1 = GUICtrlCreateInput("801", 237, 330, 33, 21)
$Phone3 = GUICtrlCreateInput("1080", 317, 330, 33, 21)
$Phone2 = GUICtrlCreateInput("808", 277, 330, 33, 21)
$Address = GUICtrlCreateInput("Address", 360, 328, 201, 21)
$City = GUICtrlCreateInput("City", 360, 352, 49, 21)
$State = GUICtrlCreateInput("State example: UT", 416, 352, 97, 21)
$Zip = GUICtrlCreateInput("Zip", 520, 352, 41, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$SubmitListing = GUICtrlCreateButton("SubmitListing", 456, 392, 113, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

 

Listing Gui Layout.kxf

Edited by rm4453
Remove Personal Data

Share this post


Link to post
Share on other sites
rm4453

Can anyone confirm if this will work?

 

Func OpenImages()
$message = "Hold down Ctrl or Shift to choose multiple files."

$var = FileOpenDialog($message, @WindowsDir & "\", "Images (*.jpg;*.bmp)", 1 + 4 )

If @error Then
    MsgBox(4096,"","No File(s) chosen")
Else
    $varsplit = StringSplit($var, "|")
    $filePath = $varsplit[0] & "\" ; Do this because it returns first part of filepath without file name in slot 0, and 1 will be first images name.
EndIf
EndFunc

 

Share this post


Link to post
Share on other sites
AutoBert

No it can't work:

Quote

Returns an array, by default the first element ($aArray[0]) contains the number of strings returned

see remarks in helfile to stringsplit. When using flag $STR_NOCOUNT it works but only if >1 file(s) selected. So do it like this:

Func OpenImages()
    $message = "Hold down Ctrl or Shift to choose multiple files."

    $var = FileOpenDialog($message, @WindowsDir & "\", "Images (*.jpg;*.bmp)", 1 + 4)

    If @error Then
        MsgBox(4096, "", "No File(s) chosen")
    Else
        $varsplit = StringSplit($var&"|", "|")
        $filePath = $varsplit[0] & "\" ; Do this because it returns first part of filepath without file name in slot 0, and 1 will be first images name.
        ;_ArrayDelete($varsplit[0]) ;removing empty string if file(s) needed 
    EndIf
EndFunc   ;==>OpenImages

 

Share this post


Link to post
Share on other sites
rm4453
6 hours ago, AutoBert said:

No it can't work:

see remarks in helfile to stringsplit. When using flag $STR_NOCOUNT it works but only if >1 file(s) selected. So do it like this:

Func OpenImages()
    $message = "Hold down Ctrl or Shift to choose multiple files."

    $var = FileOpenDialog($message, @WindowsDir & "\", "Images (*.jpg;*.bmp)", 1 + 4)

    If @error Then
        MsgBox(4096, "", "No File(s) chosen")
    Else
        $varsplit = StringSplit($var&"|", "|")
        $filePath = $varsplit[0] & "\" ; Do this because it returns first part of filepath without file name in slot 0, and 1 will be first images name.
        ;_ArrayDelete($varsplit[0]) ;removing empty string if file(s) needed 
    EndIf
EndFunc   ;==>OpenImages

 

I did this and it works just fine... had to change $filePath = $varsplit[0] to $filepath = $varsplit[1]  (see ex)

 

Func OpenImages()
$message = "Hold down Ctrl or Shift to choose multiple files."

$var = FileOpenDialog($message, @WindowsDir & "\", "Images (*.jpg;*.bmp)", 1 + 4 )

If @error Then
    MsgBox(4096,"","No File(s) chosen")
Else
    $varsplit = StringSplit($var, "|")
    $filePath = $varsplit[1] & "\" ; Do this because it returns first part of filepath without file name in slot 1, and 2 will be first images name.
    $filepathmsg = MsgBox("Path","Here is File Path", $filepath)
EndIf
EndFunc
$1 = 1
while 1 = $1
    OpenImages()
    $1 = 2
WEnd

THANKS FOR ALL THE HELP! :D

Share this post


Link to post
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

  • Similar Content

    • ufukreis1212
      By ufukreis1212
      Hello, I am new members. Help me please. I want vbs convert to au3 .
      This vbs code : 
      'deneme Set SystemSet = GetObject("winmgmts:").InstancesOf ("Win32_OperatingSystem") strOSArch = GetObject("winmgmts:root\cimv2:Win32_OperatingSystem=@").OSArchitecture Set objNetwork = CreateObject("Wscript.Network") Set wshShell = CreateObject( "WScript.Shell" ) strComputerName = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" ) Set oShell = WScript.CreateObject("WScript.Shell") proc_arch = oShell.ExpandEnvironmentStrings("%PROCESSOR_ARCHITECTURE%") Set oEnv = oShell.Environment("SYSTEM") strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") Set colMB = objWMIService.ExecQuery("Select * from Win32_BaseBoard") Set colCSes = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem") Set colProcessors = objWMIService.ExecQuery("Select * from Win32_Processor") Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") Set colItemsx = objWMIService.ExecQuery( _ "SELECT * FROM Win32_VideoController",,48) '------------------------------------------------------------------- Set obj = GetObject("winmgmts:").InstancesOf("Win32_PhysicalMemory") i = 1 For Each obj2 In obj memTmp1 = obj2.capacity / 1024 / 1024 TotalRam = TotalRam + memTmp1 i = i +1 Next '-------------------------------------------------------------------- Dim objWMIService : Set objWMIService = GetObject("winmgmts:\\.\root\cimv2") Set colItems = objWMIService.ExecQuery("Select Architecture from Win32_Processor") For Each objItem in colItems if objItem.Architecture = 0 then strArchitecture = "x86" end if if objItem.Architecture = 9 then strArchitecture = "x64" end if next '-------------------------------------------------------------------- strComputer = "." ' Local computer strMemory = "" i = 1 set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") set colItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemory") For Each objItem In colItems if strMemory <> "" then strMemory = strMemory & vbcrlf strMemory = strMemory & "Bank" & i & " : " & (objItem.Capacity /1024 /1024) & " Mb" i = i + 1 Next installedModules = i - 1 Set colItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemoryArray") For Each objItem in colItems totalSlots = objItem.MemoryDevices Next '---------------------------------------------------------------------- Set objWMISvc = GetObject( "winmgmts:\\.\root\cimv2" ) Set colItems = objWMISvc.ExecQuery( "Select * from Win32_ComputerSystem" ) For Each objItem in colItems strComputerDomain = objItem.Domain Next for each System in SystemSet For Each objItem in colItemsx For Each objProcessor in colProcessors For Each bbType In colMB MbVendor = bbType.Manufacturer MbModel = bbType.Product MsgBox "İşletim Sistemi : " & System.Caption & vbNewLine & _ "İşletim Sistemi Versionu : " & + System.Version & vbNewLine & _ "Windows Mimari Yapısı: " & strOSArch & vbNewLine & _ "Kullanıcı isminiz: " & objNetwork.UserName & vbNewLine & _ "Bilgisayar ismi: " & strComputerName & vbNewLine & _ "Çalışma Grubu: " & strComputerDomain & vbNewLine & _ "--------------------------------------" & vbNewLine & _ "Anakart: " & MbVendor & " " & "[" & MbModel & "]" & vbNewLine & _ "--------------------------------------" & vbNewLine & _ "Grafik Kartı: " & objItem.Caption & vbNewLine & _ "Driver Version: " & objItem.DriverVersion & vbNewLine & _ "--------------------------------------" & vbNewLine & _ "İşlemci Üreticisi: " & objProcessor.Manufacturer & vbNewLine & _ "İşlemci İsmi: " & objProcessor.Name & vbNewLine & _ "CPU Mimarisi: " & strArchitecture & vbNewLine & _ "İşlemci Çekirdek sayısı: " & oEnv("NUMBER_OF_PROCESSORS") & vbNewLine & _ "--------------------------------------" & vbNewLine & _ "Toplam RAM: " & TotalRam & " MB" & vbNewLine & _ "Toplam Slot: " & totalSlots & vbNewLine & _ "Boş Slot: " & (totalSlots - installedModules) & vbNewLine & _ "Ramlerin bulunduğu slotlar:" & vbcrlf & strMemory,0,"deneme" Next Next Next Next please help me , thanks.
    • JuanFelipe
      By JuanFelipe
       
      Hello friends, I have a query, it happens that I have a matrix nxn, the first column of this contains each cell a number with 21 digits, when I pass this matrix to Excel I obviously write that number as 1,10016E + 20, I solved it by adding a * at the end of each cell, but I want it to be written as a text so that I do not have to remove that *, I searched in Google but could not find an effective solution, thanks in advance. 
    • Puls3
      By Puls3
      Hi, This is my first post on the AutoIt Forums, I most of the time was able to get help from this community by merely searching though google and have been able to solve hundreds of problems this way, though in this case I was incapable of finding a solution to my problem. I am quite confident that it is a user error (And my fault) but I haven't been able to determine what I did wrong, any and all help would be greatly appreciated! I have uploaded my whole script pardon passwords to provide as much information as possible.
      I declared a global array at the top of the script and am having issues when I try to set it's value, and I fail to understand why.
      Error Message:
      "D:\Projects\AutoIt\Arena\Base.au3" (270) : ==> Subscript used on non-accessible variable.:
      $ExpMax[$i] = IniRead($TempSavePath, "Combatant" & $i, "ExpMax", $ExpMax[0])
      $ExpMax^ ERROR
      ConsoleWrite Log:
      Ran.
      Checking launch parameters.
      No launch parameters.
      Initiating load.
      Checking for save file.
      Save file not found.
      Load canceled.
      Loading or creating Combatant 1
      Base.au3
    • Blois
      By Blois
      Hi Guis,
       
      I need to create keyboard shortcut to navigate the tabs and activate them, but I could not use the code below:
      #include <TabConstants.au3> #include <WindowsConstants.au3> #include <GuiTab.au3> #include <GUIConstantsEx.au3> HotKeySet("^{TAB}", "_TabRight") HotKeySet("^+{TAB}", "_TabLeft") $gui = GUICreate("test",450, 300) $Tab1 = GUICtrlCreateTab(20, 24, 425, 201) $TabSheet1 = GUICtrlCreateTabItem("Tabsheet 1") $lbContagemGrupos2 = GUICtrlCreateLabel("aaaa", 50, 50) GUICtrlSetColor(-1, 0x0000FF) GUICtrlCreateTabItem("") $TabSheet2 = GUICtrlCreateTabItem(" ") $TabSheet3 = GUICtrlCreateTabItem(" ") GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func _TabRight() $CurPos = _GUICtrlTab_GetCurSel($Tab1) _GUICtrlTab_SetCurSel($Tab1, $CurPos + 1) $tab = "$TabSheet" & $CurPos GUICtrlSetState($TabSheet1 + $CurPos, $GUI_SHOW) Return EndFunc Func _TabLeft() $CurPos = _GUICtrlTab_GetCurSel($Tab1) _GUICtrlTab_SetCurSel($Tab1, $CurPos - 1) $tab = "$TabSheet" & $CurPos GUICtrlSetState($TabSheet1 + $CurPos, $GUI_SHOW) Return EndFunc Exit  
      can you help me?
    • RamDemon
      By RamDemon
      Hi,
      Did anyone tried to  use Redis  with AutoIT as store DB ?
       Redis <-- more about it
      Mladen
×