Jump to content

draien

Members
  • Posts

    19
  • Joined

  • Last visited

Recent Profile Visitors

139 profile views

draien's Achievements

Seeker

Seeker (1/7)

6

Reputation

  1. Hi I was searching for a while now and didn't find anything regarding this: Is there a function that returns the "number" of the monitor where the mouse is currently on screen? The same number that appears when you open windows-resolution and click on "identify" (or something). I want to trigger an event when the number changes. I wrote something that recognizes leaving the main monitor. But I couldn't get any further than that (maybe with _WinAPI_EnumDisplayMonitors/Devices/Settings ?) and I wouldn't catch an event, if someone has 3 monitors (aligned 1--2--3 with 1 being main monitor) and changes from 2 to 3. Here is my code: The GUI was just for testing. Maybe you can give me some hints :)?
  2. Hey rcmaehl, Thanks so much for the UDF. I have found 2 bugs when it comes to _IRCGetMsg Any message (e.g. PRIVMSG) ist not forwarded, when it contains umlauts/german mutations and when the message only contains a dot '.' I think this is due to the AscW at: Until AscW(StringRight($_vRecv, 1)) = 10 @Line 355. But I could be wrong. Is there a simple fix for this?
  3. There you go: ;Copy a certain column from Excel sheet to an Array Func _ReadFromExcel($column) Local $data Local $oExcel = _Excel_Open() If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Open", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) Local $oWorkbook = _Excel_BookOpen($oExcel, $xlsPath) If @error Then Switch @error Case 2 MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookOpen", "Specified Filepath does not exist" & @CRLF & "@error = " & @error & ", @extended = " & @extended) Case 3 MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookOpen", "Error opening the selected Excel file." & @CRLF & "@error = " & @error & ", @extended = " & @extended) Case 4 MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookOpen", "Readwrite access could not be granted. Workbook might be open by another users/task." & @CRLF & "@error = " & @error & ", @extended = " & @extended) EndSwitch ProcessClose("EXCEL.exe") Else $data = _Excel_RangeRead($oWorkbook, Default, $oWorkbook.ActiveSheet.Usedrange.Columns($column & ":" & $column), 2) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead", "Error reading from workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended) _Excel_Close($oExcel) EndIf Return $data EndFunc Just call it like: $xlsPath = "Excel.xls" ; Path to your excelsheet $aExcelCol = _ReadFromExcel("A")
  4. Okay now I am confused. $rowcount += 1 ; want to add rows below that You want to add empty rows after the last row used? Why? I mean this doesn't change a thing at all, because the rows after the last used row, are already empty.
  5. Hi As santhoshkumargr stated, the "2:2" is specified as a ExcelRange So for your goal to insert rows at the end of sheet, you have to get where the sheet actually ends. Therefore you can use something like this: Local $aResult = _Excel_RangeRead($oWorkbook, Default,$oWorkbook.ActiveSheet.Usedrange.Columns("A:A")) $iCells = UBound($aResult)-1 MsgBox(0,"UsedRange in Column A",$iCells) So you know where your sheet actually ends and then you can insert rows with something like that: $iRows = 3 ;Number of Rows to Insert _Excel_RangeInsert($oWorkbook.ActiveSheet, $iCells & ":" & $iCells+$iRows)  
  6. Hello, I am currently in the progress of writing a Twitch UDF to interact with the API (KRAKEN). This is my first UDF so please point out any errors you find Special thanks to FaridAgl for his functions >here Before using this UDF, make sure to paste your client-ID into the UDF from here Current version: 0.2 - 24.02.2015 UDF source: ; =================================================================== ; Twitch.au3 - UDF ; v0.2 ; ; By: Matthäus "Draien" Häußler ; Last Updated: 24.02.2015 ; Tested with AutoIt Version 3.3.12.0 ; ; Discription: Paste your twitch client ID into the global const ; ; Special Thanks: ; "FaridAgl" - For the HTTPGet / HTTPPost (soon to come) function ; ; Main functions: ; _KRAKENINFO ; =================================================================== #include-once Global Const $HTTP_STATUS_OK = 200 Global Const $KRAKEN_URL = "https://api.twitch.tv/kraken/" Global Const $CLIENT_ID = "xxxxxx" ;Your Client ID ; #FUNCTION# ==================================================================================================================== ; Name ..........: _KRAKENINFO ; Description ...: Function to grab information from the KRAKEN/Twitch API ; Syntax ........: _KRAKENINFO($sChannel) ; Parameters ....: $sChannel - Name of the Stream/Channel to check as string ; Return values .: Successful - Returns an array with information about the stream/channel ; $aINFO[0] = Status (1, if online ; 0, if offline) ; $aINFO[1] = Displayname (String) ; $aINFO[2] = Game (String) ; $aINFO[3] = Title (String) ; $aINFO[4] = Followercount (Number) ; $aINFO[5] = Total Views (Number) ; $aINFO[6] = Live-Viewercount (Number, if online ; empty, if offline) ; Failure - Returns 0 and sets @error: ; |1 = Invalid Channel, sets @extended: (1, if empty; 2, if whitespace is found) ; |2 = Problem with _HTTPGet ; Author ........: Draien ; ================================================================================================================================ Func _KRAKENINFO($sChannel) Local $aINFO[7] Local $iEND = ',' Select ;Parameter Checking, Trust No One Case $sChannel = "" Return SetError(1, 1, 0) Case StringInStr($sChannel," ") Return SetError(1, 2, 0) EndSelect $sGet = _HTTPGet($KRAKEN_URL & "streams/" & $sChannel) If (@error) Then Return SetError(2, 0, 0) If StringInStr($sGet,'"stream":null') Then $sGet = _HTTPGet($KRAKEN_URL & "channels/" & $sChannel) $aINFO[0] = 0 Else $aINFO[0] = 1 $aINFO[6] = '"viewers":' EndIf $aINFO[1] = '"display_name":"' $aINFO[2] = '"game":"' $aINFO[3] = '"status":"' $aINFO[4] = '"followers":' $aINFO[5] = '"views":' For $x = 1 To UBound($aINFO) -1 If $aINFO[$x] <> "" Then ;Avoid searching for live-viewers when offline $iINFOs = StringInStr($sGet,$aINFO[$x])+StringLen($aINFO[$x]) ;Total start position for a value $iINFOe = StringInStr($sGet,$iEND,0,1,$iINFOs) ;Total end position for a value $aINFO[$x] = StringMid($sGet,$iINFOs,$iINFOe-$iINFOs) EndIf Next ;Last Stripping of unecessary things $aINFO[1] = StringTrimRight($aINFO[1],1) $aINFO[2] = StringTrimRight($aINFO[2],1) $aINFO[3] = StringTrimRight($aINFO[3],1) Return $aINFO EndFunc ;==>_KRAKENINFO ; #FUNCTION# ==================================================================================================================== ; Name ..........: _HTTPGet ; Description ...: Get function to interact with Kraken / Twitch-API ; Syntax ........: _HTTPGet($sData) ; Parameters ....: $sData - Data to get as string. ; Return values .: Success - Returns ResponseText ; Failure - Returns 0 and sets @error ; Author ........: FaridAgl ; Modified ......: - ; Remarks .......: ; Related .......: _HTTPPost ; Link ..........: ; Example .......: No ; ================================================================================================================================ Func _HTTPGet($sURL, $sData = "") Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1") $oHTTP.Open("GET", $sURL & "?" & $sData, False) If (@error) Then Return SetError(1, 0, 0) $oHTTP.SetRequestHeader("Client-ID: " & $CLIENT_ID) $oHTTP.Send() If (@error) Then Return SetError(2, 0, 0) If ($oHTTP.Status <> $HTTP_STATUS_OK) Then Return SetError(3, 0, 0) Return SetError(0, 0, $oHTTP.ResponseText) EndFunc Example: #include "Twitch.au3" #include <Array.au3> $sGet = _KRAKENINFO("syndicate") _ArrayDisplay($sGet) Function overview: _KRAKENINFO Changelog I'd appreciate any feedback Twitch.au3
  7. This topic was not intended to be 'Does AutoIt run on XYZ OS?', but rather building up some hype for RasPi 2 and how much people would like too see AutoIt running on that. I thought so too :/ But from what I know about AutoIt and it having Windows as a requirement, it just made me so happy that there might be a possibility. Maybe with a kit that de-/encodes the code hardwarewise and translates it to a fitting language But then it would be easier to just invent a similar language that runs on those CPUs
  8. So, The raspberry pi 2 is more or less available now and Microsoft has announced Windows 10 for the RasPi 2 (see here). So, is there a possibility that AutoIt may be available for the Raspberry Pi 2? Would you like to see AutoIt working on a RasPi? What's your thought on that? Just asking out of curiosity. I for myself will probably end up learning Python more to automatize stuff if AutoIt won't be available. (So far I made a script to automatically synchronize two folders, one being on a NAS). But this announcement made me think
  9. (Had some similar question) Just added 1 line and now it works perfectly fine: Func _ConsoleWrite($sUser,$sMessage,$cColor=0xFFFFFF) ;GUICtrlSetColor($Console,$cColor) GUICtrlCreateListViewItem(@HOUR&":"&@MIN&":"&@SEC&"|"&$sUser&"|"&$sMessage,$Console) GuiCtrlSetColor(-1,$cColor) ;GUICtrlSetColor($Console,$DefaultFontColor) EndFunc  I think the colors have to be assigned to the ListViewItem, not the console itself, because the console is limited to actually what you see. So you either handle it like abberration stated with WinMove (to let AutoIT know when it was scrolled and to recolor everything again) or by simply using the code above.
  10. Wouldn't it be easier to just copy-paste this? Use Clipget() and ClipPut() Like in the following: ClipPut(GUICtrlRead($YOURTEXTBOXHERE)) ;Activate your top most window ClipPut() ;Or Send("{^v}")
  11. From the Send-Helpfile: To get the Unicode of a character you have to use: AscW ( "char" )  But AutoIt doesn't fully support all UNICODE characters (just read through the helpfile)
  12. This error indicates that $Status is not an array. So lets debug here for a second: _StringBetween returns an array if something is found The variable is not an array The questions you have to ask yourself here is: Did _StringBetween found something? (no) Possible causes: Path/Url to the file is wrong. Did you edit this? $content = _GetSource(@ScriptDir & "\Test.htm") You have to edit @ScriptDir &"Test.htm" to your path of the htm (or copy-paste the htm in your Scriptdirectory)... I think it would be this: $content = _INetGetSource("C:\Data\Auto ITs\check\Test.htm")
  13. Even though this is horrible scripted (I tried to fit in different ways to handle this), but it works for me: Edit the $content = _GetSource to your benefiting. If you want to get it via _INETGetSource then you have to call the function with $content = _GetSource("http://yourdomainhere.com",2) HotKeySet("{ESC}", "Terminate") Opt("WinTextMatchMode", 2) ;1=complete, 2=quick Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase AutoItSetOption("MouseCoordMode", 0) opt("SendKeyDelay",90) opt("WinWaitDelay",35) opt("TrayIconDebug",1) #include <IE.au3> #include <Inet.au3> #include <Array.au3> #include <String.au3> #include <MsgBoxConstants.au3> If FileExists(@ScriptDir & "\check.csv") =false Then FileWrite(@ScriptDir & "\check.csv","Actief;Lidstaat;nummer;Tijdstip waarop de aanvraag werd ontvangen;Naam;Adres;Cnummer"& @CRLF) EndIf $content = _GetSource(@ScriptDir & "\Test.htm") $start_Status = '<td class="labelLeft" colspan="3"><b><span class="validStyle">' $end_Status = '</span></b></td>' $Status = _StringBetween($content,$start_Status,$end_Status) $Lidstaat = _GrabValue($content,4) $nr = _GrabValue($content,7) $Tijd = _GrabValue($content,9) $Naam = _GrabValue($content,11) $Naam = StringReplace($Naam,@CRLF,"") $Adres = _GrabValue($content,13) $Adres = StringReplace($Adres,"<br />","") $Adres = StringReplace($Adres,@CRLF,"") $Cnummer = _GrabValue($content,15) $aio= $Status[0]&";"&$Lidstaat&";"&$nr&";"&$Tijd&";"&$Naam&";"&$Adres&";"&$Cnummer MsgBox(0,"",$aio) FileWrite ( "check.csv", $aio & @CRLF ) Func _GrabValue($sContent,$iOccurence) Local $start Local $end $start = StringInStr($sContent,"<td",0,$iOccurence) $start += 4 $end = StringInStr($content,"</td>",0,$iOccurence) Return StringMid($content,$start,$end - $start) EndFunc Func _GetSource($sHandle,$iMode=1) Switch $iMode Case 1 Return FileRead($sHandle) Case 2 Return _INetGetSource($sHandle) Case Else Return 0 EndSwitch EndFunc Func Terminate() Exit 0 EndFunc
  14. Hi Kap, For me _INetGetSource only works for domains (e.g. www.google.com) not for local html documents. For local documents you could use: FileRead("C:\Data\Auto ITs\check\Test.htm") _StringBetween for $Lidstaat doesn't really work as you are trying to get the _StringBetween to jump a line (you have to edit some @CRLF and @TABS in there). I would recommend trying a complete different method, e.g. finding "<td>" (its the second one for the NL you want to have). Or get the linenumber of "Lidstaat", assign the line+1 to a variable. Strip the last 5 characters (</td>) and the first 8(? because of @TAB right?) characters, then you should have your NL. Also: _StringBetween returns an Array (0-based , look in the Help file ) So when assigning the contents you should write: $aio= $Status[0]&";"&$Lidstaat[0]&";"&$nr[0]&";"&$Tijd[0]&";"&$Naam[0]&";"&$Adres[0]&";"&$Cnummer[0]
  15. Of course that's possible. But what exactly are you trying to achieve? Stress test? There are many services online for stress testing (loadimpact, etc.). Are you the owner of this site? Getting kinda curious here...
×
×
  • Create New...