Leaderboard
Popular Content
Showing content with the highest reputation on 05/20/2014 in all areas
-
Transparent checkbox
Cuongkoken reacted to funkey for a topic
Here is an example: #include <Constants.au3> #include <GUIConstantsEx.au3> #include <SendMessage.au3> #include <SliderConstants.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <StructureConstants.au3> Global Const $tagNMCUSTOMDRAW = 'hwnd hWndFrom;uint_ptr IDFrom;int Code;dword DrawStage;hwnd hDC;' & $tagRECT & ';dword_ptr ItemSpec;uint ItemState;lparam ItemlParam' Global Const $STM_GETIMAGE = 0x0173 Global $hGui = GUICreate("Test transparent checkbox replacement", 400, 200) GUICtrlCreatePic(StringReplace(@AutoItExe, "AutoIt3.exe", "") & "Examples\GUI\msoobe.jpg", 0, 0, 400, 200, 0) Global $hPic = GUICtrlGetHandle(-1) GUICtrlCreateCheckbox("Standard checkbox", 10, 10, 200, 20) GUICtrlCreateCheckbox("Standard checkbox transparent", 10, 50, 200, 20) GUICtrlSetBkColor(-1, -2) GUICtrlCreateCheckbox("Standard checkbox workaround", 10, 90, 13, 13) GUICtrlCreateLabel("Standard checkbox workaround", 26, 90, 200, 13) GUICtrlSetBkColor(-1, -2) Global $hCB1 = _GuiCtrlCreateTransparentCheckbox("TransparentCheckbox 1", 10, 130) Global $hCB2 = _GuiCtrlCreateTransparentCheckbox("TransparentCheckbox 2", 10, 170) GUIRegisterMsg(0x004E, '_WM_NOTIFY') GUISetState() Do Until GUIGetMsg() = -3 Func _GuiCtrlCreateTransparentCheckbox($text, $left, $top, $width = Default, $height = 13, $style = -1, $exStyle = 0) GUICtrlCreateCheckbox($text, $left, $top, $width, $height, $style, $exStyle) Return GUICtrlGetHandle(-1) EndFunc ;==>_GuiCtrlCreateTransparentCheckbox Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR Local $tNMCD = DllStructCreate($tagNMCUSTOMDRAW, $lParam) Local $hWndFrom = DllStructGetData($tNMCD, 'hWndFrom') Local $Code = DllStructGetData($tNMCD, 'Code') Local $DrawStage = DllStructGetData($tNMCD, 'DrawStage') Local $ItemSpec = DllStructGetData($tNMCD, 'ItemSpec') Local $hDC = DllStructGetData($tNMCD, 'hDC') Local $hMemDC, $hBitmap, $hPrev Local $aPos Switch $hWndFrom Case $hCB1, $hCB2 Switch $Code Case $NM_CUSTOMDRAW Switch $DrawStage Case $CDDS_PREPAINT, $CDDS_POSTPAINT $aPos = ControlGetPos($hWndFrom, '', '') Switch $DrawStage Case $CDDS_PREPAINT ;~ DllStructSetData($tNMCD, 'ItemState', BitXOR(DllStructGetData($tNMCD, 'ItemState'), $CDIS_FOCUS)) $hMemDC = _WinAPI_CreateCompatibleDC($hDC) $hBitmap = _SendMessage($hPic, $STM_GETIMAGE, $IMAGE_BITMAP, 0) $hPrev = _WinAPI_SelectObject($hMemDC, $hBitmap) _WinAPI_BitBlt($hDC, 13, 0, $aPos[2], $aPos[3], $hMemDC, $aPos[0] + 13, $aPos[1], $SRCCOPY) _WinAPI_SelectObject($hMemDC, $hPrev) _WinAPI_DeleteDC($hMemDC) Return BitOR($CDRF_NOTIFYITEMDRAW, $CDRF_NOTIFYPOSTPAINT) EndSwitch EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>_WM_NOTIFY1 point -
Context menu
UndefinedVar reacted to Mat for a topic
I did it for hotkeys here: '?do=embed' frameborder='0' data-embedContent>> Maybe you can get some ideas looking at the source code for that.1 point -
InetRead problem
coffeeturtle reacted to sahsanu for a topic
Change function _IEBodyReadHTML by _IEDocReadHTML and you should get the expected result: #include <String.au3> #include <IE.au3> Local $oIE = _IECreate("http://www.cesarsway.com/channel/dog-training", 0, 0) Local $HTMLCODE = _IEDocReadHTML($oIE) ClipPut($HTMLCODE) If Not @error Then $TITLE = _StringBetween($HTMLCODE, "<title>", "</title>") If IsArray($TITLE) Then $TITLE1 = $TITLE[0] Else $TITLE1 = "missing title" EndIf MsgBox(0, "", $TITLE1) EndIf1 point -
I use the open source program named Calibre to do these tasks. It has many command line tools to handle ebook tasks such as this and is good to use with AutoIt. For conversion tasks, you can have a look here that shows many parameters available to use. If interested. Calibre has plenty of features to discover if your into the ebook stuff. Your problem could be handled perhaps in just one line of code.1 point
-
Here is a websocket example (Win8 is required) : ;http://code.msdn.microsoft.com/windowsdesktop/WinHTTP-WebSocket-sample-50a140b5/sourcecode?fileId=51199&pathId=1032775223 #include "WinHttp.au3" #include <WinAPI.au3> ;_WinAPI_GetLastError Global Const $ERROR_NOT_ENOUGH_MEMORY = 8 Global Const $ERROR_INVALID_PARAMETER = 87 Global Const $WINHTTP_OPTION_UPGRADE_TO_WEB_SOCKET = 114 Global Const $WINHTTP_WEB_SOCKET_BINARY_MESSAGE_BUFFER_TYPE = 0 Global Const $WINHTTP_WEB_SOCKET_BINARY_FRAGMENT_BUFFER_TYPE = 1 Global Const $WINHTTP_WEB_SOCKET_SUCCESS_CLOSE_STATUS = 1000 Global $hOpen = 0, $hConnect = 0, $hRequest = 0, $hWebSocket = 0 Global $iError = 0 Example() Exit quit() Func Example() Local $sServerName = "echo.websocket.org" Local $sPath = "" Local $sMessage = "Hello world" ; Create session, connection and request handles. $hOpen = _WinHttpOpen("WebSocket sample", $WINHTTP_ACCESS_TYPE_DEFAULT_PROXY) If $hOpen = 0 Then $iError = _WinAPI_GetLastError() ConsoleWrite("Open error" & @CRLF) Return False EndIf $hConnect = _WinHttpConnect($hOpen, $sServerName, $INTERNET_DEFAULT_HTTP_PORT) If $hConnect = 0 Then $iError = _WinAPI_GetLastError() ConsoleWrite("Connect error" & @CRLF) Return False EndIf $hRequest = _WinHttpOpenRequest($hConnect, "GET", $sPath, "") If $hRequest = 0 Then $iError = _WinAPI_GetLastError() ConsoleWrite("OpenRequest error" & @CRLF) Return False EndIf ; Request protocol upgrade from http to websocket. Local $fStatus = _WinHttpSetOptionNoParams($hRequest, $WINHTTP_OPTION_UPGRADE_TO_WEB_SOCKET) If Not $fStatus Then $iError = _WinAPI_GetLastError() ConsoleWrite("SetOption error" & @CRLF) Return False EndIf ; Perform websocket handshake by sending a request and receiving server's response. ; Application may specify additional headers if needed. $fStatus = _WinHttpSendRequest($hRequest) If Not $fStatus Then $iError = _WinAPI_GetLastError() ConsoleWrite("SendRequest error" & @CRLF) Return False EndIf $fStatus = _WinHttpReceiveResponse($hRequest) If Not $fStatus Then $iError = _WinAPI_GetLastError() ConsoleWrite("SendRequest error" & @CRLF) Return False EndIf ; Application should check what is the HTTP status code returned by the server and behave accordingly. ; WinHttpWebSocketCompleteUpgrade will fail if the HTTP status code is different than 101. $hWebSocket = _WinHttpWebSocketCompleteUpgrade($hRequest, 0) If $hWebSocket = 0 Then $iError = _WinAPI_GetLastError() ConsoleWrite("WebSocketCompleteUpgrade error" & @CRLF) Return False EndIf _WinHttpCloseHandle($hRequest) $hRequestHandle = 0 ConsoleWrite("Succesfully upgraded to websocket protocol" & @CRLF) ; Send and receive data on the websocket protocol. $iError = _WinHttpWebSocketSend($hWebSocket, _ $WINHTTP_WEB_SOCKET_BINARY_MESSAGE_BUFFER_TYPE, _ $sMessage) If @error Or $iError <> 0 Then ConsoleWrite("WebSocketSend error" & @CRLF) Return False EndIf ConsoleWrite("Sent message to the server: " & $sMessage & @CRLF) Local $iBufferLen = 1024 Local $tBuffer = 0, $bRecv = Binary("") Local $iBytesRead = 0, $iBufferType = 0 Do If $iBufferLen = 0 Then $iError = $ERROR_NOT_ENOUGH_MEMORY Return False EndIf $tBuffer = DllStructCreate("byte[" & $iBufferLen & "]") $iError = _WinHttpWebSocketReceive($hWebSocket, _ $tBuffer, _ $iBytesRead, _ $iBufferType) If @error Or $iError <> 0 Then ConsoleWrite("WebSocketReceive error" & @CRLF) Return False EndIf ; If we receive just part of the message restart the receive operation. $bRecv &= BinaryMid(DllStructGetData($tBuffer, 1), 1, $iBytesRead) $tBuffer = 0 $iBufferLen -= $iBytesRead Until $iBufferType <> $WINHTTP_WEB_SOCKET_BINARY_FRAGMENT_BUFFER_TYPE ; We expected server just to echo single binary message. If $iBufferType <> $WINHTTP_WEB_SOCKET_BINARY_MESSAGE_BUFFER_TYPE Then ConsoleWrite("Unexpected buffer type" & @CRLF) $iError = $ERROR_INVALID_PARAMETER Return False EndIf ConsoleWrite("Received message from the server: '" & BinaryToString($bRecv) & "'" & @CRLF) ; Gracefully close the connection. $iError = _WinHttpWebSocketClose($hWebSocket, _ $WINHTTP_WEB_SOCKET_SUCCESS_CLOSE_STATUS) If @error Or $iError <> 0 Then ConsoleWrite("WebSocketClose error" & @CRLF) Return False EndIf ; Check close status returned by the server. Local $iStatus = 0, $iReasonLengthConsumed = 0 Local $tCloseReasonBuffer = DllStructCreate("byte[123]") $iError = _WinHttpWebSocketQueryCloseStatus($hWebSocket, _ $iStatus, _ $iReasonLengthConsumed, _ $tCloseReasonBuffer) If @error Or $iError <> 0 Then ConsoleWrite("QueryCloseStatus error" & @CRLF) Return False EndIf ConsoleWrite("The server closed the connection with status code: '" & $iStatus & "' and reason: '" & _ BinaryToString(BinaryMid(DllStructGetData($tCloseReasonBuffer, 1), 1, $iReasonLengthConsumed)) & "'" & @CRLF) EndFunc ;==>Example Func quit() If $hRequest <> 0 Then _WinHttpCloseHandle($hRequest) $hRequest = 0 EndIf If $hWebSocket <> 0 Then _WinHttpCloseHandle($hWebSocket) $hWebSocket = 0 EndIf If $hConnect <> 0 Then _WinHttpCloseHandle($hConnect) $hConnect = 0 EndIf If $iError <> 0 Then ConsoleWrite("Application failed with error: " & $iError & @CRLF) Return -1 EndIf Return 0 EndFunc Func _WinHttpSetOptionNoParams($hInternet, $iOption) Local $aCall = DllCall($hWINHTTPDLL__WINHTTP, "bool", "WinHttpSetOption", _ "handle", $hInternet, "dword", $iOption, "ptr", 0, "dword", 0) If @error Or Not $aCall[0] Then Return SetError(4, 0, 0) Return 1 EndFunc ;==>_WinHttpSetOptionNoParams Func _WinHttpWebSocketCompleteUpgrade($hRequest, $pContext = 0) Local $aCall = DllCall($hWINHTTPDLL__WINHTTP, "handle", "WinHttpWebSocketCompleteUpgrade", _ "handle", $hRequest, _ "DWORD_PTR", $pContext) If @error Then Return SetError(@error, @extended, -1) Return $aCall[0] EndFunc ;==>_WinHttpWebSocketCompleteUpgrade Func _WinHttpWebSocketSend($hWebSocket, $iBufferType, $vData) Local $tBuffer = 0, $iBufferLen = 0 If IsBinary($vData) = 0 Then $vData = StringToBinary($vData) $iBufferLen = BinaryLen($vData) If $iBufferLen > 0 Then $tBuffer = DllStructCreate("byte[" & $iBufferLen & "]") DllStructSetData($tBuffer, 1, $vData) EndIf Local $aCall = DllCall($hWINHTTPDLL__WINHTTP, "DWORD", "WinHttpWebSocketSend", _ "handle", $hWebSocket, _ "int", $iBufferType, _ "ptr", DllStructGetPtr($tBuffer), _ "DWORD", $iBufferLen) If @error Then Return SetError(@error, @extended, -1) Return $aCall[0] EndFunc ;==>_WinHttpWebSocketSend Func _WinHttpWebSocketReceive($hWebSocket, $tBuffer, ByRef $iBytesRead, ByRef $iBufferType) Local $aCall = DllCall($hWINHTTPDLL__WINHTTP, "handle", "WinHttpWebSocketReceive", _ "handle", $hWebSocket, _ "ptr", DllStructGetPtr($tBuffer), _ "DWORD", DllStructGetSize($tBuffer), _ "DWORD*", $iBytesRead, _ "int*", $iBufferType) If @error Then Return SetError(@error, @extended, -1) $iBytesRead = $aCall[4] $iBufferType = $aCall[5] Return $aCall[0] EndFunc ;==>_WinHttpWebSocketReceive Func _WinHttpWebSocketClose($hWebSocket, $iStatus, $tReason = 0) Local $aCall = DllCall($hWINHTTPDLL__WINHTTP, "handle", "WinHttpWebSocketClose", _ "handle", $hWebSocket, _ "USHORT", $iStatus, _ "ptr", DllStructGetPtr($tReason), _ "DWORD", DllStructGetSize($tReason)) If @error Then Return SetError(@error, @extended, -1) Return $aCall[0] EndFunc ;==>_WinHttpWebSocketClose Func _WinHttpWebSocketQueryCloseStatus($hWebSocket, ByRef $iStatus, ByRef $iReasonLengthConsumed, $tCloseReasonBuffer = 0) Local $aCall = DllCall($hWINHTTPDLL__WINHTTP, "handle", "WinHttpWebSocketQueryCloseStatus", _ "handle", $hWebSocket, _ "USHORT*", $iStatus, _ "ptr", DllStructGetPtr($tCloseReasonBuffer), _ "DWORD", DllStructGetSize($tCloseReasonBuffer), _ "DWORD*", $iReasonLengthConsumed) If @error Then Return SetError(@error, @extended, -1) $iStatus = $aCall[2] $iReasonLengthConsumed = $aCall[5] Return $aCall[0] EndFunc ;==>_WinHttpWebSocketQueryCloseStatus1 point
-
downloading a part of a file ?
Alexxander reacted to JohnOne for a topic
InetGet() InetGetInfo() InetClose()1 point -
New SciTE4AutoIt3 available with SciTE v3.4.1
jaberwacky reacted to Jos for a topic
Fixed in current Beta Tidy v 2.4.1.2. It is added to the example Tidy.ini for the next release. Jos1 point -
Can I Do this? (project layout)
seanbrockest reacted to somdcomputerguy for a topic
I believe this can be done. Here is a list of AutoIt functions that I think you would need.. Run or ShellExecute _Ispressed MouseGetPos PixelGetColor Sleep Along with loops of course, While..WEnd, For..Next, If..EndIf. There is example code for each of these functions in the Help file. Good Luck with your project!1 point -
Use both messages: $LVN_ITEMCHANGING and $LVN_ITEMCHANGED. #Include <GUIConstantsEx.au3> #Include <GUIListView.au3> #Include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Global $State, $Button, $ListView, $hListView GUICreate('MyGUI', 280, 391) $ListView = GUICtrlCreateListView('', 10, 10, 260, 344, BitOR($LVS_DEFAULT, $LVS_NOCOLUMNHEADER), $WS_EX_CLIENTEDGE) $hListView = GUICtrlGetHandle(-1) _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_CHECKBOXES, $LVS_EX_DOUBLEBUFFER, $LVS_EX_INFOTIP)) _GUICtrlListView_InsertColumn($hListView, 0, '', 234) $Button = GUICtrlCreateButton('OK', 105, 361, 70, 23) For $i = 1 To 5 _GUICtrlListView_AddItem($hListView, 'Item' & $i) Next _GUICtrlListView_SetItemChecked($hListView, 1, 1) _GUICtrlListView_SetItemChecked($hListView, 2, 1) _GUICtrlListView_SetItemChecked($hListView, 4, 1) GUIRegisterMsg($WM_NOTIFY, 'WM_NOTIFY') GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) Local $tNMITEMACTIVATE = DllStructCreate($tagNMITEMACTIVATE, $lParam) Local $hWndFrom = DllStructGetData($tNMITEMACTIVATE, 'hWndFrom') Local $Index = DllStructGetData($tNMITEMACTIVATE, 'Index') Local $Code = DllStructGetData($tNMITEMACTIVATE, 'Code') Switch $hWndFrom Case $hListView Switch $Code Case $LVN_ITEMCHANGING $State = _GUICtrlListView_GetItemChecked($hListView, $Index) Case $LVN_ITEMCHANGED If $State <> _GUICtrlListView_GetItemChecked($hListView, $Index) Then ConsoleWrite('Item' & ($Index + 1) & ' - ' & (Not $State) & @CR) EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY1 point