-
Posts
47 -
Joined
-
Last visited
CodeTinkerer's Achievements

Seeker (1/7)
0
Reputation
-
Hello, Before I begin, let me mention I have indeed looked through various posts and examples of anything pertaining to WebSocket. One thread Thread had some motivation long ago but never took off. Another Thread ended in hits and lack of support. Any insight would be welcomed and appreciated In my current progress, I end up with a 400 bad request response, which is indicative that my message is not understood. #include "WinHttp.au3" #include <WinAPI.au3>;_WinAPI_GetLastError #include "JSON.au3" #include "JSON_Translate.au3" 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 Func Example() Local $sServerName = "104.16.107.31" 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, "104.16.107.31", $INTERNET_DEFAULT_HTTP_PORT) If $hConnect = 0 Then $iError = _WinAPI_GetLastError() ConsoleWrite("Connect error" & @CRLF) Return False EndIf $hRequest = _WinHttpOpenRequest($hConnect, "POST", $sPath, "") If $hRequest = 0 Then $iError = _WinAPI_GetLastError() ConsoleWrite("OpenRequest error" & @CRLF) Return False EndIf ; Add header fields to the request _WinHttpAddRequestHeaders($hRequest, "Connection: Upgrade") _WinHttpAddRequestHeaders($hRequest, "Upgrade: websocket") ; 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 ConsoleWrite("HTTPResp: " & $fStatus & @CRLF) TCPStartup() Local $iSocket = TCPConnect($sServerName, 80) If @error Then ConsoleWrite("Error in TCP Connection" & @CRLF) Else ConsoleWrite("Connected to Socket: " & $iSocket & @CRLF) EndIf Local $s = '{' _ & '"type": "subscribe", ' _ & '"channels": [{"name": "ticker", ' _ & '"product_ids": ["ETH-EUR"]}]' _ & '}' $s = String($s) Local $t = _JSONEncode(_JSONDecode($s)) ConsoleWrite("RawJson: " & $s & @CRLF) ConsoleWrite("Encoded: " & $t & @CRLF) ;_CWrite("_JSONEncode:" & $s) TCPSend($iSocket, $t) If @error Then ConsoleWrite("Error in TCP Send " & @error & @CRLF) EndIf Local $irecv = TCPRecv($iSocket, 2048) If @error Then ConsoleWrite("Error in TCP Recv " & @error & @CRLF) Else ConsoleWrite("$irecv: >>> " & @CRLF & $irecv & @CRLF) Local $iListen = TCPListen($sServerName, 80) If @error Then ConsoleWrite("Error in TCP Listen " & @error & @CRLF) Else Do $iSocket = TCPAccept($iSocket) If @error Then ConsoleWrite("Error in TCP Accept" & @CRLF) ExitLoop Else ConsoleWrite("Recv: " & $iSocket & @CRLF) EndIf Until $iSocket < 0 EndIf EndIf EndFunc ;==>Example
-
Resizable Frame-less/Border-less GUI
CodeTinkerer replied to CodeTinkerer's topic in AutoIt GUI Help and Support
Still attempting a solution for getting rid of this flicker issue. Would anyone know of an efficient way to have the window Re sized AFTER the drag operation on the window edges? -
CodeTinkerer reacted to a post in a topic: Resizable Frame-less/Border-less GUI
-
Resizable Frame-less/Border-less GUI
CodeTinkerer replied to CodeTinkerer's topic in AutoIt GUI Help and Support
I have attached the progress. to achieve full expand ability of the window I have altered the XSkin.au3 to my requirements such that vertical images are of a height at 1080px and horizontal images are a width of 1920px. the window also includes a listview with a background image of 1920x1080. Looks great! Functions well! But, there is a slight flickering problem when resizing the window and its much worse in an MDI environment with a background image on the parent window. This causes bright white flashes at a frequent interval when resizing the image. I am afraid that one of my users of the application I am working on might have epilepsy and I dont want to trigger that. Is there no way to rezise the window AFTER the drag is complete? sort of like Linux style window resizing? or even windows does it at some points but I could not re-create. skinnedWindow.zip -
Resizable Frame-less/Border-less GUI
CodeTinkerer replied to CodeTinkerer's topic in AutoIt GUI Help and Support
Yes, I was just showing you what I was coming up with while I waited for a response. I did in fact take your example and assimilate it into my script. after close study and documentation of corse! I really appreciate it ! I plan to post the final result with resources once all the fine tuning is finished -
Resizable Frame-less/Border-less GUI
CodeTinkerer replied to CodeTinkerer's topic in AutoIt GUI Help and Support
Melba, Thanks for your assistance and pointing me in the right direction. I was lost. I did however attempt to do as you said and identify which window was under the cursor and modify accordingly but alas my result was sloppy dysfunctional code lol. Here is what I tried: #include <GuiConstantsEx.au3> #include <Windowsconstants.au3> #include <SendMessage.au3> #include <WinAPI.au3> #include <WinAPIsys.au3> #include <Misc.au3> Local $stPoint = DllStructCreate($tagPOINT), $aPos, $hControl, $hWin, $aLastPos[2] = [-1, -1], $sLastStr = '', $sStr HotKeySet("{ESC}", "On_Exit") ; Set distance from edge of window where resizing is possible Global Const $iMargin = 4 ; Set max and min GUI sizes Global Const $iGUIMinX = 50, $iGUIMinY = 50, $iGUIMaxX = 300, $iGUIMaxY = 300 ; Create GUI Global $hGUI = GUICreate("Y", 100, 100, -1, -1, $WS_POPUP) GUISetBkColor(0x00FFF0) GUISetState() Local $wPos = WinGetPos($hGUI) ; Create GUI Global $hGUI2 = GUICreate("Z", 100, 100, $wPos[0] + 101, -1, $WS_POPUP) GUISetBkColor(0x00FF00) GUISetState() ; Register message handlers GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN") ; For resize/drag GUIRegisterMsg($WM_MOUSEMOVE, "_SetCursor") ; For cursor type change ;GUIRegisterMsg($WM_GETMINMAXINFO, "_WM_GETMINMAXINFO") ; For GUI size limits $hCurr_HhWnd = 0 While 1 Sleep(10) WEnd ; Set cursor to correct resizing form if mouse is over a border Func _SetCursor() Local $iCursorID Local $iCursorID2 If _GethWndhWnd() = WinGetTitle($hGUI) Then Switch _GetBorder($hGUI) Case 0 $iCursorID = 2 Case 1, 2 $iCursorID = 13 Case 3, 6 $iCursorID = 11 Case 5, 7 $iCursorID = 10 Case 4, 8 $iCursorID = 12 EndSwitch GUISetCursor($iCursorID, 1) ElseIf _GethWndhWnd() = WinGetTitle($hGUI2) Then Switch _GetBorderOther($hGUI2) Case 0 $iCursorID2 = 2 Case 1, 2 $iCursorID2 = 13 Case 3, 6 $iCursorID2 = 11 Case 5, 7 $iCursorID2 = 10 Case 4, 8 $iCursorID2 = 12 EndSwitch GUISetCursor($iCursorID2, 1) EndIf EndFunc ;==>_SetCursor ; Check cursor type and resize/drag window as required Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam) Switch WinGetTitle($hWnd) Case WinGetTitle($hGUI) DragResize($hGUI) Case WinGetTitle($hGUI2) DragResize($hGUI2) EndSwitch EndFunc ;==>_WM_LBUTTONDOWN Func DragResize($hWndSample) Local $iResizeType = "" Switch WinGetTitle($hWndSample) Case WinGetTitle($hGUI) Local $iCursorType = _GetBorder($hGUI) If $iCursorType > 0 Then ; Cursor is set to resizing style $iResizeType = 0xF000 + $iCursorType _SendMessage($hGUI, $WM_SYSCOMMAND, $iResizeType, 0) Else Local $aCurInfo = GUIGetCursorInfo($hGUI) If $aCurInfo[4] = 0 Then ; Mouse not over a control DllCall("user32.dll", "int", "ReleaseCapture") _SendMessage($hGUI, $WM_NCLBUTTONDOWN, $HTCAPTION, 0) EndIf EndIf Case WinGetTitle($hGUI2) Local $iCursorType = _GetBorderOther($hGUI2) If $iCursorType > 0 Then ; Cursor is set to resizing style $iResizeType = 0xF000 + $iCursorType _SendMessage($hGUI2, $WM_SYSCOMMAND, $iResizeType, 0) Else Local $aCurInfo = GUIGetCursorInfo($hGUI2) If $aCurInfo[4] = 0 Then ; Mouse not over a control DllCall("user32.dll", "int", "ReleaseCapture") _SendMessage($hGUI2, $WM_NCLBUTTONDOWN, $HTCAPTION, 0) EndIf EndIf EndSwitch EndFunc ;==>DragResize Func _GethWndhWnd() $aPos = MouseGetPos() If $aPos[0] <> $aLastPos[0] Or $aPos[1] <> $aLastPos[1] Then DllStructSetData($stPoint, 1, $aPos[0]) DllStructSetData($stPoint, 2, $aPos[1]) $hControl = _WinAPI_WindowFromPoint($stPoint) $hWin = _WinAPI_GetAncestor($hControl, 2) $sStr = WinGetTitle($hWin) If $sLastStr <> $sStr Then ;ToolTip($sStr) ;ConsoleWrite($sStr) Return $sStr $sLastStr = $sStr EndIf $aLastPos = $aPos EndIf Sleep(15) EndFunc ;==>_GethWndhWnd ; Determines if mouse cursor over a border Func _GetBorder($blank) Local $aCurInfo = GUIGetCursorInfo() If @error Then Return -1 Local $aWinPos = WinGetPos($hGUI) Local $iSide = 0 Local $iTopBot = 0 ;x Coords If $aCurInfo[0] < $iMargin Then $iSide = 1 If $aCurInfo[0] > $aWinPos[2] - $iMargin Then $iSide = 2 ;y Coords If $aCurInfo[1] < $iMargin Then $iTopBot = 3 If $aCurInfo[1] > $aWinPos[3] - $iMargin Then $iTopBot = 6 If $iSide + $iTopBot > 0 Then ConsoleWrite("Side " & $iSide & " + TopBot " & $iTopBot & @CRLF) Return $iSide + $iTopBot EndFunc ;==>_GetBorder ; Determines if mouse cursor over a border Func _GetBorderOther($blank) Local $aCurInfo = GUIGetCursorInfo() If @error Then Return -1 Local $aWinPos = WinGetPos($hGUI2) Local $iSide = 0 Local $iTopBot = 0 ;x Coords If $aCurInfo[0] < $iMargin Then $iSide = 1 If $aCurInfo[0] > $aWinPos[2] - $iMargin Then $iSide = 2 ;y Coords If $aCurInfo[1] < $iMargin Then $iTopBot = 3 If $aCurInfo[1] > $aWinPos[3] - $iMargin Then $iTopBot = 6 If $iSide + $iTopBot > 0 Then ConsoleWrite("b - " & $iSide & " + " & $iTopBot & @CRLF) Return $iSide + $iTopBot EndFunc ;==>_GetBorderOther ; Set min and max GUI sizes Func _WM_GETMINMAXINFO($hWnd, $iMsg, $wParam, $lParam) $tMinMaxInfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam) DllStructSetData($tMinMaxInfo, 7, $iGUIMinX) DllStructSetData($tMinMaxInfo, 8, $iGUIMinY) DllStructSetData($tMinMaxInfo, 9, $iGUIMaxX) DllStructSetData($tMinMaxInfo, 10, $iGUIMaxY) Return 0 EndFunc ;==>_WM_GETMINMAXINFO Func On_Exit() Exit EndFunc ;==>On_Exit -
Resizable Frame-less/Border-less GUI
CodeTinkerer replied to CodeTinkerer's topic in AutoIt GUI Help and Support
So in an amature fashion I have been trying to understand the functionality Currently I am using this script to try to get the results I want. Looks like segregation between the two windows is not going to work, leaning towards the DLL calls to be the main pivotal point in the issue. probably not utilizing it right. Thoughts? #include <GuiConstants.au3> #include <windowsconstants.au3> ;Global Const $WM_LBUTTONDOWN = 0x0201 Global Const $margin = 12; distance from edge of window where dragging is possible Global $gui1, $gui2 Global $Gui = GUICreate("Win1", 420, 200, -1, -1, $WS_POPUP) GUISetBkColor(0xf1f100) Global $chk1 = GUICtrlCreateCheckbox("allow resizing and dragging", 140, 40) GUICtrlSetResizing(-1, $GUI_DOCKWIDTH) Global $Button = GUICtrlCreateButton("Exit", 140, 90, 150, 30) GUISetState(@SW_SHOW, $Gui) Local $MainWinPos = WinGetPos($gui1) Local $locFix = $MainWinPos[0] + $MainWinPos[2] Global $gui2 = GUICreate("Win2", 420, 200, $locFix, -1, $WS_POPUP) Global $chk2 = GUICtrlCreateCheckbox("allow resizing and dragging", 140, 40) GUICtrlSetResizing(-1, $GUI_DOCKWIDTH) Global $Button2 = GUICtrlCreateButton("Exit", 140, 90, 150, 30) GUISetState(@SW_SHOW, $gui2) GUIRegisterMsg($WM_LBUTTONDOWN, "WM_LBUTTONDOWN") GUIRegisterMsg($WM_MOUSEMOVE, "SetCursor") While 1 $msg = GUIGetMsg() Select Case $msg = $Button Exit Case $msg = $Button2 Exit EndSelect WEnd ;GetMousePosType returns a code depending on the border the mouse cursor is near Func GetMousePosType() Local $cp = GUIGetCursorInfo() Local $wp1 = WinGetPos($gui1) Local $wp2 = WinGetPos($gui2) Local $sidea = 0 Local $TopBota = 0 Local $sideb = 0 Local $TopBotb = 0 If $cp Then If WinActive($gui1) Then If $cp[0] < $margin Then $sidea = 1 If $cp[0] > $wp1[2] - $margin Then $sidea = 2 If $cp[1] < $margin Then $TopBota = 3 If $cp[1] > $wp1[3] - $margin Then $TopBota = 6 Return $sidea + $TopBota ElseIf WinActive($gui2) Then If $cp[0] < $margin Then $sideb = 1 If $cp[0] > $wp2[2] - $margin Then $sideb = 2 If $cp[1] < $margin Then $TopBotb = 3 If $cp[1] > $wp2[3] - $margin Then $TopBotb = 6 Return $sideb + $TopBotb EndIf EndIf EndFunc ;==>GetMousePosType Func SetCursor() Local $curs Local $curs2 If WinActive($gui1) Then If GUICtrlRead($chk1) <> $GUI_CHECKED Then Return Switch GetMousePosType() Case 0 $curs = 2 Case 1, 2 $curs = 13 Case 3, 6 $curs = 11 Case 5, 7 $curs = 10 Case 4, 8 $curs = 12 EndSwitch GUISetCursor($curs, 1) ElseIf WinActive($gui2) Then If GUICtrlRead($chk2) <> $GUI_CHECKED Then Return Switch GetMousePosType() Case 0 $curs2 = 2 Case 1, 2 $curs2 = 13 Case 3, 6 $curs2 = 11 Case 5, 7 $curs2 = 10 Case 4, 8 $curs2 = 12 EndSwitch GUISetCursor($curs2, 1) EndIf EndFunc ;==>SetCursor Func WM_LBUTTONDOWN($hWnd, $iMsg, $StartWIndowPosaram, $lParam) Local $w1 = WinGetHandle($gui1) Local $w2 = WinGetHandle($gui2) If WinActive($gui1) Then If GUICtrlRead($chk1) <> $GUI_CHECKED Then Return $GUI_RUNDEFMSG Local $drag = GetMousePosType() If $drag > 0 Then DllCall("user32.dll", "long", "SendMessage", "hwnd", $w1, "int", $WM_SYSCOMMAND, "int", 0xF000 + $drag, "int", 0) Else DllCall("user32.dll", "long", "SendMessage", "hwnd", $w1, "int", $WM_SYSCOMMAND, "int", 0xF012, "int", 0) EndIf ElseIf WinActive($gui2) Then If GUICtrlRead($chk2) <> $GUI_CHECKED Then Return $GUI_RUNDEFMSG Local $drag = GetMousePosType() If $drag > 0 Then DllCall("user32.dll", "long", "SendMessage", "hwnd", $w2, "int", $WM_SYSCOMMAND, "int", 0xF000 + $drag, "int", 0) Else DllCall("user32.dll", "long", "SendMessage", "hwnd", $w2, "int", $WM_SYSCOMMAND, "int", 0xF012, "int", 0) EndIf Else Return $GUI_RUNDEFMSG EndIf ;F001 = LHS, F002 = RHS, F003 = top, F004 = TopLeft, F005 = TopRight, F006 = Bottom, F007 = BL, F008 = BR ;F009 = move gui, same as F011 F012 to F01F ;F010, moves cursor to centre top of gui - no idea what that is useful for. ;F020 minimizes ;F030 maximizes EndFunc ;==>WM_LBUTTONDOWN -
Hello again! Im looking for a way to create a Resizable Frame-less/Border-less GUI window. Using the methods found here: https://www.autoitscript.com/wiki/Moving_and_Resizing_PopUp_GUIs I can get the desired outcome I want but only for a single window. My application will be using Multiple windows I would like to have this same resizable functionality. Also when using the above linked methods when the GUI loses focus, it sometime causes a crash. Is there fast-track way to simplify getting my desired outcome? Currently I have also experimented with Bitor($WS_POPUP, $WS_SIZEBOX) Which gets me the closest without using listeners/registers but still leaves me with a nasty skinny frame. i'll be using this with XSkin if that helps any also, I have re-calibrated XSkin to get the proper image formating on the GUI and now i need the window to be resizable without a Frame/Border. Perhaps there is a way to hook the resize to the Images..... lots more thinking to do, I appreciate any assistance you would have to offer. Thanks!
-
GUICtrlCreateListView and Background Image
CodeTinkerer replied to CodeTinkerer's topic in AutoIt GUI Help and Support
It seems the image I was trying to use was corrupted in some form as I used a different image and it works with both methods. Thank you both! -
GUICtrlCreateListView and Background Image
CodeTinkerer replied to CodeTinkerer's topic in AutoIt GUI Help and Support
Thanks for your suggestion, but it did not bring me much closer a solution -
So I have a massive script going. one particular part invoving an MDI Child window I want to have an image in the ListView Background. using the GUICtrlCreateListView Method I am not able to Utilize the _GUICtrlListView_SetBkImage() to set the Background image. Although if I use the _GUICtrlListView_Create() Method the image sets fine. But they way my script is set up currently would take hours to adjust the script to work properly through _GUICtrlListView_Create(). Any thoughts on how I can achieve setting the BG of the ListView Without having to change my ListView Creation Method? Here is an Example Script of what I am trying to achieve. #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> Local $Winx = 10 Local $Winy = 100 Local $WinW = 405 Local $WinH = 210 $hNew_ChildTech = GUICreate("UNPRODUCTIVE TECHNICIANS", $WinW, $WinH, $Winx, $Winy, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_TABSTOP)) $TechStatusFeed = GUICtrlCreateListView("TECH #|STATUS|First Name|Last Name ", 5, 5, $WinW - 12, $WinH - 10, -1) _GUICtrlListView_SetColumnWidth($TechStatusFeed, 0, 55) _GUICtrlListView_SetColumnWidth($TechStatusFeed, 1, 117) _GUICtrlListView_SetColumnWidth($TechStatusFeed, 2, 100) _GUICtrlListView_SetColumnWidth($TechStatusFeed, 3, 150) _GUICtrlListView_SetBkImage($TechStatusFeed, @ScriptDir & "\img\img.jpg") GUISetState() While 1 Sleep(100) WEnd
-
MDI Child of Child Window
CodeTinkerer replied to CodeTinkerer's topic in AutoIt GUI Help and Support
amazing this is just the way I was hoping it would work!! Thank you! -
Hello, I have been working on an application for quite some time now that involves an MDI style setup. I am running into an Issue with custom graphics as a background with static positions for custom buttons as a "tool bar". When a child window is maximized it will maximize the entire inside region of the parent window as it should. I would like to set a custom region which a child window will maximize to so that it does not cover up my toolbar. My first thought on the approach was to create another GUI as a container for all the child windows. which would also mean it would too be a child of the parent window. is this achievable? Does anyone have any examples of what I am trying to achieve?
-
Amazing, got my desired outcome with: Func _GuiRoundCorners($h_win, $i_x1, $i_y1, $i_x2, $i_y2, $i_x3, $i_y3) Local $XS_pos, $XS_reta, $XS_retb, $XS_ret2 $XS_pos = WinGetPos($h_win) $XS_reta = _WinAPI_CreateRoundRectRgn ( 0, 0, $XS_pos[2], $XS_pos[3]-30, $i_x3, $i_y3 ) $XS_retb = _WinAPI_CreateRectRgn (0, $XS_pos[2]-$XS_pos[1]/2, $XS_pos[2], $XS_pos[3] ) $XS_retc = _WinAPI_CombineRgn ( $XS_reta, $XS_reta, $XS_retb, $RGN_OR ) _WinAPI_DeleteObject($XS_retb) _WinAPI_SetWindowRgn($h_win, $XS_reta) EndFunc ;==>_GuiRoundCorners Thank you for your assistance!
-
Yes, I understand _WinAPI_CreateRoundRectRgn() does the same thing as : DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $i_x1, "long", $i_y1, "long", $pos[2], "long", $pos[3], "long", $i_x3, "long", $i_y3)But that doesnt answer my question, it adjusts the region as a rectangle meaning it will always adjust for 4 corners. Is there a system used for point to point corners or single corners?
-
I am developing an application with some custom graphics. I found this function here. it works perfectly but I was wondering; is there a way to round only the top or bottom two corners?