Jump to content

dragan

Active Members
  • Posts

    180
  • Joined

  • Last visited

  • Days Won

    2

Community Answers

  1. dragan's post in Chrome UDF|twitch.tv|chat monitoring was marked as the answer   
    I feel generous today...

     
    #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiRichEdit.au3> #include <GuiMenu.au3> #include <IE.au3> Global const $twitchURL = "http://www.twitch.tv/" Global $twitch_ID = "snejkipl"; Global $isVisible = 1; Global $fullUrl = $twitchURL & $twitch_ID Global $LastMessage = "" Global $width = 800, $height = 600 Global $Form1 = GUICreate("Twitch Chat details for: " & $twitch_ID, $width, $height) Global $hRichEdit = _GUICtrlRichEdit_Create($Form1, "", 0, 0, $width, $height, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL, $ES_READONLY)) GUISetState(@SW_SHOW) AppedSystemMessage("Please wait while I start IE..." & @CRLF) Global $oIE = _IECreate("about:blank", 0, $isVisible); GUIRegisterMsg($WM_SYSCOMMAND, "WM_SYSCOMMAND") GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") _GUICtrlRichEdit_SetEventMask($hRichEdit, $ENM_LINK) _GUICtrlRichEdit_AutoDetectURL($hRichEdit, True) AppedSystemMessage("Please wait while I load up: " & $fullUrl & @CRLF) _IENavigate($oIE, $fullUrl); AppedSystemMessage("Please wait while the chat loads up..." & @CRLF) While 1 Sleep(100) _CheckForMessages() WEnd Func _CheckForMessages() If NOT IsObj($oIE) Then Return $chatObject = _IEGetObjById($oIE, "chat") If NOT IsObj($chatObject) Then Return $divsInChat = _IETagNameGetCollection($chatObject, "div") if IsObj($divsInChat) Then $addMessages = False for $oneDivInChat in $divsInChat if StringInStr($oneDivInChat.classname, "ember-view chat-line") Then $allSpans = _IETagNameGetCollection($oneDivInChat, "span") if IsObj($allSpans) Then $curMessage = ""; $stringColor = "0x00000000"; for $oneSpan in $allSpans Switch $oneSpan.classname case "timestamp" $curMessage &= "<" & $oneSpan.innertext & "> " case "from" if ($oneSpan.innertext = "jtv") Then $stringColor = "0x00C3C3C3" Else $curMessage &= $oneSpan.innertext & ": " $pulledColor = StringReplace(StringReplace($oneSpan.style.getAttribute('color'), "rgb(", ""), ")", ""); $splitCol = StringSplit($pulledColor, ',') if ($splitCol[0] >= 3) Then $stringColor = "0x00" & Hex(Number(StringStripWS($splitCol[3], 3)), 2) & Hex(Number(StringStripWS($splitCol[2], 3)), 2) & Hex(Number(StringStripWS($splitCol[1], 3)), 2) EndIf case "message" if (StringLen(StringStripWS($oneSpan.innertext, 3)) > 0) AND (String($oneSpan.innertext) <> "0") Then $curMessage &= $oneSpan.innertext $allSpans2 = _IETagNameGetCollection($oneSpan, "span") if IsObj($allSpans2) Then for $oneSpan2 in $allSpans2 if StringInStr($oneSpan2.classname, "emoticon") Then $curMessage &= "[" & StringReplace($oneSpan2.classname, "emoticon ", "") & "]" Next EndIf EndSwitch Next if (StringLen($LastMessage) = 0 OR $addMessages) Then AppendUserMessage($curMessage & @CRLF, $stringColor) $LastMessage = $curMessage Else if $LastMessage = $curMessage then $addMessages = True EndIf EndIf EndIf Next EndIf EndFunc func AppendUserMessage($sText, $iColor) _GUICtrlRichEdit_AppendTextColor($hRichEdit, $sText, $iColor) EndFunc Func AppedSystemMessage($sText) _GUICtrlRichEdit_AppendTextColor($hRichEdit, $sText, 0x00C3C3C3) EndFunc Func _GUICtrlRichEdit_AppendTextColor($hWnd, $sText, $iColor) Local $iLength = _GUICtrlRichEdit_GetTextLength($hWnd, True, True) Local $iCp = _GUICtrlRichEdit_GetCharPosOfNextWord($hWnd, $iLength) _GUICtrlRichEdit_AppendText($hWnd, $sText) _GUICtrlRichEdit_SetSel($hWnd, $iCp-1, $iLength + StringLen($sText)) _GUICtrlRichEdit_SetCharColor($hWnd, $iColor) _GuiCtrlRichEdit_Deselect($hWnd) EndFunc Func WM_SYSCOMMAND($hWnd, $iMsg, $WParam, $LParam) Switch $hWnd Case $Form1 Switch $WParam Case $SC_CLOSE _GUICtrlRichEdit_Destroy($hRichEdit) _IEQuit($oIE) Exit EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Func WM_NOTIFY($hWnd, $iMsg, $iWparam, $iLparam) #forceref $hWnd, $iMsg, $iWparam Local $hWndFrom, $iCode, $tNMHDR, $tEnLink, $cpMin, $cpMax, $tMsgFilter $tNMHDR = DllStructCreate($tagNMHDR, $iLparam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hRichEdit Select Case $iCode = $EN_LINK $tMsgFilter = DllStructCreate($tagMSGFILTER, $iLparam) If DllStructGetData($tMsgFilter, "msg") = $WM_LBUTTONUP Then $tEnLink = DllStructCreate($tagENLINK, $iLparam) $cpMin = DllStructGetData($tEnLink, "cpMin") $cpMax = DllStructGetData($tEnLink, "cpMax") ShellExecute(_GUICtrlRichEdit_GetTextInRange($hRichEdit, $cpMin, $cpMax)); EndIf EndSelect EndSwitch Return $GUI_RUNDEFMSG EndFunc EDIT :
    I just realized, that twitch chat is powered by IRC. And there are plenty of IRC scripts in here. You just need to get the correct parameters (server, port, channel...).
    You can also build a chat bot with mIRC:

  2. dragan's post in Help with converting C to autoit, a DLLCall failes was marked as the answer   
    Your script failed on my PC at CrateFileW function.
    I was able to test this successfully on my PC though:
    $retVal = testFunc(@WindowsDir & "\notepad.exe") if NOT @error then MsgBox(0, "HCATINFO", "Success: " & @CRLF & @CRLF & $retVal) Else MsgBox(0, "Error", "Error code: " & @error & @CRLF & @CRLF & $retVal) EndIf func testFunc($sFile) Local $pContext $context = DllCall('Wintrust.dll', 'BOOL', 'CryptCATAdminAcquireContext', 'ptr*', $pContext, 'ptr', 0, 'DWORD', 0) If @error Or Not $context[0] Then Return SetError(1, 0, "CryptCATAdminAcquireContext failed to return pContext") $context = $context[1] Local $a_hCall = DllCall("kernel32.dll", "hwnd", "CreateFileW", _ "wstr", $sFile, _ "dword", 0x80000000, _ ; GENERIC_READ "dword", 1, _ ; FILE_SHARE_READ "ptr", 0, _ "dword", 3, _ ; OPEN_EXISTING "dword", 0, _ ; SECURITY_ANONYMOUS "ptr", 0) If @error Or $a_hCall[0] = -1 Then Return SetError(2, 0, "CreateFileW function failed") Local $hFile = $a_hCall[0] Local $cbHash = 0 $cbHash = DllCall('Wintrust.dll', 'BOOL', 'CryptCATAdminCalcHashFromFileHandle', 'handle', $hFile, 'DWORD*', $cbHash, 'ptr', 0, 'dword', 0) If @error Or Not $cbHash[0] Then _WinAPI_CloseHandleEx($hFile) Return SetError(3, 0, "CryptCATAdminCalcHashFromFileHandle failed to return cbHash") EndIf $cbHash = $cbHash[2] Local $Buffer = DllStructCreate('BYTE[' & $cbHash & ']') $pbHash = DllStructGetPtr($Buffer, 1) $cbHash = DllCall('Wintrust.dll', 'BOOL', 'CryptCATAdminCalcHashFromFileHandle', 'handle', $hFile, 'DWORD*', $cbHash, 'ptr', $pbHash, 'DWORD', 0) If @error Or Not $cbHash[0] Then _WinAPI_CloseHandleEx($hFile) Return SetError(4, 0, "CryptCATAdminCalcHashFromFileHandle failed to return cbHash, #2") EndIf $cbHash = $cbHash[2] _WinAPI_CloseHandleEx($hFile) Local $CatalogContext = DllCall('Wintrust.dll', 'handle', 'CryptCATAdminEnumCatalogFromHash', 'handle', $context, 'ptr', $pbHash, 'DWORD', $cbHash, 'DWORD', 0, "handle", 0) If @error Or not $CatalogContext[0] Then Return SetError(5, 0, "CryptCATAdminEnumCatalogFromHash failed to return HCATINFO") $CatalogContext = $CatalogContext[0] Return $CatalogContext EndFunc ; #FUNCTION# ==================================================================================================================== ; Author ........: Paul Campbell (PaulIA) ; Modified.......: ; =============================================================================================================================== Func _WinAPI_CloseHandleEx($hObject) Local $aResult = DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hObject) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc ;==>_WinAPI_CloseHandle
  3. dragan's post in Embedded Window Media Player in GUI was marked as the answer   
    It seems that the WMP can't change aspect ratio, so you can't stretch to fill both: desired width and desired height.
    http://www.sevenforums.com/music-pictures-video/163445-stretch-videos-wmp.html
    http://stackoverflow.com/questions/15749181/stretch-video-of-axwindowsmediaplayer-without-maintaining-aspect-ration-in-c-sha
    But you can stretch to the either one of those:
     
    #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <IE.au3> Global $width = 800 Global $height = 450 Global $IEControl; = null; Global $MyGUI = GUICreate("WMPlayer Control", $width,$height,(@DesktopWidth-$width)/2,(@DesktopHeight-$height)/2, $WS_OVERLAPPEDWINDOW) Global $oIE = _GUICtrl_CreateWMPlayer("about:blank", 0, 0, $width, $height) GUISetState (@SW_SHOW, $MyGUI) GUIRegisterMsg($WM_SIZE, "WM_SIZE") Global $playerOBJ = _IEGetObjById($oIE, "objWMPlayer") if NOT IsObj($playerOBJ) Then MsgBox(0, "Error", "WMP failed to be created."); Exit; EndIf ;~ $FileOpen = "C:\Users\Public\Videos\Sample Videos\Wildlife.wmv"; $FileOpen = FileOpenDialog("Open Videos", @UserProfileDir, "Movies (*.3gp;*.mp4;*.avi;*.wmv;*.flv)") If Not @error Then _wmpvalue($playerOBJ, "nocontrols") _wmploadmedia($playerOBJ,$FileOpen) $mediaName = _wmpvalue($playerOBJ, "getname"); WinSetTitle($MyGUI, "", "Playing video: " & $mediaName) Else Exit; EndIf While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit; EndSwitch WEnd Func WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam, $ilParam Local $xClient, $yClient $xClient = BitAND($ilParam, 0x0000FFFF) $yClient = BitShift($ilParam, 16) GUICtrlSetPos($IEControl, 0, 0, $xClient, $yClient) if NOT @error Then if IsObj($playerOBJ) Then $playerOBJ.width = $xClient; if IsObj($playerOBJ) Then $playerOBJ.height = $yClient; EndIf Return $GUI_RUNDEFMSG EndFunc ;=============================================== ;=============================================== ;=============================================== #cs _wmploadmedia( $object, $URL ) $object: Object returned from the $playerOBJ = _IEGetObjById($oIE, "objWMPlayer") $URL: Path or URL of the media Return: None #ce Func _wmploadmedia( $object, $URL) $object.URL = $URL While Not $object.controls.isAvailable("play") Sleep(1) WEnd $object.controls.play() EndFunc ; Function: _GUICtrl_CreateWMPlayer ; Purpose: Embed Windows Media Player and play one file or one playlist only. ; Notes: PARAM NAME="url" is ReadOnly ; Authors: squirrely1 ; borderless IE embed example: GaryFrost ; Kudos - Kare Johansson, CFire ; References: ; http://msdn2.microsoft.com/en-us/library/ms930698.aspx ; http://www.w3schools.com/media/media_playerref.asp ; clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6 - wmplayer latest installed version ; clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95 - wmp 6.4 ;=============================================== Func _GUICtrl_CreateWMPlayer($movieURL, $playerLeft, $playerTop, $playerWidth, $playerHeight, _ $insetBorders = 0, $fullscreenMode = False, $showControls = True, $enableContextMenu = True, _ $LoopMode = false, $playCount = 1, $playVolume = 100, $playBalance = 0, $enableFullScreenControls = True) If $fullscreenMode Then $fullscreenMode = "true" Else $fullscreenMode = "false" EndIf If $showControls Then $showControls = "true" Else $showControls = "false" EndIf If $enableContextMenu Then $enableContextMenu = "true" Else $enableContextMenu = "false" EndIf If $LoopMode Then $playCount = 999 EndIf If $enableFullScreenControls Then $enableFullScreenControls = "true" Else $enableFullScreenControls = "false" EndIf Local $myIE_Obj = _IECreateEmbedded () $IEControl = GUICtrlCreateObj($myIE_Obj, $playerLeft, $playerTop, $playerWidth, $playerHeight) _IENavigate($myIE_Obj, "about:blank") Local $htmlWMP $htmlWMP = '' _ & @CR & '<body style="margin:0;padding:0" >' _ & @CR & '<OBJECT' _ & @CR & 'ID="objWMPlayer"' _ & @CR & 'STYLE="margin:0;padding:0"' _ & @CR & 'HSPACE="0"' _ & @CR & 'VSPACE="0"' _ & @CR & 'BORDER="0"' _ & @CR & 'WIDTH="' & $playerWidth & '"' _ & @CR & 'HEIGHT="' & $playerHeight & '"' _ & @CR & 'CLASSID="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6"' _ & @CR & 'STANDBY="Loading Windows Media Player components..."' _ & @CR & 'TYPE="application/x-ms-wmp">' _ & @CR & '<PARAM NAME="allowHideControls" VALUE="true">' _ & @CR & '<PARAM NAME="autoStart" VALUE="false">' _ & @CR & '<PARAM NAME="audioStream" VALUE="false">' _ & @CR & '<PARAM NAME="autoSize" VALUE="false">' _ & @CR & '<PARAM NAME="balance" VALUE="' & $playBalance & '"><!-- -100 to 100 -->' _ & @CR & '<!-- <PARAM NAME="bufferingTime" VALUE="5"><!-- seconds -->' _ & @CR & '<PARAM NAME="clickToPlay" VALUE="false"><!-- has no effect -->' _ & @CR & '<PARAM NAME="currentPosition" VALUE="0"><!-- start position within video, in seconds -->' _ & @CR & '<PARAM NAME="enableContextMenu" VALUE="' & $enableContextMenu & '">' _ & @CR & '<PARAM NAME="enableFullScreenControls" VALUE="' & $enableFullScreenControls & '">' _ & @CR & '<PARAM NAME="enabled" VALUE="true"><!-- whether controls are enabled -->' _ & @CR & '<PARAM NAME="fullScreen" VALUE="' & $fullscreenMode & '">' _ & @CR & '<PARAM NAME="mute" VALUE="false">' _ & @CR & '<PARAM NAME="playCount" VALUE="' & $playCount & '">' _ & @CR & '<!-- <PARAM NAME="previewMode" VALUE="true"> -->' _ & @CR & '<PARAM NAME="rate" VALUE="1"><!-- play speed of -.5 to 2 increments of .1 -->' _ & @CR & '<PARAM NAME="sendPlayStateChangeEvents" VALUE="false">' _ & @CR & '<PARAM NAME="showCaptioning" VALUE="false">' _ & @CR & '<PARAM NAME="showControls" VALUE="' & $showControls & '">' _ & @CR & '<PARAM NAME="showGotoBar" VALUE="false">' _ & @CR & '<PARAM NAME="showPositionControls" VALUE="true"><!-- uiMode must = "full" -->' _ & @CR & '<PARAM NAME="showStatusBar" VALUE="false"><!-- has no effect -->' _ & @CR & '<PARAM NAME="showDisplay" VALUE="true"><!-- has no effect - reportedly shows filename -->' _ & @CR & '<PARAM NAME="stretchToFit" VALUE="true">' _ & @CR & '<PARAM NAME="uiMode" VALUE="full"><!-- invisible, none, mini, full -->' _ & @CR & '<!-- <PARAM NAME="videoBorderWidth" VALUE="0"> -->' _ & @CR & '<PARAM NAME="volume" VALUE="' & $playVolume & '"><!-- volume percent setting of wmplayer.exe -->' _ & @CR & '<PARAM NAME="windowlessVideo" VALUE="false"><!-- must be the default (false) for function to work in wmp 9.0, otherwise might renders video directly in the client area -->' _ & @CR & '</OBJECT>' _ & @CR & '</body>' _IEDocWriteHTML ($myIE_Obj, $htmlWMP) _IEAction ($myIE_Obj, "refresh") $myIE_Obj.document.body.scroll = "no" $myIE_Obj.document.body.style.border = $insetBorders Return $myIE_Obj EndFunc ;==>_GUICtrl_CreateWMPlayer Func _wmpvalue( $object, $setting, $para=1 ) Switch $setting Case "play" If $object.controls.isAvailable("play") Then $object.controls.play() case "stop" If $object.controls.isAvailable("stop") Then $object.controls.stop() case "pause" If $object.controls.isAvailable("pause") Then $object.controls.pause() case "invisible" $object.uiMode = "invisible" case "controls" $object.uiMode = "full" case "nocontrols" $object.uiMode = "none" case "fullscreen" $object.fullscreen = "True" Case "step" If $object.controls.isAvailable("step") Then $object.controls.step($para) Case "fastForward" If $object.controls.isAvailable("fastForward") Then $object.controls.fastForward() Case "fastReverse" If $object.controls.isAvailable("fastReverse") Then $object.controls.fastReverse() Case "volume" $object.settings.volume = $para Case "rate" $object.settings.rate = $para Case "playcount" $object.settings.playCount = $para Case "setposition" $object.controls.currentPosition = $para Case "getposition" Return $object.controls.currentPosition Case "getpositionstring" Return $object.controls.currentPositionString Case "getduration" Return $object.currentMedia.duration Case "getname" Return $object.currentMedia.name EndSwitch EndFunc
  4. dragan's post in how to easily get the subnet mask? was marked as the answer   
    if you're still interested, this is the way via Iphlpapi.dll:
     
    $theIP1 = @IPAddress1 $subnetIP = _GetSubnetBasedOnIP($theIP1) if NOT @error then Local $type = '' Switch @extended Case 0 $type = 'Regular adapter IP' Case 1 $type = 'Gateway IP' Case 2 $type = 'DHCP Server IP' Case 3 $type = 'PrimaryWinsServer IP' Case 4 $type = 'SecondaryWinsServer IP' Case Else $type = 'Unknown IP' EndSwitch MsgBox(0, 'Success', 'For IP:' & @TAB & $theIP1 & @CRLF & 'Subnet is:' & @TAB & $subnetIP & @CRLF & 'IP Type:' & @TAB & $type) Else Switch @error Case 1 MsgBox(0, 'Error 1', 'Input IP [' & $theIP1 & '] is not a valid IP address.') Case 2 MsgBox(0, 'Error 2', 'Input IP [' & $theIP1 & '] was not found on this computer.') Case 3 MsgBox(0, 'Error 3', 'dll open: Iphlpapi.dll, error code: ' & @extended) Case 4 MsgBox(0, 'Error 4', 'dll call function: GetAdaptersInfo, error code: ' & @extended) Case 5 MsgBox(0, 'Error 5', 'dll call function: GetAdaptersInfo with adapter buffer pointer, error code: ' & @extended) Case Else MsgBox(0, 'Error X', 'Unknown error occured for the input IP [' & $theIP1 & '].') EndSwitch EndIf ;========================================================================================================================================================== ;========================================================================================================================================================== Func _GetSubnetBasedOnIP($theIP) if NOT _isIPaddr($theIP) Then Return SetError(1, 0, 0) Local Const $tagIP_ADDRESS_STRING = "char IPAddress[16];" Local Const $tagIP_MASK_STRING = "char IPMask[16];" Local Const $tagIP_ADDR_STRING = "ptr Next;" & $tagIP_ADDRESS_STRING & $tagIP_MASK_STRING & "DWORD Context;" Local Const $tagIP_ADAPTER_INFO = "ptr Next; DWORD ComboIndex; char AdapterName[260];char Description[132]; UINT AddressLength; BYTE Address[8]; dword Index; UINT Type;" & _ " UINT DhcpEnabled; ptr CurrentIpAddress; ptr IpAddressListNext; char IpAddressListADDRESS[16]; char IpAddressListMASK[16]; DWORD IpAddressListContext; " & _ "ptr GatewayListNext; char GatewayListADDRESS[16]; char GatewayListMASK[16]; DWORD GatewayListContext; " & _ "ptr DhcpServerNext; char DhcpServerADDRESS[16]; char DhcpServerMASK[16]; DWORD DhcpServerContext; " & _ "int HaveWins; " & _ "ptr PrimaryWinsServerNext; char PrimaryWinsServerADDRESS[16]; char PrimaryWinsServerMASK[16]; DWORD PrimaryWinsServerContext; " & _ "ptr SecondaryWinsServerNext; char SecondaryWinsServerADDRESS[16]; char SecondaryWinsServerMASK[16]; DWORD SecondaryWinsServerContext; " & _ "DWORD LeaseObtained; DWORD LeaseExpires;" Local $dll = DllOpen("Iphlpapi.dll") If @error then Return SetError(3, @error, 0) Local $ret = DllCall($dll, "dword", "GetAdaptersInfo", "ptr", 0, "dword*", 0) If @error then DllClose($dll) Return SetError(4, @error, 0) EndIf Local $adapterBuffer = DllStructCreate("byte[" & $ret[2] & "]") Local $adapterBuffer_pointer = DllStructGetPtr($adapterBuffer) DllCall($dll, "dword", "GetAdaptersInfo", "ptr", $adapterBuffer_pointer, "dword*", $ret[2]) If @error then $adapterBuffer = "" $adapterBuffer_pointer = "" DllClose($dll) Return SetError(5, @error, 0) EndIf Local $adapter = DllStructCreate($tagIP_ADAPTER_INFO, $adapterBuffer_pointer) Local $IPType = -1 Local $FoundIt = False Local $retVal = "" Do Local $allArray = _GetAllIps(DllStructGetPtr($adapter, "IpAddressListNext"), $tagIP_ADDR_STRING) if IsArray($allArray) Then For $i = 0 to UBound($allArray)-1 if NOT _isIPaddr($allArray[$i][0]) then ContinueLoop if $allArray[$i][0] <> $theIP Then ContinueLoop if NOT _isIPaddr($allArray[$i][1]) then ContinueLoop $retVal = $allArray[$i][1] $IPType = 0 $FoundIt = True ExitLoop Next EndIf if NOT $FoundIt Then $allArray = _GetAllIps(DllStructGetPtr($adapter, "GatewayListNext"), $tagIP_ADDR_STRING) if IsArray($allArray) Then For $i = 0 to UBound($allArray)-1 if NOT _isIPaddr($allArray[$i][0]) then ContinueLoop if $allArray[$i][0] <> $theIP Then ContinueLoop if NOT _isIPaddr($allArray[$i][1]) then ContinueLoop $retVal = $allArray[$i][1] $IPType = 1 $FoundIt = True ExitLoop Next EndIf EndIf if NOT $FoundIt Then Local $ptr1 = DllStructGetPtr($adapter, "DhcpServerNext") Local $IPStruct = DllStructCreate($tagIP_ADDR_STRING,$ptr1) Local $curIP = DllStructGetData($IPStruct,"IPAddress") Local $curSubnet = DllStructGetData($IPStruct,"IPMask") if _isIPaddr($curIP) AND _isIPaddr($curSubnet) Then if $curIP = $theIP then $retVal = $curSubnet $IPType = 2 $FoundIt = True EndIf EndIf EndIf if NOT $FoundIt Then Local $ptr1 = DllStructGetPtr($adapter, "PrimaryWinsServerNext") Local $IPStruct = DllStructCreate($tagIP_ADDR_STRING,$ptr1) Local $curIP = DllStructGetData($IPStruct,"IPAddress") Local $curSubnet = DllStructGetData($IPStruct,"IPMask") if _isIPaddr($curIP) AND _isIPaddr($curSubnet) Then if $curIP = $theIP then $retVal = $curSubnet $IPType = 3 $FoundIt = True EndIf EndIf EndIf if NOT $FoundIt Then Local $ptr1 = DllStructGetPtr($adapter, "SecondaryWinsServerNext") Local $IPStruct = DllStructCreate($tagIP_ADDR_STRING,$ptr1) Local $curIP = DllStructGetData($IPStruct,"IPAddress") Local $curSubnet = DllStructGetData($IPStruct,"IPMask") if _isIPaddr($curIP) AND _isIPaddr($curSubnet) Then if $curIP = $theIP then $retVal = $curSubnet $IPType = 4 $FoundIt = True EndIf EndIf EndIf if $FoundIt Then ExitLoop $ptr = DllStructGetData($adapter, "Next") $adapter = DllStructCreate($tagIP_ADAPTER_INFO, $ptr) Until @error $adapterBuffer = "" $adapterBuffer_pointer = "" DllClose($dll) if NOT $FoundIt Then Return SetError(2, 0, 0) Return SetError(0, $IPType, $retVal) EndFunc Func _GetAllIps($Ptr, $tagIP_ADDR_STRING) Local $IPStruct, $Index = 0 Local $IPArray[1][3] Do ReDim $IPArray[$Index+1][3] $IPStruct = DllStructCreate($tagIP_ADDR_STRING,$ptr) $IPArray[$Index][0] = DllStructGetData($IPStruct,"IPAddress") $IPArray[$Index][1] = DllStructGetData($IPStruct,"IPMask") $IPArray[$Index][2] = DllStructGetData($IPStruct,"Context") $Ptr = DllStructGetData($IPStruct,"Next") $Index += 1 Until $Ptr = 0 Return $IPArray EndFunc Func _isIPaddr($sIPAddr) If NOT StringRegExp($sIPAddr, "^((25[0-5]|2[0-4]\d|[01]?\d?\d)\.){3}(25[0-5]|2[0-4]\d|[01]?\d?\d)$") Then Return SetError(1, 0, False) Return True EndFunc
  5. dragan's post in extracting link from href tag was marked as the answer   
    - Get all elements with tagname "a"
    - For each element in those elements
    - If element.classname equals to "download rep_sprite_backup"
    - then that element.href is the data you need, and you can exit the "for each" loop.
  6. dragan's post in Getting an IE object for something that doesn't have an ID was marked as the answer   
    how about this:
     
    $allAelements = _IETagNameGetCollection($IEObject, "a") if IsObj($allAelements) Then For $oneAelement in $allAelements If $oneAelement.innertext == "Protect" Then _IEAction($oneAelement, "Focus") _IEAction($oneAelement, "Click") ExitLoop EndIf Next EndIf
  7. dragan's post in Help Modifying Code To Read Monitor Info was marked as the answer   
    You could have used >scriptomatic to get the code to read monitor info via WMI, and you can get manufacturer as well:
     
    $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $Output="" $Output = $Output & "Computer: " & $strComputer & @CRLF $Output = $Output & "==========================================" & @CRLF $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_DesktopMonitor", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems $Output = $Output & "Availability: " & $objItem.Availability & @CRLF $Output = $Output & "Bandwidth: " & $objItem.Bandwidth & @CRLF $Output = $Output & "Caption: " & $objItem.Caption & @CRLF $Output = $Output & "ConfigManagerErrorCode: " & $objItem.ConfigManagerErrorCode & @CRLF $Output = $Output & "ConfigManagerUserConfig: " & $objItem.ConfigManagerUserConfig & @CRLF $Output = $Output & "CreationClassName: " & $objItem.CreationClassName & @CRLF $Output = $Output & "Description: " & $objItem.Description & @CRLF $Output = $Output & "DeviceID: " & $objItem.DeviceID & @CRLF $Output = $Output & "DisplayType: " & $objItem.DisplayType & @CRLF $Output = $Output & "ErrorCleared: " & $objItem.ErrorCleared & @CRLF $Output = $Output & "ErrorDescription: " & $objItem.ErrorDescription & @CRLF $Output = $Output & "InstallDate: " & WMIDateStringToDate($objItem.InstallDate) & @CRLF $Output = $Output & "IsLocked: " & $objItem.IsLocked & @CRLF $Output = $Output & "LastErrorCode: " & $objItem.LastErrorCode & @CRLF $Output = $Output & "MonitorManufacturer: " & $objItem.MonitorManufacturer & @CRLF ;<--------- manufacturer $Output = $Output & "MonitorType: " & $objItem.MonitorType & @CRLF $Output = $Output & "Name: " & $objItem.Name & @CRLF $Output = $Output & "PixelsPerXLogicalInch: " & $objItem.PixelsPerXLogicalInch & @CRLF $Output = $Output & "PixelsPerYLogicalInch: " & $objItem.PixelsPerYLogicalInch & @CRLF $Output = $Output & "PNPDeviceID: " & $objItem.PNPDeviceID & @CRLF $strPowerManagementCapabilities = $objItem.PowerManagementCapabilities(0) $Output = $Output & "PowerManagementCapabilities: " & $strPowerManagementCapabilities & @CRLF $Output = $Output & "PowerManagementSupported: " & $objItem.PowerManagementSupported & @CRLF $Output = $Output & "ScreenHeight: " & $objItem.ScreenHeight & @CRLF $Output = $Output & "ScreenWidth: " & $objItem.ScreenWidth & @CRLF $Output = $Output & "Status: " & $objItem.Status & @CRLF $Output = $Output & "StatusInfo: " & $objItem.StatusInfo & @CRLF $Output = $Output & "SystemCreationClassName: " & $objItem.SystemCreationClassName & @CRLF $Output = $Output & "SystemName: " & $objItem.SystemName & @CRLF if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop $Output="" Next Else Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_DesktopMonitor" ) Endif Func WMIDateStringToDate($dtmDate) Return (StringMid($dtmDate, 5, 2) & "/" & _ StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _ & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2)) EndFunc
  8. dragan's post in Ctrl + A (Select all) Expected keys produce Ding sound was marked as the answer   
    Here's an example:
     
    #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiEdit.au3> #include <WinAPI.au3> $Form1 = GUICreate("Form1", 600, 400) $Edit1 = GUICtrlCreateEdit("Some text in Edit1" & @CRLF & "focus me, and press CTRL+A", 0, 0, 300, 400) $Edit2 = GUICtrlCreateEdit("Some text in Edit2" & @CRLF & "focus me, and press CTRL+A", 300, 0, 300, 400) GUISetState(@SW_SHOW) Global $hSelAll = GUICtrlCreateDummy() Dim $AccelKeys[1][2] = [["^a", $hSelAll]] GUISetAccelerators($AccelKeys, $Form1) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $hSelAll _SelectAllTextInEdit() EndSwitch WEnd Func _SelectAllTextInEdit();will make select all text in eny focused edit, as long as it is edit inside $Form1 winhandle because we bound GUISetAccelerators to $Form1 Local $theHandle = _WinAPI_GetFocus() Local $TheClass = _WinAPI_GetClassName($theHandle) If $TheClass = 'Edit' Then _GUICtrlEdit_SetSel($theHandle, 0, -1) EndFunc
  9. dragan's post in Help to open a file diferent user names was marked as the answer   
    by using
     
    @DesktopDir ?
  10. dragan's post in Java SWT Eclipse RCP Based Application - Automating with AutoIT was marked as the answer   
    I'm not sure that you can get text from those items, but you can automate them:

     
    #include <GuiTreeView.au3> _Main() Func _Main() Local $EclipseHWND = WinGetHandle('[CLASS:SWT_Window0]') If NOT IsHWnd($EclipseHWND) Then MsgBox(0, 'Error', 'NO Eclipse winHandle') Return SetError(1, 0, 0) EndIf Local $treeViewCtrl = ControlGetHandle($EclipseHWND, '', "[CLASS:SysTreeView32; INSTANCE:1]") If NOT IsHWnd($treeViewCtrl) Then MsgBox(0, 'Error', 'no Treeview handle') Return SetError(2, 0, 0) EndIf WinActivate($EclipseHWND) Local $totalNoOfItems = _GUICtrlTreeView_GetCount($treeViewCtrl) If $totalNoOfItems = 0 Then MsgBox(0, 'Error', 'Treeview is empty, there are no items to expand.') Return SetError(3, 0, 0) Else _GUICtrlTreeView_Expand($treeViewCtrl, 0, False) EndIf MsgBox(0, 'Ready?', 'Script is ready to automate Eclipse''s treeview') Local $hFirstItem = _GUICtrlTreeView_GetFirstItem($treeViewCtrl) $hItem = _GUICtrlTreeView_GetNext($treeViewCtrl, $hFirstItem) _GUICtrlTreeView_EnsureVisible($treeViewCtrl, $hItem) MsgBox(0, 'Info', 'First parent is expanded.') Local $firstChildCount = _GUICtrlTreeView_GetChildCount($treeViewCtrl, $hFirstItem) MsgBox(0, 'Info', 'There are: ' & $firstChildCount & ' first level child elements.') $hItem = _GUICtrlTreeView_GetNext($treeViewCtrl, $hItem) _GUICtrlTreeView_EnsureVisible($treeViewCtrl, $hItem) MsgBox(0, 'Info', 'First child is expanded.') EndFunc
  11. dragan's post in _IEAction was marked as the answer   
    Correct me if I'm wrong, but there's no waiting when you're going BACK, because the previous page is being loaded up from memory.
    Anyway, if you're going back to the point where previous page is no longer in your memory, you can use _IELoadWait again:
     
    #include <IE.au3> $oIE = _IECreate("http://www.yahoo.com/") MsgBox(0, 'message', 'Yahoo loaded!') _IENavigate($oIE, "http://www.google.com/") MsgBox(0, 'message', 'Google loaded!') _IEAction($oIE, "back") _IELoadWait($oIE) MsgBox(0, 'message', 'Loaded previous page.' & @CRLF & @CRLF & "Press OK to close script.") _IEQuit($oIE)
  12. dragan's post in how to change an object style in a web page? was marked as the answer   
    Well, this is a WILD guess, I've no idea if this will work on IE8, but it seems that style is ALSO an object, so you use "SetAttribute" function to "style":
    #include <IE.au3> $oIE = _IECreate() Local $sHTML = '<html><body><img src="http://aut1.autoit-cdn.com/site/wp-content/themes/TheCorporation/images/logo@2x.png" width="210"height="72" alt="AutoItScript" id="logo" /></body></html>' _IEBodyWriteHTML($oIE, $sHTML) Local $AllImages = _IETagNameGetCollection($oIE, 'img') For $OneImage in $AllImages If $OneImage.id = 'logo' Then MsgBox(0, '', 'about to change') $OneImage.style.setAttribute('border', '5px solid green') MsgBox(0, '', 'after changing') ExitLoop EndIf Next
  13. dragan's post in Select -> Option without form on javascript - fireEvent don`t work was marked as the answer   
    Well, I like calling java functions directly, not activating their "onchange" or "onclick" function, IF I CAN. And you can do that on your page:
    #include <IE.au3> $the_URL = 'http://catalog.1001z.ru/bmw/#c3Q9PTQwfHxzdHM9PXsiMTAiOiJcdTA0MWNcdTA0MzBcdTA0NDBcdTA0M2FcdTA0MzAiLCIyMCI6IkJNVyIsIjMwIjoiMSBFODIiLCI0MCI6Ilx1MDQzYVx1MDQ0M1x1MDQzZlx1MDQzNSAxMThkIn18fGJtdD09Qk1XfHxicD09UHx8ZnY9PVZUfHxiYj09RTgyfHxtb2RlbD09MTE4ZHx8c21vZGVsPT1Db3V8fGVtb2RlbD090LrRg9C%2F0LV8fGljbz09MTY1NzI3' $oIE = _IECreate($the_URL) Sleep(2000);time given for JAVA to load some page elements, otherwise, you will get NO "select" elements _ChangeSelect('01', 2);select 2nd element in 1st "select" control Sleep(1000);time given for java to react and execute the function _ChangeSelect('02', 1);select 1st element in 2nd "select" control Sleep(1000);time given for java to react and execute the function _ChangeSelect('03', 1);select 1st element in 3rd "select" control Sleep(1000);time given for java to react and execute the function _ChangeSelect('04', 3);select 3rd element in 4th "select" control Sleep(1000);time given for java to react and execute the function Func _ChangeSelect($SelName, $OptIndex) Local $oSelects = _IETagNameGetCollection($oIE, 'select') For $oSelect in $oSelects If $oSelect.name == $SelName Then Local $oOptions = $oSelect.options Local $Counter = -1 For $oOption in $oOptions $Counter += 1 If $Counter = $OptIndex Then $oIE.document.parentWindow.execScript('HM.set("' & $oOption.value & '");') Return EndIf Next Return EndIf Next EndFunc MsgBox(0, 'DONE!', 'Press OK to close the script') _IEQuit($oIE) Because JAVA is changing htmlsource of the $oIE, then you must call _IETagNameGetCollection($oIE, 'select') after each changed element, like it's shown in the script above.
  14. dragan's post in InetRead was marked as the answer   
    how about this:
     
    Local $webURL = 'http://www.autoitscript.com/site' Local $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("GET",$webURL) $oHTTP.Send() $oHTTP.WaitForResponse() Local $HTMLSource = $oHTTP.Responsetext ConsoleWrite($HTMLSource & @CRLF) $oHTTP = 0
  15. dragan's post in GuiCtrlSetPos problem was marked as the answer   
    How about this:
    -First you detect right keyboard button like you already did
    -Then you get current position of your $Icon1 control:
    Local $aPos = ControlGetPos($Form1, "", $Icon1) -Then (if no @errors), you will get array results to $aPos variable.
    -Then you set new position of the $Icon1 control using:
    GUICtrlSetPos($Icon1, $aPos[0]+5, $aPos[1]) ;will move 5 pixels to the right
  16. dragan's post in How to enable windows high contrast mode with autoit? was marked as the answer   
    How about this:
     
    #RequireAdmin Local $RunDLLexe = 'rundll32.exe' Local $Parameters = @WindowsDir & '\system32\shell32.dll,Control_RunDLL ' & _ @WindowsDir & '\system32\desk.cpl desk,@Themes /Action:OpenTheme /file:"' & _ @WindowsDir & '\Resources\Ease of Access Themes\hc1.theme"' ShellExecuteWait($RunDLLexe, $Parameters, @SystemDir) Local $winClass = "[CLASS:CabinetWClass]" WinWait($winClass, '', 5) If NOT @error then WinClose($winClass)
×
×
  • Create New...