作者: Fred Wang (FW知識瑣記) 日期: 2013/1/2
根據TIOBE,在2012/4月以前Java保持約七年的第一名寶座,在該月被C語言擠下,到2012/12月C仍保持第一的優勢
雖然C, C++與Java市佔率也有上升,但更令人矚目的是2009年才崛起的Objective C在Apple的加持下短短三年半一路攀升到第三名,寫下程式語言的傳奇!
2012/1 (1) Java 17.48% (2) C 16.98% (3) C# 8.78%
2012/2 (1) Java 17.05% (2) C 16.52% (3) C# 8.65%
2012/3 (1) Java 17.11% (2) C 17.09% (3) C# 8.24%
2012/4 (1) C 17.56% (2) Java 17.03% (3) C++ 8.90%
...
2012/12(1) C 18.70% (2) Java 18.57% (3) Objective-C 11.12% (4) C++ 9.2% (5) C# 5.55%
C#在2012/4月落後C++之後,持續下滑,到2012/12月僅剩5.55%,排名第五
如果引用或轉貼,麻煩註明出處與本網誌連結,否則視為侵權。
2013年1月2日
2012年8月29日
AutoIT程式如何處理跳出式對話窗(popup dialog)
作者: Fred Wang (FW知識瑣記) 日期: 2012/8/29
AutoIT模擬Windows操作常發生跳出式對話窗(popup dialog)的處理,我整理了一個處理模式的範例,供大家參考
AutoIT模擬Windows操作常發生跳出式對話窗(popup dialog)的處理,我整理了一個處理模式的範例,供大家參考
Local $strTitle = "==title==" ; 要偵測的跳出對話窗的window title
If WinWait($strTitle,"",3) <> 0 Then ; 等待該對話窗出現(最多三秒)
WinActivate($strTitle) ; 將該對話窗變成最上層的active window
WinWaitActive($strTitle,"",3) ; 等待它變成active(最多三秒),才往下執行
SendKeepActive($strTitle) ; 在模擬鍵盤動作Send()過程,保持此對話窗為active,避免干擾
If WinActive($strTitle) Then
Send("{ENTER}") ; 送出鍵盤動作(依每個對話窗按鈕,有所不同)
... ; 或對話窗特有的動作
EndIf
WinWaitClose($strTitle,"",3) ; 等待該對話窗關閉(最多三秒),,才往下執行
EndIf
Labels:
AutoIT
2012年8月28日
AutoIT程式怎樣讀取MS Word檔案中的表格內容
作者: Fred Wang (FW知識瑣記) 日期: 2012/8/28
在AutoIT論壇中找到一篇非常好的範例, 將word中的表格讀入array中
http://www.autoitscript.com/forum/topic/94390-wordau3-how-to-read-a-table-into-a-variable/
其中網友big_daddy(Bob Anthony)寫的
稍加改寫前面幾行, 測試OK! 如下
#include <word.au3>
#include <array.au3>
在AutoIT論壇中找到一篇非常好的範例, 將word中的表格讀入array中
http://www.autoitscript.com/forum/topic/94390-wordau3-how-to-read-a-table-into-a-variable/
其中網友big_daddy(Bob Anthony)寫的
稍加改寫前面幾行, 測試OK! 如下
#include <word.au3>
#include <array.au3>
#AutoIt3Wrapper_Au3Check_Parameters = -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
Global $oWordApp, $oDoc, $oTable, $aTable
Global $fileName = FileOpenDialog("Please select a file.", @ScriptDir & "\", "Images (*.doc;*.docx)", 1 + 4)
If @error Then
MsgBox(4096, "", "No File(s) chosen")
Else
$fileName = StringReplace($fileName, "|", @CRLF)
EndIf
ConsoleWrite($fileName & @LF)
Global $nthOfTable = InputBox("Pasring Word Doc","Which table will you get(1,2,3...)")
if FileExists($fileName) Then
_WordErrorHandlerRegister()
$oWordApp = _WordCreate($fileName, 1, 0)
$oDoc = _WordDocGetCollection($oWordApp, 0)
$oTable = $oDoc.Tables($nthOfTable)
$aTable = _WordDocTableWriteToArray($oTable, True)
_ArrayDisplay($aTable)
_WordDocClose($oDoc)
_WordQuit($oWordApp)
Else
MsgBox( 1 ,"Message", $fileName & " Not Found!" )
Endif
; #FUNCTION# ;===============================================================================
;
; Name...........: _WordDocTableWriteToArray()
; Description ...: Reads the contents of a Table into an array
; Syntax.........: _WordDocTableWriteToArray(ByRef $o_object, $f_transpose = False)
; Parameters ....: $o_object - Object variable of a Word.Application, Table object
; $f_transpose - Boolean value. If True, swap rows and columns in output array
; Return values .: Success - Returns a 2-dimensional array containing the contents of the Table
; Failure - Returns 0 and sets @ERROR
; |0 ($_WordStatus_Success) = No Error
; |3 ($_WordStatus_InvalidDataType) = Invalid Data Type
; |4 ($_WordStatus_InvalidObjectType) = Invalid Object Type
; @Extended - Contains invalid parameter number
; Author ........: Bob Anthony (big_daddy)
; Modified.......:
; Remarks .......:
;
; ;==========================================================================================
Func _WordDocTableWriteToArray(ByRef $o_object, $f_transpose = False)
If Not IsObj($o_object) Then
__WordErrorNotify("Error", "_WordDocTableWriteToArray", "$_WordStatus_InvalidDataType")
SetError($_WordStatus_InvalidDataType, 1)
Return 0
EndIf
;
;~ If Not __WordIsObjType($o_object, "table") Then
;~ __WordErrorNotify("Error", "_WordDocTableWriteToArray", "$_WordStatus_InvalidObjectType")
;~ SetError($_WordStatus_InvalidObjectType, 1)
;~ Return 0
;~ EndIf
;
Local $i_cols, $trs, $tr, $tds, $i_rows, $col, $row
$tds = $o_object.columns
$trs = $o_object.rows
$i_cols = $tds.count
$i_rows = $trs.count
Local $a_TableCells[$i_cols][$i_rows]
$row = 0
For $tr In $trs
$tds = $tr.cells
$col = 0
For $td In $tds
$a_TableCells[$col][$row] = StringReplace(StringStripCR($td.Range.Text), Chr(7), "")
$col += 1
Next
$row += 1
Next
If $f_transpose Then
Local $i_d1 = UBound($a_TableCells, 1), $i_d2 = UBound($a_TableCells, 2), $aTmp[$i_d2][$i_d1]
For $i = 0 To $i_d2 - 1
For $j = 0 To $i_d1 - 1
$aTmp[$i][$j] = $a_TableCells[$j][$i]
Next
Next
$a_TableCells = $aTmp
EndIf
SetError($_WordStatus_Success)
Return $a_TableCells
EndFunc ;==>_WordDocTableWriteToArray
Labels:
AutoIT
AutoIT程式怎樣讀取MS Word檔案的內容
作者: Fred Wang (FW知識瑣記) 日期: 2012/8/28
今天又開始寫AutoIT程式, 想要自動讀取,解析出MS Word檔案的內容, 網路上找的sample program is not work! 因此自己改寫, 測試成功, 可以提供網友參考!
採用AutoIT UDF word.au3
今天又開始寫AutoIT程式, 想要自動讀取,解析出MS Word檔案的內容, 網路上找的sample program is not work! 因此自己改寫, 測試成功, 可以提供網友參考!
採用AutoIT UDF word.au3
#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.8.1 Author: Fred Wang (FW知識瑣記 http://fredwang.blogspot.tw ) Script Function: Read MS Word's content using AutoIT UDF Date : 2012/8/28 #ce ----------------------------------------------------------------------------#include <word.au3>
Global $fileName = FileOpenDialog("Please select a file.", @ScriptDir & "\", "Images (*.doc;*.docx)", 1 + 4)
If @error Then
MsgBox(4096, "", "No File(s) chosen")
Else
$fileName = StringReplace($fileName, "|", @CRLF)
EndIf
if FileExists($fileName) Then
$textOfWord = readWordDoc($fileName) ; Show the text from the document
MsgBox( 1 ," The Content is : ", $textOfWord )
Else
MsgBox( 1 ,"Message", $fileName & " Not Found!" )
Endif
Func readWordDoc($fileName)
Local $oWordApp = _WordCreate($fileName,1,0)
Local $oWordDocument = _WordDocGetCollection($oWordApp, 0)
Local $oWordContent = $oWorddocument.Content ; Ask to Receive the Contents Object of the Object Document
Local $TextDoc = $oWordContent.Text ; Ask to Extract the Text of the Contents Object in an AutoIt Variant
_WordDocClose($oWordDocument)
_WordQuit($oWordApp, -1)
return $TextDoc
EndFunc
Labels:
AutoIT
2012年5月23日
怎樣用AutoIT播放影音檔
作者: Fred Wang (FW知識瑣記) 日期: 2012/5/23
透過播放器如Windows Media Player, VLC, iTunes等自動播放影音,可以利用AutoIT的兩個Process Management指令ShellExecute與Run就可以達成
程式案例
$exeFile = "C:\Program Files\Windows Media Player\wmplayer.exe" ;播放器執行檔的路徑
$wavFile = "B:\BILD0982.WAV" ;影音檔的路徑
; 方法一 用ShellExecute
ShellExecute($exeFile,$wavFile)
; 方法二 用Run
$cmd = $exeFile & " " & $wavFile
Run($cmd)
透過播放器如Windows Media Player, VLC, iTunes等自動播放影音,可以利用AutoIT的兩個Process Management指令ShellExecute與Run就可以達成
程式案例
$exeFile = "C:\Program Files\Windows Media Player\wmplayer.exe" ;播放器執行檔的路徑
$wavFile = "B:\BILD0982.WAV" ;影音檔的路徑
; 方法一 用ShellExecute
ShellExecute($exeFile,$wavFile)
; 方法二 用Run
$cmd = $exeFile & " " & $wavFile
Run($cmd)
Labels:
AutoIT
訂閱:
文章 (Atom)