Hi all, I am writing some scripts to control some lab equipment, and sometimes I observe that the script "misses" one of the steps, leading to cascading errors. For example, at one part of the code I wrote this:
Most of the times this works, but I found that in some occasions the windows fail to close. Then, the code becomes a mess, because a second instance of the program will launch, and both windows now have the same title. I think I can solve this problem with this code:
I would like to know if anybody has any other suggestions for this kind of redundant code. Thanks,
I'm having some trouble restoring a program which uses a normal AutoIT-GUI and is used as a ToolKit for our customers to open different (external) tools, check their network connections or ping different destinations. Almost all customers are running this script on Win7 x64.
What do I want to do?
When the program is already running and the user tries to start it for a second time, it should exit the second instance after activating/restoring the first instance.
What did I do to integrate this?
I used a little piece of script found on the forums to prevent opening a second instance and modified it as follows:
$g_szVersion = "VSOL ToolKit" If WinExists($g_szVersion) Then Local $gState = WinGetState($g_szVersion) MsgBox(0,"","gState = " & $gState) ;For debugging purposes WinSetState($g_szVersion,"",@SW_SHOW) MsgBox(0,"","gState = " & $gState) ;For debugging purposes WinSetState($g_szVersion,"",@SW_RESTORE) MsgBox(0,"","gState = " & $gState) ;For debugging purposes WinActivate($g_szVersion) Exit EndIf AutoItWinSetTitle($g_szVersion) I have tried it with only the @SW_SHOW, only the @SW_RESTORE, both of them in a different order, same difference, it doesn't work.
What does happen then?
It detects the current state (when it's minimized) as '5', which means enabled and hidden. After setting the state to show, the state changes to 7. Restoring doesn't change the state. But what is really odd, is that the window doesn't appear but AutoIt seems to create a néw window with the same title as the existing one.
It doesn't matter if the window was originally minimized by clicking the minimize button in the GUI or by a line of code in my script. For example, when users open a software package from within my script, a similar function to this one will be called:
Func VSOL_FFTOOLS_SHOW_DOWNLOADS() GUISetState(@SW_MINIMIZE,$VSOL_BACKEND) ShellExecute(@UserProfileDir & "\Downloads") EndFunc The only thing that does work, is when the window is running in a non-minimized state (somewhere behind the current window), it gets activated and receives the focus when trying to start the second instance.
If anyone could help me out with this one, I'd be forever thankful :-)
Thanks in advance!
Is it possible , and how can I read and write txt files from Icloud (apple service) ?
Let me try to explain my application.
On my Ipad and Iphone I create txt files. On my windows computer it is possible to read and modify these files manually, by logging in on www.icloud.com.
What I want to make is an auto-it script who reads the txt file and create an new txt file on www.icloud.com, so I can acces these on my ipad and/or phone.
This code will read text data from txt file. However, if I use '$Newtext &= $convert' then $convert is saved as strings, not hex value.
For example, if $convert = 0x300020FF and $bNewText = Test then the result is 0x333030303230464654657374. (Wrong)
What I want is 0x300020FF54657374. How can I modify my script?
For $i = $y-1 To Ubound($split) - 1 $convert = "0x" & $split[$i] $Newtext &= $convert $NewLen_hex = BinaryLen ($convert) $i=$i+1 $split[$i] = $split[$i] $split[$i] = StringRegExpReplace($split[$i], "<cf>", @CRLF) $split[$i] = StringRegExpReplace($split[$i], "<lf>", @LF) $split[$i] = StringRegExpReplace($split[$i], "<cr>", @CR) $bNewText = _WinAPI_WideCharToMultiByte($split[$i], $CP_SHIFT_JIS) if $i = Ubound($split) - 1 Then $bNewText &= Chr(0) EndIf $Newtext &= $bNewText $NewLen = $NewLen_hex + BinaryLen ($bNewText) Next (...) (...) $Newfile = BinaryMid($Newfile_header,1) & BinaryMid($Newtext,1) $hNewfile = FileOpen ("NEW_"&$Name, 2+16) FileWrite ($hNewfile, $Newfile) FileClose ($hNewfile) TrayTip ("Importer", "Finish!", 3) sleep (3000)
I have searched and found many posts on READING CSV. What I need to do is WRITE CSV.
Typically I have a Listview, I use @guinness's excellent _GUICtrlListView_CreateArray to read that LV to Array. Currently I use _FileWriteFromArray to write the output. It is fast and it is easy.
The benefits of using these Array functions are their inherit flexibility. The code is portable. Plug it into LV report and you can write to file instantly. No formatting issues.
To be sure, my problem is not with the Listview or Array. My problem is with the file write to CSV: it should be fast, accurate and efficient.
Part of the problem is Microsoft Excel's insistence that my CSVs are not what they appear to be...
I am inspired by the simplicity of SQLITE3.EXE's dot command options:
.headers on .mode csv .once output.csv
Problem is that I want to export the text packed in characters, such as ' " ' with fields delimited by another character, such as ' , '.
Current method using _FileWriteFromArray outputs data like this
12-04-2016| 0.00| 131.00|131|Description 12-04-2016| 0.00| 132.00|132|Description 132 rece 12-04-2016| 998.00| 0.00|998|Description Receipt 12-04-2016| 0.00| 900.00|900|Description What I want to achieve is this:
"12-04-2016"," 0.00"," 131.00","131","Description" "12-04-2016"," 0.00"," 132.00","132","Description 132 rece" "12-04-2016"," 998.00"," 0.00","998","Description Receipt" "12-04-2016"," 0.00"," 900.00","900","Description" I have done this. The long way. I have written the output one $aResult[$i] item at a time, spaced with the $text & $field markers. I have placed this in an array with additional columns just to fit in the formatting. I have also played with the idea of inserting the array into a sqlite db, then run sqlite3's dot commands on that.
Is there a different method? Is there an efficient method to specify FileWriteFromArraytoCSV? Does anyone have ideas? I am sure I will know how to code this, I just need advice on the most efficient way of going about it. If I missed any threads, please enlighten me.
Thanks for reading