Jump to content

[SOLVED] some help with shellexecute!


Recommended Posts

Hi all!

Im trying to execute a program that are specified in a ini file like this but shellexecute ignore the @windowsdir or any @variable i put in, what im i doing wrong?

; Ini file
[Utforskaren]
exe= explorer.exe
arg= , C:
wrk= @WindowsDir
ico= @WindowsDir & "\explorer.exe"
dsc= Utforskaren

the execute is from an array like this

[3]|explorer.exe|, C:|@WindowsDir|@WindowsDir & "\explorer.exe"|Utforskaren

ShellExecute($aIcon[$iIconIndex][0], $aIcon[$iIconIndex][1], $aIcon[$iIconIndex][2])
ConsoleWrite("! Consolewrite ->Shellexecute: " & $aIcon[$iIconIndex][0] &" | "& $aIcon[$iIconIndex][1] &" | "& $aIcon[$iIconIndex][2] & @CRLF)

and result is this

! Consolewrite ->Shellexecute: explorer.exe | , C: | @WindowsDir

Edited by lgvlgv
Link to post
Share on other sites
  • Developers

Try this and see if that is what you want:

$t = '@WindowsDir & "explorer.exe"'
ConsoleWrite('$t = ' & $t & @crlf )
$t = Execute($t)
ConsoleWrite('$t = ' & $t & @crlf )

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites

not sure i understand i tried this

ConsoleWrite('$t = ' & $t & @crlf )
       local $t = $aIcon[$iIconIndex][2]
       ConsoleWrite('$t = ' & $t & @crlf )
       ShellExecute($aIcon[$iIconIndex][0], $aIcon[$iIconIndex][1], $t)
       ConsoleWrite("! Consolewrite ->Shellexecute: " & $aIcon[$iIconIndex][0] &" , "& $aIcon[$iIconIndex][1] &" , "& $t & @CRLF)

but still it reads the @windowsdir as @windowsdir and not like "C:windows" ?

Link to post
Share on other sites
  • Developers

It thing I was trying to make you understand is that putting @WindowsDir in a string doesn't mean that AutoIt3 will know about this.

The Execute() Function will take a literal string and assumes it contains something to Execute.

in your case, you are retrieving some AutoIt3 Macro's from a INI file, which will be stored in a variable as literal string. So perform an Execute() function on that String and you will find what you are looking for.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites

thx

It thing I was trying to make you understand is that putting @WindowsDir in a string doesn't mean that AutoIt3 will know about this.

The Execute() Function will take a literal string and assumes it contains something to Execute.

in your case, you are retrieving some AutoIt3 Macro's from a INI file, which will be stored in a variable as literal string. So perform an Execute() function on that String and you will find what you are looking for.

Jos

LOL, dident realize that execute was an actuall command ;)

Thank you very mutch for ur patience with me .

What is the best way to use execute or stringreplace? $aIcon[$i][2]=StringReplace($aIcon[$i][2],'@WindowsDir',@WindowsDir,0,2)

Regards L

Link to post
Share on other sites
  • Developers

Either way works and am not sure if there is a best way... just use the way you prefer and understand.

Jos ;)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By barkeeper
      Hi there,
      I made a script together with some great help from this community. What is does is, sit in the tray until ctrl+1 is pressed, it will ask for input (in this case a short word that contains a longer answer in the ini file it will paste, for example when answering outlook mails with default answers) now the list will become longer and longer, and learning the strings by head will get harder so I was looking into listing the search terms somewhere in the program but can't really find code to borrow for it on these forums. I was wondering if anyone here would be able to help me with it. What I'm looking for is some "bar" attached to the search bar, or some pulldown menu that lists the options that would be the most convenient view. I've attached my script here.
      #include <Misc.au3> HotKeySet("^1", "search") $zoek = "" ; if its going to be a string, its good practice to declare it as a string While 1 Sleep(1) WEnd Func _test() Local $sIni = @ScriptDir & "\antwoorden.ini" Local $sAnswer = "" $sAnswer = IniRead($sIni, "answers", $zoek, "Sorry No answer available") If StringInStr($sAnswer,"<enter>") Then $aAnswer = StringSplit($sAnswer,"<enter>",1) ; 1 = entire delimiter string is needed to mark the split $sAnswer = "" For $i = 1 To $aAnswer[0] $sAnswer &= $aAnswer[$i] & @CR Next EndIf _Sendex ($sAnswer) $zoek = "" ;Reset string EndFunc ;==>_test Func search() $zoek &= InputBox("Zoeken", "Zoekterm:") _test() EndFunc ;==>search Func _SendEx($ss) Local $iT = TimerInit() While _IsPressed("10") Or _IsPressed("11") Or _IsPressed("12") If TimerDiff($iT) > 2000 Then MsgBox(262144, "Warning", "Shift, Ctrl and Alt keys need to be released to proceed!") $iT = TimerInit() ; reset the timer EndIf WEnd Send($ss) $zoek = "" ;Reset string EndFunc ;==>_SendEx [answers] password=answer rule 1<enter>rule 2 abuse=answer rule 1<enter>rule 2 VPN=answer rule 1<enter>rule 2<enter>rule 3  
      antwoorden.au3 antwoorden.ini
    • By Jibsbrown
      Need some help understanding why the ConsoleWrite works inside 2nd For loop but not out side. Between Audit Wiki, Help file , Forum searching (lots of code reading), and YouTube ( shout out to TutsTeach), I have not been able to find the reason why. 
      $sIniPath = "installLog.ini" ; - Get section name $iniSctionNames = IniReadSectionNames($sIniPath) ; - Get Keys and Vaules For $a = 1 to UBound($iniSctionNames) - 1 $keys = IniReadSection($sIniPath , $iniSctionNames[$a]) For $b = 1 to UBound($keys) - 1 $oldSysInfo = IniRead($sIniPath , $iniSctionNames[1], $keys[$b][0], "") $PntIPInfo = IniRead($sIniPath , $iniSctionNames[2], $keys[$b][0], "") $NewPCInfor = IniRead($sIniPath , $iniSctionNames[3], $keys[$b][0], "") ;ConsoleWrite($oldSysInfo & @LF) Next ;ConsoleWrite($oldSysInfo & @LF) Next ConsoleWrite($oldSysInfo) My intention is to use the variables later for Listboxes. Any explanation, forum post links or whatever would help. Sorry also very very new to Autoit.
      Also here's the ini file.
      [OldSysInfo] 4=192.168.0.4|DESKTOP-RDIU2SN|R90M05Q8 5=192.168.0.5|SD0123456789101|R9WGP9P 6=192.168.0.6|SD0123456789102|R9WGP9PT 3=192.168.0.3|DESKTOP-3RS4LKL|R9WGP9P 23=192.168.0.23|SD0123456789102|MXL1234P5I [PrinterIp] 50=192.168.0.50 48=192.168.0.48 47=192.168.0.47 [NewSysInfo] newPC = SD0123456789adfs|192.168.0.185|2UA1234FTR Thank you for your time.
    • By DagSa
      I have some problem to make my ini-file work properly. Purpose is to install program at windows 7 - 10 but think it work at XP also.
       I have included a fragment of code, but all my errors are there. It should be run by user privilege.
      The test code point out what is not working:
      Code is create a directory in %appdata%, and create a ini-file if not there. (This write of file work!)
      When change the settings only one of the two parameters are changed. One value should be changed (don't work), and the other should be added (work!). Editing manually by notepad does not allow to save it.  I want the code to be able to change everything in ini-file.
      1. First of all, the ini-file is not writeable by user when look at file properties and also directory properties. Any way to change this?
      2. Is %appdata% wrong directory? I want all user to have access to the settings but its enough if only by control of the program.
      It make me crazy its writeable sometimes, and sometimes not. Any ideas?
      /Dag
      AppData_INI-test.au3
    • By l3ill
      Hi All,
      Here is a little GUI I built a while back to learn how to use INI files to store information ( variables ) between opening and closing certain programs.
      I just recently pulled it back out and cleaned it up and debugged it, if you find any bugs please kill them.
      The FTP connection part was just so it would have purpose... 
      To cut down on clutter there are no labels, hover mouse over to see what things are.
      cya,
      Bill
    • By akira2891
      Hi i have problem with reading data from INI file.
      So i need when i put in search field "Test" to get in listbox all results under number 1= with "Test" in name and so my list need to look like this
      [5018] Test name 2 [5218] Test name 1 [5458] Test nameand when i click on item from list that he appears on $hNameInput
      Look on image http://prntscr.com/83i7a6
      this is my ini file
      [5018] 0=test1 1=Test name 2 2=0 3=1 [5218] 0=test1 1=Test name 1 2=0 3=1 [5458] 0=test1 1=Test name 2=0 3=1 [5468] 0=test1 1=Name no 1 2=0 3=1 [5345] 0=test1 1=Name no 2 2=0 3=1And here is autoit code
      #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=C:\Users\Mario\Documents\renamer.kxf $hGUI = GUICreate("Form1", 684, 364, 607, 439) GUICtrlCreateGroup(" Search ", 8, 16, 342, 297) GUICtrlCreateLabel("Search for text", 22, 40, 73, 17) $hSearchInput = GUICtrlCreateInput("", 23, 60, 185, 21) $hFinddAllButton = GUICtrlCreateButton("Find All", 222, 58, 75, 25) GUICtrlCreateLabel("Found Items ( click to edit )", 22, 102, 131, 17) $hList = GUICtrlCreateList("", 22, 120, 313, 175) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup(" Edit Item", 355, 16, 321, 137) GUICtrlCreateLabel("Name", 372, 40, 32, 17) $hNameInput = GUICtrlCreateInput("", 371, 60, 289, 21) $hSaveButton = GUICtrlCreateButton("Save", 587, 112, 75, 25) GUICtrlCreateLabel("Item ID", 372, 95, 38, 17) $hItemID = GUICtrlCreateInput("", 369, 112, 57, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$ES_READONLY)) GUICtrlCreateGroup("", -99, -99, 1, 1) $hOpenIniButton = GUICtrlCreateButton("Open INI for Edit", 8, 328, 105, 25) $hWriteIniButton = GUICtrlCreateButton("Write Modified INI", 123, 328, 105, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $file While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $hOpenIniButton __openINI() Case $hFinddAllButton Local $iFileExists = FileExists($file) If Not $iFileExists Then MsgBox(48, "Error", "test.ini not found!") EndIf Local $aArray = IniReadSection($file, "5018") If Not @error Then For $i = 1 To $aArray[0][0] GUICtrlSetData($hList, $aArray[$i][1] & @CRLF) Next EndIf EndSwitch WEnd ; open ini Func __openINI() Global $file = FileOpenDialog("Open INI for edit", "", "INI files (*.ini)") If FileExists($file) Then $sFile = FileOpen($file) If @error Then MsgBox(48, "Error", "Error = " & @error & ", Extended = " & @extended) Else GUICtrlSetState($hOpenIniButton, $GUI_DISABLE) EndIf Else MsgBox(48, "Error", "Error = " & @error & ", Extended = " & @extended) EndIf EndFunc 
×
×
  • Create New...