Sign in to follow this  
Followers 0
Shifty88

Opening a File

9 posts in this topic

Sorry if this is elementary, extremely new to AutoIT. I am trying to open a saved file without opening a new window… To be more clear, I have my program window open and when I use:

ShellExecute("Vblock_Setup.LAZ", "", "E:\CARBIDE LASER\AutoIT", "open", @SW_MAXIMIZE)

It opens a complete new window instead of opening the file within my current one. Suggestions?

FYI, I have permision from the program owners (TJSLaser) to auotomate this software.


Year 1882Friedrich Nietzsche : "God is Dead"Year (1900-08-25)God : Nietzsche is Dead

Share this post


Link to post
Share on other sites



Take a look at FileOpen and FileRead. You can then replace the existing data with the data read from file in your GUI.


[center]Spiderskank Spiderskank[/center]GetOpt Parse command line options UDF | AU3Text Program internationalization UDF | Identicon visual hash UDF

Share this post


Link to post
Share on other sites

I thought FileOpen was only good for text files? This one is saved in binary.


Year 1882Friedrich Nietzsche : "God is Dead"Year (1900-08-25)God : Nietzsche is Dead

Share this post


Link to post
Share on other sites

Read the description, hint: mode parameter ;)


[center]Spiderskank Spiderskank[/center]GetOpt Parse command line options UDF | AU3Text Program internationalization UDF | Identicon visual hash UDF

Share this post


Link to post
Share on other sites
Again I’m sorry for the elementary questions. I'm running a mouse coordinate script right after I open the file and when I use FileOpen I’m not seeing the file regardless of what mode parameter I use.

Year 1882Friedrich Nietzsche : "God is Dead"Year (1900-08-25)God : Nietzsche is Dead

Share this post


Link to post
Share on other sites

Hey don't apologize, nobody's learned to fish without losing his net atleast once.

Local $hFileHandle = FileOpen("filename.txt", 16) ; 16 means open in binary read mode.
MsgBox(0, 'Filehandle', $hFileHandle) ; Anything but -1.
Local $bContent = FileRead($hFileHandle) ; No count means get the entire file contents.
MsgBox(0, 'Binary length', BinaryLen($bContent)) ; Anything but 0.

Now $bContents should contain the binary data of the file. This is not a string! Probably there are NUL characters in there and that is why it fails to display. Use BinaryToString on it first.

Also, what code are you using to 'see this file'?


[center]Spiderskank Spiderskank[/center]GetOpt Parse command line options UDF | AU3Text Program internationalization UDF | Identicon visual hash UDF

Share this post


Link to post
Share on other sites

Ive cut most of the bottom off of my code but this should be enough for you to understand what im trying to do. You will see where the ShellExecute comand is being used, thats the only way I knew of how to open the file. To explain further, this method works I just end up having to close the Prolase Window after each run of the script, or I keep stacking them on my task bar (not prefered).

I hope this is the proper way to post code, not sure which button to use...

; Script Start -
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include <File.au3>
#Include <Array.au3>
#include <Process.au3>
#include <Date.au3>
Func _WinWaitActivate($title,$text,$timeout=0)
WinWait($title,$text,$timeout)
If Not WinActive($title,$text) Then WinActivate($title,$text)
WinWaitActive($title,$text,$timeout)
EndFunc
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=e:carbide laserautoitlaser setup.kxf
$Form1_1 = GUICreate("Laser Information", 212, 396, 190, 109)
$Pic1 = GUICtrlCreatePic("C:Documents and SettingsLaserDesktopATI Logo.jpg", 0, 0, 209, 57)
$Laser = GUICtrlCreateButton("Laser", 0, 352, 105, 41)
$Cancel = GUICtrlCreateButton("Cancel", 104, 352, 105, 41)
$Group1 = GUICtrlCreateGroup("Tray Styles", 0, 64, 209, 65, BitOR($GUI_SS_DEFAULT_GROUP,$BS_CENTER))
$Radio1 = GUICtrlCreateRadio("Vblock", 8, 80, 89, 41, BitOR($GUI_SS_DEFAULT_RADIO,$BS_PUSHLIKE))
$Radio2 = GUICtrlCreateRadio("MFP TRAY", 104, 80, 97, 41, BitOR($GUI_SS_DEFAULT_RADIO,$BS_PUSHLIKE))
GUICtrlCreateGroup("", -99, -99, 1, 1)
$GrpVblock = GUICtrlCreateGroup("Vblock", 0, 136, 209, 217, BitOR($GUI_SS_DEFAULT_GROUP,$BS_CENTER))
$Zheight = GUICtrlCreateInput("Zheight", 88, 152, 113, 21)
$Xpos = GUICtrlCreateInput("-7.25", 88, 216, 113, 21)
$Text_Height = GUICtrlCreateInput("Textheight", 88, 280, 113, 21)
$Text_Rotation = GUICtrlCreateInput("TextRotation", 88, 312, 113, 21)
$Yinc = GUICtrlCreateInput("Thickness", 88, 184, 113, 21)
$Ypos = GUICtrlCreateInput("8.8047", 88, 248, 113, 21)
$Label1 = GUICtrlCreateLabel("Z Height :", 32, 152, 51, 17)
$Label2 = GUICtrlCreateLabel("10 Piece avg. :", 8, 184, 76, 17)
$Label3 = GUICtrlCreateLabel("X position :", 32, 216, 56, 17)
$Label4 = GUICtrlCreateLabel("Y position :", 32, 248, 56, 17)
$Label5 = GUICtrlCreateLabel("Text Height :", 24, 280, 65, 17)
$Label6 = GUICtrlCreateLabel("Text Rotation :", 16, 312, 74, 17)
Controlhide("Laser Information", "", $GrpVblock)
  Controlhide("Laser Information", "", $Text_Rotation)
  Controlhide("Laser Information", "", $Zheight)
  Controlhide("Laser Information", "", $Xpos)
  Controlhide("Laser Information", "", $Text_Height)
  Controlhide("Laser Information", "", $Yinc)
  Controlhide("Laser Information", "", $Ypos)
  Controlhide("Laser Information", "", $Label1)
  Controlhide("Laser Information", "", $Label2)
  Controlhide("Laser Information", "", $Label3)
  Controlhide("Laser Information", "", $Label4)
  Controlhide("Laser Information", "", $Label5)
  Controlhide("Laser Information", "", $Label6)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$GrpManz = GUICtrlCreateGroup("Manz Trays", 0, 136, 209, 209, BitOR($GUI_SS_DEFAULT_GROUP,$BS_CENTER))
$MFPTRAY = GUICtrlCreateInput("TrayStyle", 80, 160, 121, 21)
$Yinc1 = GUICtrlCreateInput("Yinc" , 80, 280, 121, 21)
$Xinc1 = GUICtrlCreateInput("Xinc" , 80, 256, 121, 21)
$Ypos1 = GUICtrlCreateInput("Ypos" , 80, 232, 121, 21)
$Xpos1 = GUICtrlCreateInput("Xpos" , 80, 208, 121, 21)
$Zheight1 = GUICtrlCreateInput("Zheight", 80, 184, 121, 21)
$TextHeight = GUICtrlCreateInput("Text Height", 80, 304, 121, 21)
$Rotation = GUICtrlCreateInput("Rotation", 80, 328, 121, 21)
$Label7 = GUICtrlCreateLabel("Text Rotation :", 8, 328, 74, 17)
$Label8 = GUICtrlCreateLabel("Text Height :", 16, 304, 65, 17)
$Label9 = GUICtrlCreateLabel("Z Height :", 32, 184, 51, 17)
$Label10 = GUICtrlCreateLabel("X position :", 24, 208, 56, 17)
$Label11 = GUICtrlCreateLabel("Y position :", 24, 232, 56, 17)
$Label12 = GUICtrlCreateLabel("Tray Style :", 24, 160, 57, 17)
$Label13 = GUICtrlCreateLabel("X inc :", 48, 256, 34, 17)
$Label14 = GUICtrlCreateLabel("Y inc :", 48, 280, 34, 17)
Controlhide("Laser Information", "", $GrpManz)
  Controlhide("Laser Information", "", $Rotation)
  Controlhide("Laser Information", "", $Zheight1)
  Controlhide("Laser Information", "", $Xpos1)
  ControlHide("Laser Information", "", $Ypos1)
  Controlhide("Laser Information", "", $TextHeight)
  Controlhide("Laser Information", "", $Xinc1)
  Controlhide("Laser Information", "", $Yinc1)
  Controlhide("Laser Information", "", $MFPTRAY)
  Controlhide("Laser Information", "", $Label7)
  Controlhide("Laser Information", "", $Label8)
  Controlhide("Laser Information", "", $Label9)
  Controlhide("Laser Information", "", $Label10)
  Controlhide("Laser Information", "", $Label11)
  Controlhide("Laser Information", "", $Label12)
  Controlhide("Laser Information", "", $Label13)
  Controlhide("Laser Information", "", $Label14)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
;GUICtrlSetOnEvent($Laser,"Laser")
GUICtrlSetOnEvent($Cancel,"Canc")
While 1
$nMsg = GUIGetMsg()
  If GUICtrlRead($Radio1) =  $GUI_CHECKED Then
  ControlShow("Laser Information", "", $GrpVblock)
  ControlShow("Laser Information", "", $Text_Rotation)
  ControlShow("Laser Information", "", $Zheight)
  ControlShow("Laser Information", "", $Xpos)
  ControlShow("Laser Information", "", $Text_Height)
  ControlShow("Laser Information", "", $Yinc)
  ControlShow("Laser Information", "", $Ypos)
  ControlShow("Laser Information", "", $Label1)
  ControlShow("Laser Information", "", $Label2)
  ControlShow("Laser Information", "", $Label3)
  ControlShow("Laser Information", "", $Label4)
  ControlShow("Laser Information", "", $Label5)
  ControlShow("Laser Information", "", $Label6)
  Else
  Controlhide("Laser Information", "", $GrpVblock)
  Controlhide("Laser Information", "", $Text_Rotation)
  Controlhide("Laser Information", "", $Zheight)
  Controlhide("Laser Information", "", $Xpos)
  Controlhide("Laser Information", "", $Text_Height)
  Controlhide("Laser Information", "", $Yinc)
  Controlhide("Laser Information", "", $Ypos)
  Controlhide("Laser Information", "", $Label1)
  Controlhide("Laser Information", "", $Label2)
  Controlhide("Laser Information", "", $Label3)
  Controlhide("Laser Information", "", $Label4)
  Controlhide("Laser Information", "", $Label5)
  Controlhide("Laser Information", "", $Label6)
EndIf
If GUICtrlRead($Radio2) =  $GUI_CHECKED Then
  ControlShow("Laser Information", "", $GrpManz)
  ControlShow("Laser Information", "", $Rotation)
  ControlShow("Laser Information", "", $Zheight1)
  ControlShow("Laser Information", "", $Xpos1)
  ControlShow("Laser Information", "", $Ypos1)
  ControlShow("Laser Information", "", $TextHeight)
  ControlShow("Laser Information", "", $Xinc1)
  ControlShow("Laser Information", "", $Yinc1)
  ControlShow("Laser Information", "", $MFPTRAY)
  ControlShow("Laser Information", "", $Label7)
  ControlShow("Laser Information", "", $Label8)
  ControlShow("Laser Information", "", $Label9)
  ControlShow("Laser Information", "", $Label10)
  ControlShow("Laser Information", "", $Label11)
  ControlShow("Laser Information", "", $Label12)
  ControlShow("Laser Information", "", $Label13)
  ControlShow("Laser Information", "", $Label14)
  Else
  Controlhide("Laser Information", "", $GrpManz)
  Controlhide("Laser Information", "", $Rotation)
  Controlhide("Laser Information", "", $Zheight1)
  Controlhide("Laser Information", "", $Xpos1)
  ControlHide("Laser Information", "", $Ypos1)
  Controlhide("Laser Information", "", $TextHeight)
  Controlhide("Laser Information", "", $MFPTRAY)
  Controlhide("Laser Information", "", $Xinc1)
  Controlhide("Laser Information", "", $Yinc1)
  Controlhide("Laser Information", "", $Label7)
  Controlhide("Laser Information", "", $Label8)
  Controlhide("Laser Information", "", $Label9)
  Controlhide("Laser Information", "", $Label10)
  Controlhide("Laser Information", "", $Label11)
  Controlhide("Laser Information", "", $Label12)
  Controlhide("Laser Information", "", $Label13)
  Controlhide("Laser Information", "", $Label14)
EndIf
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
EndSwitch
WEnd
;Cancel form
Func Canc()
Exit
EndFunc
Func Laser()
Select
  Case GUICtrlRead($radio1) = $GUI_CHECKED
   ShellExecute("Vblock_Setup.LAZ", "", "C:Documents and SettingsLaserDesktop", "open", @SW_MAXIMIZE)
   #region --- Equations and constants ----
   Local $begin = TimerInit()
   Local const $Xinc = 1.5
   Local $Yinc11 = -$Yinc
   ;Local $YPos1 = ( 9.1049 - $Yinc )
   Local $Xpos22 = ( $Xpos + ( 3 * $Xinc ) )
   Local $Xpos33 = ( $Xpos22 + ( 3 * $Xinc ) )
   Local $Xpos44 = ( $Xpos33 + ( 3 * $Xinc ) )
   Local $X_Array1 = 3
   Local $X_Array2 = 2
   Local $Y_Array = Floor( 4.75/$Yinc)
   Local $Ypos22 = ($Ypos - ( $Yinc * $Y_array))
   #endregion
   #region ---Au3Recorder generated code Start (v3.3.7.0)  ---
BlockInput(1)
#region --- Internal functions Au3Recorder Start ---
Opt('WinWaitDelay',100)
Opt('WinDetectHiddenText',1)
Opt('MouseCoordMode',0)
Opt("SendKeyDelay", 100)
#endregion --- Internal functions Au3Recorder End ---
_WinWaitActivate("ProLase7 Server Plus - [Vblock_Setup.LAZ]","Layer / Object Layou")
MouseClick("right",1182,255,1)
Send("{UP}{ENTER}")
_WinWaitActivate("Layer 1 Properties","") ;LAYER 1 STARTS HERE
MouseClick("left",38,39,1)
_WinWaitActivate("Layer 1 Properties","Active:    Items wil")
MouseClick("left",36,138,1)
MouseClick("left",251,38,1)
_WinWaitActivate("Layer 1 Properties","Correct projection d")
Mouseclick("left",100,452,2)
Send($Zheight) ; Z height goes here
MouseClick("left",190,41,1)
_WinWaitActivate("Layer 1 Properties","Layer Control Sequen")
MouseClick("Left",283,209,2)
Send($X_Array1)
Send("{TAB}")
Send($Y_Array)
Send("{TAB}")
Send($Xinc)
Send("{TAB}")
Send($Yinc11)
MouseClick("left",278,710,1)
_WinWaitActivate("ProLase7 Server Plus - [Vblock_Setup.LAZ]","Layer / Object Layou")
MouseClick("right",1194,274,1)
Send("{UP}{ENTER}")
_WinWaitActivate("Properties :Variable Text 1","Orientation / Sizing")
Send($Xpos)
Send("{TAB}")
Send($Ypos)
Send("{TAB}")
send($Text_Rotation)
MouseClick("Left",371,312,2)
Send($Text_Height) ; Text Height goes here.
MouseClick("left",467,615,1)
EndSelect

; There is about 700 more lines but i figured this would be a good enough example.

Year 1882Friedrich Nietzsche : "God is Dead"Year (1900-08-25)God : Nietzsche is Dead

Share this post


Link to post
Share on other sites

After further research I think I understand why this isnt working for me. Is the ShellExecute command equivalent to a double click on a desktop saved file?


Year 1882Friedrich Nietzsche : "God is Dead"Year (1900-08-25)God : Nietzsche is Dead

Share this post


Link to post
Share on other sites

Please refer to the help file in the future as it's clear what ShellExecute is. To answer your question ShellExecute is useful for opening a file or folder with the assigned application, e.g. opening a text document (.txt) will 9/10 open with notepad.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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: 04/09/2015

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
Sign in to follow this  
Followers 0