Leaderboard
Popular Content
Showing content with the highest reputation on 08/23/2015 in all areas
-
Under no circumstances should you use my solution over Malkey's, at all, ever. In this case my script is only more condensed because I am lazy and was not about to make $var for you, he was kind enough to do so. They are, for all intents, the same (this time, but thats just luck).2 points
-
LAST VERSION - 1.0 07-Mar-10 This is my very simple and small UDF. Allows you to restart the script from any location with full restoration of the original command line parameters. I use this library in several of my programs, and I was not disappointed. I hope this UDF will be useful for many as for me. I will be glad to any feedback and suggestions. Restart UDF Library v1.0 Previous downloads: 943 Restart.au3 Example #NoTrayIcon #Include <Misc.au3> #Include <Restart.au3> _Singleton('MyProgram') If MsgBox(36, 'Restarting...', 'Press OK to restart this script.') = 6 Then _ScriptRestart() EndIf1 point
-
If you need to do this on a log of any decent size, or if you really only want the last line: you may want to consider filereadline($log , -1), as checking that one string will be much less of a penalty than the readtoarray and ubound check.1 point
-
there are a couple hundred ways you could do this, here is my thought: Read to array, check the size, if it is bigger than before then read the last line. If that works you can start getting sexy and return all the lines that are new, since you have both the previous and current size. Something like this pseudo...... $oldnumberoflines = 0 While 1 $array = _FileReadToArray("logfile.log") $newnumberoflines = ubound($array) - 1 If $newnumberoflines > $oldnumberoflines Then msgbox(0, '' , $array[ubound($array) - 1]) $newnumberoflines = $oldnumberoflines sleep (5000) ; check every 5 seconds wend1 point
-
Thank you TheDcoder new version updated1 point
-
Laptop Guardian
JohnOne reacted to jvanegmond for a topic
You know that exists right? Hard disk firmware can be flashed with modified code. Recently people been doing interesting things with that. https://en.wikipedia.org/wiki/Rootkit#Firmware_and_hardware Edit Also what is the first thing you do after a reformat? You connect it to the internet to download updates and drivers. What if I flash your home router so it uses known exploits against Windows the moment that you connect? It's honestly not even that hard.1 point -
I've secured some short-term gigs and won't be in the country for the next week or so. My apologies, but it will take a little longer. Job goes first1 point
-
There's no need to re-declare the variable inside the function, just re-initialize it Declaration Global $someVariable = "SomeData" (re)Initialization $someVariable = "SomeOtherData" If you are only twelve for real, keep it up not many kids your age take interest in jack shit these days. Here is a little stroke for your ego, search for my last post here (Hint: I've been lurking a LONG time lol)1 point
-
define 2d array in a for loop
gottygolly reacted to Malkey for a topic
It is best to define or declare the array outside of any loop. Then, assign values to the elements of the array inside of a loop. #include <Array.au3> Local $array[50][2] Local $var[50] = [49, 48, 47, 46, 45, 44, 43, 42, 41, 40] For $i = 0 To 49 $array[$i][0] = $i $array[$i][1] = $var[$i] Next MsgBox(0, "Result", "$array[5][0] = " & $array[5][0] & @CRLF & @CRLF & "$array[5][1] = " & $array[5][1]) _ArrayDisplay($array)See tutorial on arrays https://www.autoitscript.com/wiki/Arrays1 point -
define 2d array in a for loop
gottygolly reacted to iamtheky for a topic
#include<array.au3> local $array[50][2] For $i = 0 to ubound($array) - 1 $array[$i][0] = $i $array[$i][1] = "var" & $i Next _ArrayDisplay($array)1 point -
Both of those are a last resort when dealing with window buttons, and neither can be used on non visible windows.1 point
-
Modified version of code here: #include <File.au3> #include <Misc.au3> ;Only allow one instance of the program to run. If _Singleton("Voice Commands", 1) = 0 Then Exit EndIf Dim $spokenWords Dim $voiceCommands = _FileListToArray(@WorkingDir & "\Voice Commands") Dim $voiceCommandsCap = $voiceCommands[0] Dim $voiceCommandName Dim $splitCommand Dim $splitRecognition Dim $parameter Dim $sendParameter Dim $count Dim $skipSearch Dim $transcriptionMode Global $h_Context = ObjCreate("SAPI.SpInProcRecoContext") Global $h_Recognizer = $h_Context.Recognizer Global $h_Grammar = $h_Context.CreateGrammar(1) $h_Grammar.Dictationload $h_Grammar.DictationSetState(1) ;Create a token for the default audio input device and set it Global $h_Category = ObjCreate("SAPI.SpObjectTokenCategory") $h_Category.SetId("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\AudioInput\TokenEnums\MMAudioIn\") Global $h_Token = ObjCreate("SAPI.SpObjectToken") $h_Token.SetId("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\AudioInput\TokenEnums\MMAudioIn\") $h_Recognizer.AudioInput = $h_Token Global $i_ObjInitialized = 0 Global $h_ObjectEvents = ObjEvent($h_Context, "SpRecEvent_") If @error Then ConsoleWrite("ObjEvent error: " & @error & @CRLF) $i_ObjInitialized = 0 Else ConsoleWrite("ObjEvent created Successfully!" & @CRLF) $i_ObjInitialized = 1 EndIf While $i_ObjInitialized Sleep(5000) ;Allow the Audio In to finalize processing on the last 5 second capture $h_Context.Pause ;Resume audio in processing $h_Context.Resume ;Reset event function allocation (what is this? I think its garbage collection or something, needs clarification) $h_ObjectEvents = ObjEvent($h_Context, "SpRecEvent_") WEnd Func SpRecEvent_Hypothesis($StreamNumber, $StreamPosition, $Result) ConsoleWrite("Hypothesis(): Hypothized text is: " & $Result.PhraseInfo.GetText & @CRLF) EndFunc ;==>SpRecEvent_Hypothesis Func SpRecEvent_Recognition($StreamNumber, $StreamPosition, $RecognitionType, $Result) ConsoleWrite($RecognitionType & "||" & $Result.PhraseInfo.GetText & @CRLF) $spokenWords = $Result.PhraseInfo.GetText CheckCommands() EndFunc ;==>SpRecEvent_Recognition Func SpRecEvent_SoundStart($StreamNumber, $StreamPosition) ConsoleWrite("Sound Started" & @CRLF) EndFunc ;==>SpRecEvent_SoundStart Func SpRecEvent_SoundEnd($StreamNumber, $StreamPosition) ConsoleWrite("Sound Ended" & @CRLF) EndFunc ;==>SpRecEvent_SoundEnd Func CheckCommands() ;=== Special Voice Commands === ;-- Transcription Mode-- If $spokenWords = "Transcription Mode" Then If $transcriptionMode = 0 Then $transcriptionMode = 1 ConsoleWrite("Transcription Mode On" & @CRLF) $skipSearch = 1 Else $transcriptionMode = 0 ConsoleWrite("Transcription Mode Off" & @CRLF) $skipSearch = 1 EndIf EndIf If $transcriptionMode = 1 Then If $spokenWords <> "Transcription Mode" Then Send($spokenWords) $skipSearch = 1 EndIf Else $skipSearch = 0 EndIf ;--------- ;============================== If $skipSearch = 0 Then ;=== Voice Command Search === ;%% in the file name denotes that whatever is said after the command, should be sent as a parameter $count = 1 While $count <= $voiceCommandsCap ConsoleWrite("count: " & $count & @CRLF) ConsoleWrite($voiceCommands[$count] & @CRLF) If StringInStr($voiceCommands[$count], "%%") <> 0 Then ConsoleWrite("found %%" & @CRLF) $splitCommand = StringSplit($voiceCommands[$count], " %%") If $splitCommand[0] > 2 Then $voiceCommandName = $splitCommand[1] & " " & $splitCommand[2] Else $voiceCommandName = $splitCommand[1] EndIf $splitRecognition = StringReplace($spokenWords, $voiceCommandName & " ", "") ;$splitRecognition = StringSplit($spokenWords, $voiceCommandName) ConsoleWrite("spokenWords: " & $spokenWords & @CRLF) ;ConsoleWrite("split By: " & $voiceCommandName & @CRLF) ConsoleWrite("splitRecognition: " & $splitRecognition & @CRLF) ;$parameter = $splitRecognition[1] $parameter = $splitRecognition $sendParameter = 1 ConsoleWrite("voiceCommandName: " & $voiceCommandName & @CRLF) ConsoleWrite("Parameter: " & $parameter & @CRLF) Else $splitCommand = StringSplit($voiceCommands[$count], ".au3") $voiceCommandName = $splitCommand[1] $sendParameter = 0 EndIf $count = $count + 1 WEnd ConsoleWrite("Checking Command to List" & @CRLF) If StringInStr($spokenWords, $voiceCommandName) <> 0 Then If $sendParameter = 1 Then Run(@WorkingDir & "\Voice Commands\" & $voiceCommandName & " %%.exe " & $parameter) ;Run("AutoIt3.exe " & $voiceCommandName &"%%.au3" & $parameter) Else ShellExecute(@WorkingDir & "\Voice Commands\" & $voiceCommandName & ".exe") ;Run("AutoIt3.exe " & $voiceCommandName &".au3") EndIf EndIf ;============================== EndIf $skipSearch = 0 EndFunc ;==>CheckCommands My issue is with the recognition itself. It's too often that the engine does not recognize what I'm saying. I've tried searching for the recognition information, training, etc... but I'm not finding what I need. I think I can use last hypothesized entry to check the commands, but.... I'm not sure how to get only the last entry for the hypothesis. If you look in the console as you speak, the hypothesis is constantly changing until you stop speaking. So I'm fairly certain I need to check for a pause in speech to use this method. Is the voice recognition engine shared amongst all programs? Is there a good application to train the voice recognition? sidenote: The code is terribly inefficient at the moment. It's a work in progress. After I get it to recognize my voice, then I'll work on making the actual commands better optimized.1 point
-
?? https://www.autoitscript.com/autoit3/docs/functions/HttpSetUserAgent.htm1 point
-
You will probably have to find each registry entry for "all browser!" user agent and set them all. You can start there.1 point
-
Use ControlSetText instead. Keep this in mind also...It's specific to apps on a locked station, but works the same for non-active windows: https://www.autoitscript.com/wiki/FAQ#Why_doesn.27t_my_script_work_on_a_locked_workstation.3F1 point
-
Word MailMerge Automation
lilaray7581 reacted to water for a topic
You need to modify the select statement. There you can specify the worksheet to be read.1 point -
Learn To Program Using FREE Tools with AutoIt
autoautoauto reacted to mLipok for a file
1 point -
Player music and playlist
coffeeturtle reacted to xan for a topic
Some modifications, continued track, time etc. #include <GuiListView.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <Sound.au3> If FileExists("Lista.ini") Then ;Se a lista existe é exibida $lista = IniRead("Lista.ini", "Lista" , "Caminho","") $var = $lista Else ;Se não é criado um falso mp3 no diretório do Script FileOpen("No-Music.mp3",1) Sleep(300) $var = @ScriptDir EndIf Local $asteriscos = " **************************** " Local $FileList = _FileListToArray($var, "*.mp3*", 1), $dir,$ntime,$slength Global $tocando, $music = 1, $vol = 30, $max = $FileList[0], $title = $FileList[1],$sound, $List2 GUICreate("Autoit Sound Play", 500, 313, 192, 124, -1, 16) $List1 = GUICtrlCreateListView("", 200, 4, 295, 215, 0x00800000) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetBkColor(0x393952) GUISetState() _GUICtrlListView_InsertColumn($List1, 0," " & $FileList[0] & " - músicas ", 257,0) GUICtrlSetState ( - 1 , $GUI_DROPACCEPTED ) For $i = 1 To $max Step 1 _GUICtrlListView_AddItem($List1, $FileList[$i], $i) ;gera itens de acordo com o nº de músicas Next $Prev = GUICtrlCreateButton("Prev", 104, 2, 81, 41) GUICtrlSetBkColor(-1, 0xff6633) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") $Next = GUICtrlCreateButton("Next", 104, 51, 81, 49) GUICtrlSetBkColor(-1, 0xff6633) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") $Play = GUICtrlCreateButton("Play", 8, 2, 89, 97) GUICtrlSetBkColor(-1, 0xbdc6c6) GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif") $Stop = GUICtrlCreateButton("Stop", 8, 110, 177, 33) GUICtrlSetBkColor(-1, 0xbdc6c6) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") $List = GUICtrlCreateButton("List", 136, 147, 49, 73) GUICtrlSetBkColor(-1, 0x999999) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $VolUP= GUICtrlCreateButton("VolUP", 72, 147, 57, 73) GUICtrlSetBkColor(-1, 0xbdc6c6) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $time = GUICtrlCreateLabel("Autosom", 420, 240, 80, 30) GUICtrlSetColor(-1, 0xffffff) $VDown= GUICtrlCreateButton("VolDown", 8, 147, 57, 73) GUICtrlSetBkColor(-1, 0xbdc6c6) $Volume=GUICtrlCreateLabel("Volume " & $vol, 15, 230, 340, 45) GUICtrlSetFont(-1, 30, 500, 0, "MS Sans Serif") $List2 =GUICtrlCreateList($title & " *********************************", 0, 280, 500, 50,3) GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif") GUICtrlSetBkColor(-1,0xbdc6c6) GUISetState(@SW_SHOW) While 1 If $ntime <> _SoundPos($sound, 1) Then GUICtrlSetData($time,"Time " & _SoundLength($sound, 1) & @cr & " |> "& _SoundPos($sound, 1)) $ntime = _SoundPos($sound, 1) EndIf $nMsg = GUIGetMsg() If _SoundPos($sound) >= _SoundLength($sound, 1) And $tocando And $music < $max Then Sleep(1500) SoundControl(1) EndIf Switch $nMsg Case $GUI_EVENT_DROPPED $File = @GUI_DragFile $str = StringSplit($File, "\", 1) ConsoleWrite($max&@CR) _GUICtrlListView_AddItem($List1, $str[$str[0]], $max) Case $Play SoundControl(0) Case $Next If $music < $max And $tocando Then SoundControl(1) Case $Prev If $music > 1 And $tocando Then SoundControl(2) Case $Stop _SoundStop($sound) GUICtrlSetData($Play, "Play") $tocando = False Case $VDown If $tocando And $vol >= 5 Then $vol -= 5 GUICtrlSetData($Volume, "Volume " & $vol) EndIf Case $VolUP If $tocando And $vol < 100 Then $vol += 5 GUICtrlSetData($Volume, "Volume " & $vol) EndIf Case $List $openwin = FileSelectFolder("Escolha um pasta.", $dir ) Local $FileList = _FileListToArray($openwin, "*.mp3", 0) ; transforma os mp3 em arrays If @error = 1 Or Not $openwin Then $FileList = _FileListToArray($var, "*.mp3", 0) ; transforma os mp3 em arrays Else $var = $openwin EndIf $max = $FileList[0] ; [0] número de mp3 é o limite max $open = FileOpen("Lista.ini", 2) $lista = IniWrite("Lista.ini", "Lista", "Caminho", $var) GUICtrlDelete($List1) $List1 = GUICtrlCreateListView("", 200, 4, 285, 215) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState() _GUICtrlListView_InsertColumn($List1, 0," " & $FileList[0] & " - músicas ", 256) GUICtrlSetState ( - 1 , $GUI_DROPACCEPTED ) For $i = 1 To $max Step 1 _GUICtrlListView_AddItem($List1, $FileList[$i], $i) ;gera novamente itens após novo diretório Next Case -3 Exit EndSwitch SoundSetWaveVolume($vol) Sleep(10) WEnd Func SoundControl($mode) If $mode = 0 Then If $tocando = 2 Then GUICtrlSetData($Play, "||") _SoundResume($sound) $tocando = 1 ElseIf $tocando Then GUICtrlSetData($Play, "Play") _SoundPause($sound) $tocando = 2 Else GUICtrlSetData($Play, "||") $sound = _SoundOpen($var & "\" & $FileList[$music]) _SoundPlay($sound) $tocando = 1 EndIf ElseIf $mode = 1 Then $tocando = 1 _SoundClose($sound) $music += 1 $sound = _SoundOpen($var & "\" & $FileList[$music]) _SoundPlay($sound) ElseIf $mode = 2 Then $tocando = 1 _SoundClose($sound) $music -= 1 $sound = _SoundOpen($var & "\" & $FileList[$music]) _SoundPlay($sound) ElseIf $mode = 3 Then GUICtrlSetData($Play, "||") $tocando = 1 _SoundClose($sound) $sound = _SoundOpen($var & "\" & $FileList[$music]) _SoundPlay($sound) EndIf $title = $FileList[$music] $star = $asteriscos For $i = 0 To StringLen($star) $starr = StringTrimLeft($star,$i) GUICtrlSetData($List2, "") GUICtrlSetData($List2, $starr & $title & $asteriscos); & $asteriscos) Sleep(30) Next EndFunc Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) ;reconhece o ítem clicado duas vezes e executa Local $iCode, $tNMHDR, $hWndListView, $tInfo, $aItem, $hWndListView = $List1, _ $tNMHDR = DllStructCreate($tagNMHDR, $ilParam), $iCode = DllStructGetData($tNMHDR, "Code") If $iCode = $NM_DBLCLK Then $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) $aItem = _GUICtrlListView_GetItem($hWndListView, DllStructGetData($tInfo, "Index")) $music = $aItem[4] SoundControl(3) EndIf EndFunc1 point -
Player music and playlist
coffeeturtle reacted to xan for a topic
new version of this player with some enhancements like click and run #include <File.au3> #include <GuiListView.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> If FileExists("Lista.ini") Then ;if the list exists is displayed $lista = IniRead("Lista.ini", "Lista" , "Caminho","") $var = $lista Else ;if not, it created a false mp3 directory script FileOpen("No-Music.mp3",1) Sleep(300) $var = @ScriptDir EndIf Local $FileList = _FileListToArray($var, "*.mp3*", 1) Global $tocando = False, $music = 1, $voll = "Volume", $vol = 30, $max = $FileList[0], $title = $FileList[1] #region ### START Koda GUI section ### $Form1_1 = GUICreate("Autoit Sound Play", 500, 313, 192, 124) GUISetBkColor(0x393952) $List1 = GUICtrlCreateListView("", 200, 8, 261, 220) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState() _GUICtrlListView_InsertColumn($List1, 0," " & $FileList[0] & " - músicas ", 257) For $i = 1 To $max Step 1 _GUICtrlListView_AddItem($List1, $FileList[$i], $i) ;generating items according to the number of songs Next $Prev = GUICtrlCreateButton("Prev", 104, 2, 81, 41) GUICtrlSetBkColor(-1, 0xff6633) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") $Next = GUICtrlCreateButton("Next", 104, 51, 81, 49) GUICtrlSetBkColor(-1, 0xff6633) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") $Play = GUICtrlCreateButton("Play", 8, 2, 89, 97) GUICtrlSetBkColor(-1, 0xbdc6c6) GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif") $Stop = GUICtrlCreateButton("Stop", 8, 110, 177, 33) GUICtrlSetBkColor(-1, 0xbdc6c6) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") $List = GUICtrlCreateButton("List", 136, 147, 49, 73) GUICtrlSetBkColor(-1, 0x999999) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $VolUP = GUICtrlCreateButton("VolUP", 72, 147, 57, 73) GUICtrlSetBkColor(-1, 0xbdc6c6) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $AutoSound = GUICtrlCreateLabel("A" & @CR & "U" & @CR & "T" & @CR & "O" & _ @CR & @CR & @CR & "S" & @CR & "O" & @CR & "U" & @CR & "N" & @CR & "D", 478, 10, 257, 217) $VolDown = GUICtrlCreateButton("VolDown", 8, 147, 57, 73) GUICtrlSetBkColor(-1, 0xbdc6c6) $Volume = GUICtrlCreateLabel("Volume " & $vol, 15, 230, 400, 45) GUICtrlSetFont(-1, 30, 500, 0, "MS Sans Serif") $List2 = GUICtrlCreateList($title & " *********************************", 0, 280, 500, 50,3) GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif") GUICtrlSetBkColor(-1,0xbdc6c6) GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### SoundPlay($var & "\" & $music, 0) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $Play $title = $FileList[$music] SoundPlay($var & "\" & $FileList[$music], 0) GUICtrlSetData($List2, $title & " *********************************") ; $tocando = True Case $Prev If $tocando And $music > 1 Then $music -= 1 $title = $FileList[$music] SoundPlay($var & "\" & $FileList[$music], 0) GUICtrlSetData($List2, $title & " *********************************") EndIf If $tocando And $music < 2 Then SoundPlay($var & "\" & $FileList[$music], 0) EndIf Case $Next If $tocando And $music < $max Then $music += 1 $title = $FileList[$music] GUICtrlSetData($List2,"") GUICtrlSetData($List2, $title & " *********************************") SoundPlay($var & "\" & $FileList[$music], 0) EndIf Case $Stop SoundPlay("nosound", 0) $tocando = False Case $VolDown If $tocando And $vol >= 5 Then $vol -= 5 GUICtrlSetData($Volume, $voll & " " & $vol) EndIf Case $VolUP If $tocando And $vol < 100 Then $vol += 5 GUICtrlSetData($Volume, $voll & " " & $vol) EndIf Case $List $openwin = FileSelectFolder("Escolha um pasta.", "") $var = $openwin ; var equal to the Open Directory Local $FileList = _FileListToArray($var, "*.mp3", 0) ; mp3 transforms into arrays $max = $FileList[0] ;[0] number of mp3 is the limit max $open = FileOpen("Lista.ini", 2) $lista = IniWrite("Lista.ini", "Lista", "Caminho", $var) GUICtrlDelete($List1) $List1 = GUICtrlCreateListView("", 200, 8, 261, 220) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState() _GUICtrlListView_InsertColumn($List1, 0," " & $FileList[0] & " - músicas ", 256) For $i = 1 To $max Step 1 _GUICtrlListView_AddItem($List1, $FileList[$i], $i) ;regenerates items after new directory Next Case $GUI_EVENT_CLOSE Exit EndSwitch SoundSetWaveVolume($vol) Sleep(10) WEnd Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) ;recognizes the item double-clicked and executed Local $iCode, $tNMHDR, $hWndListView, $tInfo, $aItem, $hWndListView = $List1, _ $tNMHDR = DllStructCreate($tagNMHDR, $ilParam), $iCode = DllStructGetData($tNMHDR, "Code") Switch $iCode Case $NM_DBLCLK $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) $aItem = _GUICtrlListView_GetItem($hWndListView, DllStructGetData($tInfo, "Index")) GUICtrlSetData($List2, "") GUICtrlSetData($List2, $aItem[3] & " *********************************") SoundPlay($var & "\" & $aItem[3], 0) $tocando = True ;music playing EndSwitch EndFunc1 point -
Google Functions
guestscripter reacted to Beege for a topic
Heres four short and quick functions that use google that might come in handy for some people. Ideas came from Travis and IchBistTod scripts. Can anyone think of any more? #include <inet.au3> #include <array.au3> $suggestions = _GoogleSuggestions('autoit s') _ArrayDisplay($suggestions, 'Suggestions') $Definitions = _GoogleDefine("Pulp") _ArrayDisplay($Definitions, 'Pulp ') $Translate = _GoogleTranslate("Hello how are you?") MsgBox(0, 'English to Spanish ', "Hello how are you?" & @CRLF & $Translate) $convert = _GoogleUnitConvert(10, 'gallons', 'liters') MsgBox(0,'Gallons to Liters', '10 Gallons = ' &$convert& ' Liters') Func _GoogleSuggestions($sSuggest); Retruns an Array of Suggestions Local $sSource, $aResults;, $aQueries $sSource = _INetGetSource("http://google.com/complete/search?output=toolbar&q=" & $sSuggest) If @error Then Return SetError(1) $aResults = StringRegExp($sSource, '<CompleteSuggestion><suggestion data="(.*?)"/>', 3) ;~ $sQueries = StringRegExp($source, '"/><num_queries int="(\d{0,})"/>', 3) Return $aResults EndFunc ;==>_GoogleSuggestions Func _GoogleDefine($sKeyWord) Local $aDefintions, $sSource $sSource = _INetGetSource("http://www.google.com/search?q=define%3A" & $sKeyWord) If @error Then Return SetError(1) $aDefintions = StringRegExp($sSource, "<li>(.*?)<br>", 1) Return StringSplit(StringRegExpReplace($aDefintions[0], '(<li>)', '|'), '|') EndFunc ;==>_GoogleDefine Func _GoogleTranslate($sText, $sTo = "es", $sFrom = "en") Local $sTranslation, $sUrl, $sSource $sUrl = StringFormat("http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=%s&langpair=%s%%7C%s", $sText, $sFrom, $sTo) $sSource = _INetGetSource($sUrl) $sTranslation = StringRegExp(BinaryToString($sSource, 4), '"translatedText":"([^"]+)"', 1) Return $sTranslation[0] EndFunc ;==>_GoogleTranslate ;~ spanish = es, Albanian = sq, Arabic = ar, Bulgarian = bg,Catalan = ca, Croatian = hr, Czech = cs,Danish = da ;~ dutch = nl,Estonian = et,Filipino = tl, Finnish = fi, French = fr, Galician = gl,German = de,Greek = el ;~ Hebrew = iw,Hindi = hi - no, Hungarian = hu,Indonesian = id, Italian = it, Latvian = lv,Vietnamese = vi ;~ Turkish = tr,Swedish = sv,Russian = ru, Portuguese = pt, English = en Func _GoogleUnitConvert($sValue, $sFrom, $sTo) Local $sSource $sSource = _INetGetSource("http://www.google.com/search?q=" & $sValue & "%20" & StringLower($sFrom) & "%20in%20" & StringLower($sTo)) If @error Then Return SetError(1) $sSource = StringRegExp($sSource, '<h2(.*?)More about calculator.</a>', 1) $sSource = StringRegExp($sSource[0], '=\s(.*?)\s[a-z]*(\s?[a-z]*?)</b>', 1) Return StringReplace($sSource[0], Chr(160), '') EndFunc ;==>_GoogleUnitConvert1 point