Leaderboard
Popular Content
Showing content with the highest reputation on 07/18/2013 in all areas
-
YWeather UDF - Yahoo Weather API
jaberwacky reacted to Nessie for a topic
Here is another UDF Now you can very simply retrive details about the weather in a specific region, using the Yahoo Weather API. All you need is the WOEID code of the region that you want to check. If you will find any bug, have suggestion or you want other function please just let me know! What is this WOEID? A WOEID (Where on Earth IDentifier) is a unique 32 bit reference identifier assigned byYahoo! to identify any feature on Earth. How i can get this value? Now with version >= 1.1.0 you can retrive this value with the function _YWeater_Retrieval_WOEID OR You can use this simple website to retrive your preferite WOEID http://woeid.rosselliot.co.nz/ You can search by city, address or zip code. Changelog ;===================================================== v.1.1.0 (11/04/2013) Added _YWeater_Retrieval_WOEID ;===================================================== v.1.0.0 (18/03/2013) Initial Release All supported function: ;_YWeater_Retrieval_WOEID ;_YWeater_Get_Weather ;_YWeater_Get_Forecast ;_YWeater_Get_Atmosphere ;_YWeater_Get_Astronomy ;_YWeater_Get_Wind ;_YWeater_Get_Coordinates ;_YWeater_Get_Location Here is an example of usage: #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include "YWeather.au3" ;====================================================================================================== $iWOEID = "2459115" ;New York WOEID $iUnits = 1 ;Imperial System ;====================================================================================================== $GUI = GUICreate("YWeather v.1.0.0", 454, 421, 550, 140) $Group1 = GUICtrlCreateGroup("Current Weather", 8, 8, 433, 209) $Label1 = GUICtrlCreateLabel("Temperature:", 16, 24, 67, 17) $l_Temp = GUICtrlCreateLabel("40", 88, 24, 20, 17) $Label3 = GUICtrlCreateLabel("Weather:", 16, 48, 48, 17) $l_Weather = GUICtrlCreateLabel("", 64, 48, 276, 17) $Label19 = GUICtrlCreateLabel("Wind Chill:", 16, 72, 54, 17) $l_Chill = GUICtrlCreateLabel("", 72, 72, 18, 17) $Label21 = GUICtrlCreateLabel("Direction:", 96, 72, 49, 17) $l_Direction = GUICtrlCreateLabel("", 144, 72, 26, 17) $Label23 = GUICtrlCreateLabel("Speed:", 176, 72, 38, 17) $l_Speed = GUICtrlCreateLabel("", 216, 72, 26, 17) $Label25 = GUICtrlCreateLabel("mph", 248, 72, 24, 17) $Label26 = GUICtrlCreateLabel("Sunrise:", 16, 120, 42, 17) $l_Sunrise = GUICtrlCreateLabel("", 64, 120, 42, 17) $Label28 = GUICtrlCreateLabel("Sunset:", 112, 120, 40, 17) $l_Sunset = GUICtrlCreateLabel("", 152, 120, 42, 17) $Label30 = GUICtrlCreateLabel("Humidity:", 16, 96, 47, 17) $l_Humidity = GUICtrlCreateLabel("", 64, 96, 18, 17) $Label32 = GUICtrlCreateLabel("%", 88, 96, 12, 17) $Label33 = GUICtrlCreateLabel("Visibility:", 104, 96, 43, 17) $l_Visibility = GUICtrlCreateLabel("", 152, 96, 18, 17) $Label35 = GUICtrlCreateLabel("mi", 176, 96, 14, 17) $Label36 = GUICtrlCreateLabel("Pressure:", 192, 96, 48, 17) $l_Pressure = GUICtrlCreateLabel("", 240, 96, 26, 17) $Label38 = GUICtrlCreateLabel("Latitude:", 16, 144, 45, 17) $l_Latitude = GUICtrlCreateLabel("", 64, 144, 34, 17) $Label40 = GUICtrlCreateLabel("Longitude:", 104, 144, 54, 17) $l_Longitude = GUICtrlCreateLabel("", 160, 144, 34, 17) $Label42 = GUICtrlCreateLabel("City:", 16, 168, 24, 17) $l_City = GUICtrlCreateLabel("", 40, 168, 114, 17) $Label44 = GUICtrlCreateLabel("Region:", 168, 168, 41, 17) $l_Region = GUICtrlCreateLabel("", 216, 168, 50, 17) $Label46 = GUICtrlCreateLabel("Country:", 280, 168, 43, 17) $l_Country = GUICtrlCreateLabel("", 328, 168, 106, 17) $Label5 = GUICtrlCreateLabel("Check time:", 16, 192, 60, 17) $l_Check = GUICtrlCreateLabel("", 80, 192, 236, 17) $Label2 = GUICtrlCreateLabel("F", 112, 24, 10, 17) $Label4 = GUICtrlCreateLabel("in", 272, 96, 12, 17) $Label6 = GUICtrlCreateLabel("Rising:", 288, 96, 33, 17) $l_Rising = GUICtrlCreateLabel("", 328, 96, 68, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group2 = GUICtrlCreateGroup("Forecast", 8, 224, 433, 89) $Label7 = GUICtrlCreateLabel("Low Temperature:", 16, 240, 90, 17) $l_Low1 = GUICtrlCreateLabel("", 112, 240, 20, 17) $Label9 = GUICtrlCreateLabel("F", 136, 240, 10, 17) $Label11 = GUICtrlCreateLabel("High Temperature:", 16, 264, 92, 17) $l_Hi1 = GUICtrlCreateLabel("", 112, 264, 18, 17) $Label12 = GUICtrlCreateLabel("F", 136, 264, 10, 17) $Label13 = GUICtrlCreateLabel("Weather:", 16, 288, 48, 17) $l_Weather1 = GUICtrlCreateLabel("", 64, 288, 290, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group3 = GUICtrlCreateGroup("", 8, 320, 433, 89) $Label15 = GUICtrlCreateLabel("Low Temperature:", 16, 336, 87, 17) $Label16 = GUICtrlCreateLabel("High Temperature:", 16, 360, 89, 17) $Label17 = GUICtrlCreateLabel("Weather:", 16, 384, 48, 17) $l_Weather2 = GUICtrlCreateLabel("", 64, 384, 298, 17) $l_Low2 = GUICtrlCreateLabel("", 104, 336, 18, 17) $Label14 = GUICtrlCreateLabel("F", 128, 336, 10, 17) $l_Hi2 = GUICtrlCreateLabel("", 112, 360, 18, 17) $Label20 = GUICtrlCreateLabel("F", 136, 360, 10, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $Weather = _YWeater_Get_Weather($iWOEID, $iUnits) If Not @error Then InetGet($Weather[1], @TempDir & "\Current_Picture.gif") GUICtrlSetData($l_Weather, $Weather[0]) GUICtrlCreatePic(@TempDir & "\Current_Picture.gif", 368, 24, 60, 52) GUICtrlSetData($l_Temp, $Weather[2]) GUICtrlSetData($l_Check, $Weather[3]) EndIf $Forecast = _YWeater_Get_Forecast($iWOEID, $iUnits) If Not @error Then InetGet($Forecast[0][5], @TempDir & "\Tomorrow_Picture.gif") GUICtrlCreatePic(@TempDir & "\Tomorrow_Picture.gif", 368, 240, 60, 52) GUICtrlSetData($Group2, $Forecast[0][0] & " " & $Forecast[0][1]) GUICtrlSetData($l_Low1, $Forecast[0][2]) GUICtrlSetData($l_Hi1, $Forecast[0][3]) GUICtrlSetData($l_Weather1, $Forecast[0][4]) InetGet($Forecast[1][5], @TempDir & "\After_Tomorrow_Picture.gif") GUICtrlCreatePic(@TempDir & "\After_Tomorrow_Picture.gif", 368, 336, 60, 52) GUICtrlSetData($Group3, $Forecast[1][0] & " " & $Forecast[1][1]) GUICtrlSetData($l_Low2, $Forecast[1][2]) GUICtrlSetData($l_Hi2, $Forecast[1][3]) GUICtrlSetData($l_Weather2, $Forecast[1][4]) EndIf $Wind = _YWeater_Get_Wind($iWOEID, $iUnits) If Not @error Then GUICtrlSetData($l_Chill, $Wind[0]) GUICtrlSetData($l_Direction, $Wind[1]) GUICtrlSetData($l_Speed, $Wind[2]) EndIf $Atmosphere = _YWeater_Get_Atmosphere($iWOEID, $iUnits) If Not @error Then GUICtrlSetData($l_Humidity, $Atmosphere[0]) GUICtrlSetData($l_Visibility, $Atmosphere[1]) GUICtrlSetData($l_Pressure, $Atmosphere[2]) GUICtrlSetData($l_Rising, $Atmosphere[3]) EndIf $Astronomy = _YWeater_Get_Astronomy($iWOEID) If Not @error Then GUICtrlSetData($l_Sunrise, $Astronomy[0]) GUICtrlSetData($l_Sunset, $Astronomy[1]) EndIf $Coordinates = _YWeater_Get_Coordinates($iWOEID) If Not @error Then GUICtrlSetData($l_Latitude, $Coordinates[0]) GUICtrlSetData($l_Longitude, $Coordinates[1]) EndIf $Location = _YWeater_Get_Location($iWOEID) If Not @error Then GUICtrlSetData($l_City, $Location[0]) GUICtrlSetData($l_Region, $Location[1]) GUICtrlSetData($l_Country, $Location[2]) EndIf GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEndHi! Previous download : 39 YWeather v.1.1.0.rar1 point -
I wouldn't worry about it, It's your page file you should worry about if you have low memory. But I tend to read from file/registry when start program and write when end program, during is all memory.1 point
-
Thought I'd put up what I was banging on about (for reference) But I don't even think it worked #include <Array.au3> Opt("WinTitleMatchMode", 2) $aBefore = GetWinHandles() Run(@ProgramFilesDir & "\internet explorer\iexplore.exe") Sleep(2000) WinMinimizeAll() $after = GetWinHandles() For $i = 0 To UBound($after) - 1 $Testing = hWndInArray($aBefore, $after[$i]) If $Testing Then WinSetState($Testing, "", @SW_RESTORE) GetPid($Testing) Exit EndIf Next Exit Func GetPid($hwnd) $PID = DllStructCreate("int") $aCall = DllCall("user32.dll", "int", "GetWindowThreadProcessId", "hwnd", HWnd($hwnd), "dword*", DllStructGetPtr($PID)) MsgBox(0,"PID", $aCall[2]) EndFunc Func hWndInArray(ByRef $aArray, $hWnd) For $i = 0 To UBound($aArray) - 1 If $hWnd = $aArray[$i] Then Return 0 EndIf Next Return $hWnd EndFunc ;==>hWndInArray Func GetWinHandles() $sIndex = "" $WindowCount = 0 $aIEWindows = WinList("Windows Internet Explorer") For $i = 1 To UBound($aIEWindows) - 1 $winstate = WinGetState($aIEWindows[$i][1]) If BitAND($winstate, 2) Then $WindowCount += 1 $sIndex &= $i EndIf Next Local $aOriginalWindows[$WindowCount] $aLocalArray = StringSplit($sIndex, "", 3) For $i = 0 To UBound($aLocalArray) - 1 $aLocalArray[$i] = $aIEWindows[$aLocalArray[$i]][1] Next Return $aLocalArray EndFunc ;==>GetWinHandles1 point
-
beautiful solutions Ascend4ant, and also very instructive! also nice the _ProcessListAfterTime! following the advice of Mr. Ascend4ant in post # 16, his wonderful UDF, and if it is allowed to use the run () instead RunWait () should then work even these simple few lines (a bit botched): #include <array.au3> #include <_ProcessListFunctions.au3> ; <-- download from Ascend4nt signature ; https://sites.google.com/site/ascend4ntscode/processfunctions $father_pid = run(@comspec & ' /c ' & $command) ; pid of father Sleep(1000) ; give time to spawn childs or _ProcessGetChildren will not find them $childs = _ProcessGetChildren($father_pid) ; list of child(s) processes spawned by $father ; (in this case should be only 1) ; Return: ; [0][0] = # of Child Processes (0 = none found) ; [$i][0] = Process Name ; [$i][1] = Process ID # ; [$i][2] = Parent Process ID # ; [$i][3] = Thread Count ; [$i][4] = Threads Base Priority $child_pid = $childs [1][1] ; Process ID # of the (single) child ; $out[1][2] should be = $fatherpid $nephews = _ProcessGetChildren($child_pid) ; list of nephew(s) processes spawned by $child ; should be the iexplore.exe (?) $nephew_pid = $nephews [1][1] ; <-- this should be the searched PID MsgBox(0,"",$nephew_pid)1 point
-
try changing root key to "HKEY_LOCAL_MACHINE64"1 point
-
Else I will tell him what hasn't been finished.1 point
-
I believe it has something to do with registry redirection, where the os decides where a key is meant for. You have two options, websearch "disable redirection" to explicitly turn it off and back on after write, or it could be as simple as #Autoitwrapper usex64 = n (or something like that) EDIT: #AutoIt3Wrapper_UseX64=n1 point
-
0xdefea7's post makes more sense than anything else posted, after all using RunWait means that the script won't continue until the process is closed, so having a PID of a program that's not running any longer is pretty much pointless. You can't do anything with the information, and I'm pretty sure you won't get any information to begin with.1 point
-
Or #include <constants.au3> $String = "2" & chr(160) & "234,34" $NewString = StringRegExpReplace($String, "(\d+)\D(\d+),(\d+)", "$1$2.$3") MsgBox($MB_SYSTEMMODAL, "New String", $NewString)1 point
-
DirCopy not working.. HELP!
0xdefea7 reacted to JLogan3o13 for a topic
Hi, swstrau118. For what it is worth, your script works when I test on both XP and WIN7, so if it is not copying to the network drive the cause is something local to your machine (permissions on the folder you're copying, permissions on the network share, etc. etc.) As for the IF statement, to only pull SysDat and GPData (not GPData 1988, etc.), your statement as is should work - e.g. CopyWithProgress("C:VSMSysDat" is not going to copy any directory with a name longer that SysDat. Regarding the dates, you could always read the list of directories in using Melba's _RecFileListToArray, then run through the array with FileAttribute to get your dates, like so: #include <Array.au3> #include <RecFileListToArray.au3> $sPath = "C:\Test" $aDirs = _RecFileListToArray($sPath, "*", 0, 1, 1, 2) For $i = 1 To $aDirs[0] MsgBox(4096, "", FileGetTime($aDirs[$i], 1, 1)) Next You could do an If statement based on the file name, and compare the timestamps to get what you want.1 point -
IniRead from a variable (not from a file)
michaelslamet reacted to guinness for a topic
You mean you want to read INI syntax assigned to a variable without writing to a file? If so, search AZJIO and ini virtual.1 point -
oapjr, I haven't forgot about ya. Give this a try. Note its for testing purposes only, meaning it dosen't delete anything although you could simply add the command to do so if it works. The file has to be playing...du #NoTrayIcon #include "WinAPIEx.au3" #include "APIConstants.au3" #include <WinAPI.au3> ; Note that the functions below were thrown together and need heavy optimization! #include <Array.au3> ; For example only #include <File.au3> Dim $aFiles = _ProcessListFiles("wmplayer.exe") ; Get a list of files currently opened by the process $aFiles = _ArrayUnique($aFiles) ; Remove duplicate entries Dim $bAllFilesExist = False Do ; Loop through the array and remove invalid entries $bAllFilesExist = True For $i = 1 To UBound($aFiles, 1) - 1 Step 1 If Not FileExists($aFiles[$i]) Then _ArrayDelete($aFiles, $i) ; Files dosen't exist so remove it from the array $bAllFilesExist = False $aFiles[0] -= 1 ExitLoop EndIf Next Until $bAllFilesExist MsgBox(262144, "FileDelete", _GetAudioFileFromArray($aFiles)) ; Display the result _ArrayDisplay($aFiles) ; Display the result Exit Func _GetAudioFileFromArray(ByRef $aFiles) Local $aPath, $szDrive, $szDir, $szFName, $szExt For $i = 1 To $aFiles[0] Step 1 $aPath = _PathSplit($aFiles[$i], $szDrive, $szDir, $szFName, $szExt) If StringRegExp($aPath[4], "(mp3|wav|ogg|wma)") Then Return $aFiles[$i] EndIf Next EndFunc Func _ProcessListFiles($vProcess) _AdjustPrivilege(20) ; Retrieve PID from process name Local $nProcessId = ProcessExists($vProcess) ; Create structure to store public object type information Local $tPOTI = DllStructCreate('ushort;ushort;ptr;byte[128]'), $aRet ; Get the full list of open handles via PID Local $aHandles = _WinAPI_EnumProcessHandles($nProcessId) ; Variable declaration and open target process for handle duplication Local $hObject, $hProcess = _WinAPI_OpenProcess($PROCESS_DUP_HANDLE, 0, $nProcessId, True), $pData, $Length, $tString, $nFiles = 0 ; Iterate through each handle listed and duplicate into our own process for object information gathering For $i = 1 To $aHandles[0][0] Step 1 ; Prevent Hangup on certain access rights! If $aHandles[$i][3] == 0x00120189 Then $aHandles[$i][0] = 0 ContinueLoop EndIf If $aHandles[$i][3] == 0x0012019f Then $aHandles[$i][0] = 0 ContinueLoop EndIf If $aHandles[$i][3] == 0x00100000 Then $aHandles[$i][0] = 0 ContinueLoop EndIf ; Duplicate handle is neccessary to retrieve object information $hObject = _WinAPI_DuplicateHandle($hProcess, $aHandles[$i][0], _WinAPI_GetCurrentProcess(), 0, False, $DUPLICATE_SAME_ACCESS) If Not $hObject Then ContinueLoop ; Determine Object Type $aRet = DllCall("ntdll.dll", 'uint', 'NtQueryObject', 'ptr', $hObject, 'uint', 2, 'ptr', DllStructGetPtr($tPOTI), 'ulong', DllStructGetSize($tPOTI), 'ptr', 0) If @error Then ContinueLoop Else If $aRet[0] Then ContinueLoop EndIf EndIf $pData = DllStructGetData($tPOTI, 3) If Not $pData Then ContinueLoop EndIf $Length = DllCall("kernel32.dll", 'int', 'lstrlenW', 'ptr', $pData) If @error Then ContinueLoop EndIf $Length = $Length[0] If Not $Length Then ContinueLoop EndIf $tString = DllStructCreate('wchar[' & ($Length + 1) & ']', $pData) If @error Then ContinueLoop EndIf $aHandles[$i][0] = $hObject ; $hObject contains the handle to the object which duplicate to our process $aHandles[$i][1] = DllStructGetData($tString, 1) ; Should contain the object type in string format. If $aHandles[$i][1] == "File" Then $nFiles += 1 Next ; Create a new array for the file handles Local $aFiles[$nFiles+1][4] $aFiles[0][0] = $nFiles $nFiles = 0 ; Sort and close unneeded handles For $i = 1 To $aHandles[0][0] Step 1 If $aHandles[$i][0] And $aHandles[$i][1] == "File" Then $nFiles += 1 $aFiles[$nFiles][0] = $aHandles[$i][0] $aFiles[$nFiles][1] = $aHandles[$i][1] $aFiles[$nFiles][2] = $aHandles[$i][2] $aFiles[$nFiles][3] = $aHandles[$i][3] ElseIf $aHandles[$i][0] Then _WinAPI_CloseHandle($aHandles[$i][0]) EndIf Next ; Free memory by deleting the previous array $aHandles = 0 Local $aFilePaths[$aFiles[0][0]+1] For $i = 1 To $aFiles[0][0] Step 1 If $aFiles[$i][0] Then $aFilePaths[$i] = _GetFileObjectPath($aFiles[$i][0]) _WinAPI_CloseHandle($aFiles[$i][0]) EndIf Next $aFilePaths[0] = $aFiles[0][0] Return $aFilePaths EndFunc Func _GetFileObjectPath($hObject) Local $tStruct = DllStructCreate("char[255];") Local $aDrive = DriveGetDrive("ALL") Local $aDrivesInfo[UBound($aDrive) - 1][2] For $I = 0 To UBound($aDrivesInfo) - 1 $aDrivesInfo[$I][0] = $aDrive[$I + 1] DllCall("kernel32.dll", "dword", "QueryDosDevice", "str", $aDrivesInfo[$I][0], "ptr", DllStructGetPtr($tStruct), "dword", 255) $aDrivesInfo[$I][1] = DllStructGetData($tStruct, 1) Next Local $PUBLIC_OBJECT_TYPE_INFORMATION = "ushort Length;" & _ "ushort MaximumLength;" & _ "ptr Buffer;" & _ ;UNICODE_STRING struct "wchar Reserved[260];" Local $tPOTI = DllStructCreate($PUBLIC_OBJECT_TYPE_INFORMATION), $sDeviceStr, $vSolid = False DllCall("ntdll.dll", "ulong", "NtQueryObject", "ptr", $hObject, "int", 1, "ptr", DllStructGetPtr($tPOTI), "ulong", DllStructGetSize($tPOTI), "ulong*", "") $sDeviceStr = DllStructGetData(DllStructCreate("wchar[" & Ceiling(DllStructGetData($tPOTI, "Length") / 2) & "];", DllStructGetData($tPOTI, "buffer")), 1) For $y = 0 To UBound($aDrivesInfo) - 1 If StringLeft($sDeviceStr, StringLen($aDrivesInfo[$y][1])) = $aDrivesInfo[$y][1] Then $vSolid = StringUpper($aDrivesInfo[$y][0]) & StringTrimLeft($sDeviceStr, StringLen($aDrivesInfo[$y][1])) ExitLoop EndIf Next If $vSolid Then Return $vSolid EndIf EndFunc Func _AdjustPrivilege($Type) Local $aReturn = DllCall("ntdll.dll", "int", "RtlAdjustPrivilege", "int", $Type, "int", 1, "int", 0, "int*", 0) If @error Or $aReturn[0] Then Return SetError(1, 0, 0) Return SetError(0, 0, 1) EndFunc ;==>AdjustPrivilege Edit - Sources: WinAPIEx --> '?do=embed' frameborder='0' data-embedContent>> The package includes the APIConstants.au3 Anonymous1 point
-
oapjr, Sure, I'll give it a go! Anonymous1 point
-
TomMelee, You might want to check out the included form designer of the >ISN AutoIt Studio AutoIt IDE. It's in beta, but it's maturing nicely and it makes it MUCH easier to create GUIs!1 point
-
Holy crap that's elegant. I'm nowhere near ready to parse strings from logfiles yet, but this is a fantastic example of how to do it. I'm still struggling with creating a GUI, lol. Thanks!1 point
-
What a lot of writing. And code too. Thank you. I have not had time to look at it yet. But I will look into it. glCallLists. There is nothing wrong with your code. But there was a bug in my code. You have my apologies. You can find a flawless function here: Func glCallLists( $n, $type, $lists ) If IsString( $lists ) Then If $type <> $GL_UNSIGNED_BYTE Then Return SetError( 1, 0, 0 ) DllCall( $dllOpenGL32, "none", "glCallLists", "int", $n, "uint", $type, "str", $lists ) If @error Then Return SetError( 3, 0, 0 ) ElseIf IsArray( $lists ) And UBound( $lists, 0 ) = 1 Then Local $sType, $l = UBound( $lists ), $struct Switch $type Case $GL_BYTE, $GL_UNSIGNED_BYTE $sType = "byte" Case $GL_SHORT $sType = "short" Case $GL_UNSIGNED_SHORT $sType = "ushort" Case $GL_INT $sType = "int" Case $GL_UNSIGNED_INT $sType = "uint" Case $GL_FLOAT $sType = "float" Case Else Return SetError( 1, 0, 0 ) EndSwitch $struct = DllStructCreate( $sType & "[" & $l & "]" ) For $i = 0 To $l - 1 DllStructSetData( $struct, 1, $lists[$i], $i + 1 ) Next DllCall( $dllOpenGL32, "none", "glCallLists", "int", $n, "uint", $type, "struct*", $struct ) If @error Then Return SetError( 3, 0, 0 ) Else Return SetError( 1, 0, 0 ) EndIf EndFunc Regards Lars.1 point