Jump to content

MachinistProgrammer

Active Members
  • Posts

    108
  • Joined

  • Last visited

Reputation Activity

  1. Like
    MachinistProgrammer got a reaction from timmy2 in How can I close this script from another script?   
    this is exactly what you are >looking for
  2. Like
    MachinistProgrammer got a reaction from mmfalcao in STDOUT ?   
    I forgot the run param to let the script inherret the stdout and stderr stream and i used your data loop
    #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Version=Beta #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_Change2CUI=y #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #AutoIt3Wrapper_Run_AU3Check=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;#Netux_scriptable_webserver.au3#================================== ;File Name.......:Netux_scriptable_webserver.au3 ;Creator.........:sean.campbell7 ;Created with....:Created with ISN AutoIt Studio ;Version.........:0.91 BETA ;============================================= #include <Misc.au3> ; Only used for _Iif #include <file.au3> #include <Array.au3> Local $Dlog = @ScriptDir & "\Logs\NetuX_log_" & @MDAY & "_" & @MON & "_" & @YEAR & ".log" Local $autoit = @AutoItExe OnAutoItExitRegister("_exit") ; // OPTIONS HERE // Local $intcfg = @ScriptDir & "\CFG\init.ini" Local $sRootDir = @ScriptDir & "\" & IniRead($intcfg, "Main", "MD", "Webroot") Local $sIP = @IPAddress1 if IniRead($intcfg, "Main", "Uselocal", "false") = "true" Then     $sIP = "127.0.0.1" EndIf Local $iPort = 80 ; the listening port Local $sServerAddress = "https://" & $sIP & "/" Local $sServerName = "NetuX/1.3 (" & @OSVersion & ") AutoIt " & @AutoItVersion ; // END OF OPTIONS // Local $aSocket[1] ; Creates an array to store all the possible users Local $sBuffer[1] ; All these users have buffers when sending/receiving, so we need a place to store those TCPStartup() ; AutoIt needs to initialize the TCP functions $iMainSocket = TCPListen($sIP, $iPort) ;create main listening socket If @error Then ; if you fail creating a socket, exit the application     MsgBox(266256, "NetuX 1.3", "Error : NetuX cannot establish a listening port check to see of any other" & @CRLF & "server software is running", 0)     _log("Error : Unknown Host Exeption, Exiting")     Exit ; if your server is part of a GUI that has nothing to do with the server, you'll need to remove the Exit keyword and notify the user that the HTTP server will not work. EndIf ConsoleWrite("Server established on : " & $sServerAddress & @CRLF) ; If you're in SciTE, _log("established server : " & $sServerAddress) While 1     $iNewSocket = TCPAccept($iMainSocket) ; Tries to accept incoming connections          If $iNewSocket >= 0 Then ; Verifies that there actually is an incoming connection         Local $user = UBound($aSocket) ; some code to allow infinate users         ReDim $aSocket[$user + 1]         ReDim $sBuffer[$user + 1]         $aSocket[$user] = $iNewSocket         ConsoleWrite("New Client : " & TCPSocketToIP($iNewSocket) & @CRLF)         _log("Client connected on : " & TCPSocketToIP($iNewSocket))     EndIf     For $x = 0 to UBound($aSocket) - 1 ; A big loop to receive data from everyone connected         $sNewData = TCPRecv($aSocket[$x], 1024) ; Receives a whole lot of data if possible         If $sNewData Then ; data received             $sBuffer[$x] &= $sNewData ;store it in the buffer             If StringInStr(StringStripCR($sBuffer[$x]), @LF & @LF) Then ; if the request has ended ..                 $sFirstLine = StringLeft($sBuffer[$x], StringInStr($sBuffer[$x], @LF)) ; helps to get the type of the request                 $sRequestType = StringLeft($sFirstLine, StringInStr($sFirstLine, " ") - 1) ; gets the type of the request                 If $sRequestType = "GET" Then ; user wants to download a file or whatever ..                     $sRequest = StringTrimRight(StringTrimLeft($sFirstLine, 4), 11) ; let's see what file he actually wants                     If StringInStr(StringReplace($sRequest, "\", "/"), "/.") Then ; Disallow any attempts to go back a folder                         _HTTP_Send400($aSocket[$x]) ; sends back an error                         ConsoleWrite("Client requested bad address" & @CRLF)                         _log("Error : code 400 requested bad address")                     Else                         If $sRequest = "/" Then ; user has requested the root                             if FileExists($sRootDir & "\index.htm") Then                                 $sRequest = "/index.htm"                             ElseIf FileExists($sRootDir & "\index.htm") Then                                 $sRequest = "/index.html"                             ElseIf FileExists($sRootDir & "\index.au3") Then                                 $sRequest = "/index.au3"                             EndIf                         EndIf                                                  $sRequest = StringReplace($sRequest, "/", "\") ; convert HTTP slashes to windows slashes, not really required because windows accepts both                         If FileExists($sRootDir & "\" & $sRequest) Then ; makes sure the file that the user wants exists                             $sFileType = StringRight($sRequest, 4) ; determines the file type, so that we may choose what mine type to use                             Switch $sFileType                                 Case "html", ".htm" ; in case of normal HTML files                                     _HTTP_SendFile($aSocket[$x], $sRootDir & $sRequest, "text/html")                                 Case ".css" ; in case of style sheets                                     _HTTP_SendFile($aSocket[$x], $sRootDir & $sRequest, "text/css")                                 Case ".jpg", "jpeg" ; for common images                                     _HTTP_SendFile($aSocket[$x], $sRootDir & $sRequest, "image/jpeg")                                 Case ".png" ; another common image format                                     _HTTP_SendFile($aSocket[$x], $sRootDir & $sRequest, "image/png")                                 Case ".au3"                                     _autodetectscript($sRequest, $aSocket[$x])                                 Case Else ; this is for .exe, .zip, or anything else that is not supported is downloaded to the client using a application/octet-stream                                     _HTTP_SendFile($aSocket[$x], $sRootDir & $sRequest, "application/octet-stream")                             EndSwitch                         Else                             _autodetectscript($sRequest, $aSocket[$x])                         EndIf                     EndIf                 ElseIf $sRequestType = "POST" Then ; user has come to us with data, we need to parse that data and based on that do something special                                          $aPOST = _HTTP_GetPost($sBuffer[$x]) ; parses the post data                                          $sComment = _HTTP_POST("wintext", $aPOST) ; Like PHPs _POST, but it requires the second parameter to be the return value from _Get_Post                                          _HTTP_ConvertString($sComment) ; Needs to convert the POST HTTP string into a normal string                                          ConsoleWrite($sComment)                                          $data = FileRead($sRootDir & "\template.html")                     $data = StringReplace($data, "<?au3 Replace me ?>", $sComment)                                          $h = FileOpen($sRootDir & "\index.html", 2)                     FileWrite($h, $data)                     FileClose($h)                                          $h = FileOpen($sRootDir & "\clean.html", 2)                     FileWrite($h, $sComment)                     FileClose($h)                                          _HTTP_SendFile($aSocket[$x], $sRootDir & "\index.html", "text/html") ; Sends back the new file we just created                 EndIf                                  $sBuffer[$x] = "" ; clears the buffer because we just used to buffer and did some actions based on them                 $aSocket[$x] = -1 ; the socket is automatically closed so we reset the socket so that we may accept new clients                              EndIf         EndIf     Next          Sleep(10) WEnd Func _HTTP_ConvertString(ByRef $sInput) ; converts any characters like %20 into space 8)     $sInput = StringReplace($sInput, '+', ' ')     StringReplace($sInput, '%', '')     For $t = 0 To @extended         $Find_Char = StringLeft(StringTrimLeft($sInput, StringInStr($sInput, '%')), 2)         $sInput = StringReplace($sInput, '%' & $Find_Char, Chr(Dec($Find_Char)))     Next EndFunc Func _HTTP_SendHTML($hSocket, $sHTML, $sReply = "200 OK") ; sends HTML data on X socket     _HTTP_SendData($hSocket, Binary($sHTML), "text/html", $sReply) EndFunc Func _HTTP_SendFile($hSocket, $sFileLoc, $sMimeType, $sReply = "200 OK") ; Sends a file back to the client on X socket, with X mime-type     Local $hFile, $sImgBuffer, $sPacket, $a          ConsoleWrite("Sending " & $sFileLoc & @CRLF)          $hFile = FileOpen($sFileLoc, 16)     $bFileData = FileRead($hFile)     FileClose($hFile)          _HTTP_SendData($hSocket, $bFileData, $sMimeType, $sReply) EndFunc Func _HTTP_SendData($hSocket, $bData, $sMimeType, $sReply = "200 OK")     $sPacket = Binary("HTTP/1.1 " & $sReply & @CRLF & _             "Server: " & $sServerName & @CRLF & _             "Connection: close" & @CRLF & _             "Content-Lenght: " & BinaryLen($bData) & @CRLF & _             "Content-Type: " & $sMimeType & @CRLF & _             @CRLF)     TCPSend($hSocket, $sPacket) ; Send start of packet          While BinaryLen($bData) ; Send data in chunks (most code by Larry)         $a = TCPSend($hSocket, $bData) ; TCPSend returns the number of bytes sent         $bData = BinaryMid($bData, $a + 1, BinaryLen($bData) - $a)     WEnd          $sPacket = Binary(@CRLF & @CRLF) ; Finish the packet     TCPSend($hSocket, $sPacket)          TCPCloseSocket($hSocket) EndFunc Func _HTTP_Send404($hSocket) ; Sends back a basic 404 error     Local $s404Loc = $sRootDir & "\404.html"     If FileExists($s404Loc) Then         _HTTP_SendFile($hSocket, $s404Loc, "text/html")     Else         _HTTP_SendHTML($hSocket, "<h1>404 Error:</h1><br/>The file you requested could not be found.<br/><br/><i>Netux SND HTTP Server version 1.3</i>", "404 not found")     EndIf EndFunc Func _HTTP_Send400($hSocket) ; Sends back a basic 400 error     Local $s400Loc = $sRootDir & "\400.html"     If FileExists($s400Loc) Then         _HTTP_SendFile($hSocket, $s400Loc, "text/html")     Else         _HTTP_SendHTML($hSocket, "<h1>400 Error:</h1><br/>bad or incorrect syntax in address.<br/><br/><i>Netux SND HTTP Server version 1.3</i>", "400 bad")     EndIf EndFunc Func _HTTP_GetPost($s_Buffer) ; parses incoming POST data     Local $sTempPost, $sLen, $sPostData, $sTemp          ; Get the lenght of the data in the POST     $sTempPost = StringTrimLeft($s_Buffer, StringInStr($s_Buffer, "Content-Length:"))     $sLen = StringTrimLeft($sTempPost, StringInStr($sTempPost, ": "))          ; Create the base struck     $sPostData = StringSplit(StringRight($s_Buffer, $sLen), "&")          Local $sReturn[$sPostData[0] + 1][2]          For $t = 1 To $sPostData[0]         $sTemp = StringSplit($sPostData[$t], "=")         If $sTemp[0] >= 2 Then             $sReturn[$t][0] = $sTemp[1]             $sReturn[$t][1] = $sTemp[2]         EndIf     Next          Return $sReturn EndFunc Func _HTTP_Post($sName, $sArray) ; Returns a POST variable like a associative array.     For $i = 1 to UBound($sArray) - 1         If $sArray[$i][0] = $sName Then             Return $sArray[$i][1]         EndIf     Next     Return "" EndFunc Func _log($text) ; its just for logging     if IniRead($intcfg, "Main", "log", "true") = "true" Then         local $ilog = FileOpen($Dlog, 1)         FileWrite($ilog, @HOUR & ":" & @MIN & ":" & @SEC & ":" & $text & @CRLF)     EndIf EndFunc Func TCPSocketToIP($SHOCKET) ;from the helpfile     Local $sockaddr, $aRet          $sockaddr = DllStructCreate("short;ushort;uint;char[8]")          $aRet = DllCall("Ws2_32.dll", "int", "getpeername", "int", $SHOCKET, _             "ptr", DllStructGetPtr($sockaddr), "int*", DllStructGetSize($sockaddr))     If Not @error And $aRet[0] = 0 Then         $aRet = DllCall("Ws2_32.dll", "str", "inet_ntoa", "int", DllStructGetData($sockaddr, 3))         If Not @error Then $aRet = $aRet[0]     Else         $aRet = 0     EndIf          $sockaddr = 0          Return $aRet EndFunc ;==>SocketToIP Func _autodetectscript($request, $hSocket)     $snp = StringSplit($request, "?")     If FileExists($sRootDir & $snp[1]) Then         $ipid = Run($autoit & ' "' & $sRootDir & $snp[1] & '"', '', '', 0x8)         Local $data         while ProcessExists($ipid)             Sleep(100)         wend         $data = StdoutRead($ipid)         Sleep(100) ;dont know why it needs to sleep it just dose         _HTTP_SendHtml($hSocket, $data)     Else         _HTTP_Send404($hSocket)     EndIf EndFunc Func _exit()     _log("Server Closed") EndFunc
  3. Like
    MachinistProgrammer got a reaction from mesale0077 in Light Hover UDF   
    I know I'm not the first to make a Hover UDF, but i think a lot of the other Hover UDF are very complicated and hard to use so I made GUICtrl_hover it is light, easy to understand and only has one known bug (if you delete a GUI without disposing of old HoverIds will  cause  new items to trigger old HoverIds)
     
    GUICtrl_Hover.zip
  4. Like
    MachinistProgrammer got a reaction from jaberwacky in Light Hover UDF   
    I know I'm not the first to make a Hover UDF, but i think a lot of the other Hover UDF are very complicated and hard to use so I made GUICtrl_hover it is light, easy to understand and only has one known bug (if you delete a GUI without disposing of old HoverIds will  cause  new items to trigger old HoverIds)
     
    GUICtrl_Hover.zip
  5. Like
    MachinistProgrammer got a reaction from mesale0077 in making buttions with array   
    this is the project im working on it is almost done

    ;#GUIBuilder++.au3#================================== ;File Name.......:GUIBuilder++.au3 ;Creator.........:sean.campbell7 ;Created with....:Created with ISN AutoIt Studio ;Version.........:0.91 BETA ;============================================= Opt("GUIResizeMode", 802) #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <editconstants.au3> #Include <GuiButton.au3> #include <array.au3> #include <misc.au3> #include <TabConstants.au3> $crc = 0 Global $guihandle = "$HGUI" $xx = 0 $au3 = "" $codescreen = GUICreate("compiled code", 350, 350, -1, -1, $WS_CAPTION, $WS_EX_TOPMOST) $code = GUICtrlCreateEdit("", 20, 20, 310, 240, 2048, -1) GUICtrlSetBkColor($code, 0xFFFFFF) $cc = GUICtrlCreateButton("Copy", 220, 280, 100, 30, -1, -1) $ok = GUICtrlCreateButton("Ok", 120, 280, 100, 30, -1, -1) $sc = GUICtrlCreateButton("Save as", 20, 280, 100, 30, -1, -1) Global $ctrldata[1][8], $rdm = 1, $copyobj[7] $toolbar = GUICreate("GUIBuilder++", @DesktopWidth -5, @DesktopWidth -300, 0, 0, 0x00010000 + 0x00020000) $d = GUICtrlCreateButton("Date", 50, 300, 50, 50, -1, -1) $pb = GUICtrlCreateButton("progress bar", 0, 300, 50, 50, -1, -1) $s = GUICtrlCreateButton("slider", 50, 250, 50, 50, -1, -1) $co = GUICtrlCreateButton("combo box", 0, 350, 50, 50, -1, -1) $li = GUICtrlCreateButton("listbox", 50, 400, 50, 50, -1, -1) $g = GUICtrlCreateButton("group", 0, 400, 50, 50, -1, -1) $t = GUICtrlCreateButton("treeview", 50, 350, 50, 50, -1, -1) $i = GUICtrlCreateButton("input", 0, 150, 50, 50, -1, -1) $l = GUICtrlCreateButton("Lable", 50, 100, 50, 50, -1, -1) $b = GUICtrlCreateButton("Button", 0, 100, 50, 50, -1, -1) $c = GUICtrlCreateButton("checkbox", 50, 150, 50, 50, -1, -1) $ic = GUICtrlCreateButton("icon", 0, 250, 50, 50, -1, -1) $im = GUICtrlCreateButton("image", 50, 200, 50, 50, -1, -1) $r = GUICtrlCreateButton("radiobox", 0, 200, 50, 50, -1, -1) $e = GUICtrlCreateButton("edit", 0, 450, 50, 50) $ca = GUICtrlCreateButton("calender", 50, 450, 50, 50) $prop = GUICtrlCreateButton("GUI properties", 0, 50, 100, 50) $iFile = GUICtrlCreateMenu("File") $iFile_Export = GUICtrlCreateMenuItem('E&xport' & @TAB & 'Ctrl + E',$iFile) GUISetState(@SW_SHOW, $toolbar) GUISetState(@SW_MAXIMIZE, $toolbar) Global $lao $GUIprop = GUICreate("Gui Properties", 350, 307, -1, -1, -1, $ws_ex_topmost + $WS_EX_TOOLWINDOW) $tab = GUICtrlCreatetab(20, 20, 310, 240, 1024, -1) GUICtrlCreateTabItem("General") $wintit = GUICtrlCreateInput("", 140, 110, 150, 22, -1, 512) $hgui = GUICtrlCreateInput("HGUI", 140, 80, 150, 22, -1, 512) GUICtrlCreateLabel("Window Title:", 40, 113, 80, 15, -1, -1) GUICtrlSetBkColor(-1, "-2") GUICtrlCreateLabel("Window handle:$", 40, 83, 96, 15, -1, -1) GUICtrlSetBkColor(-1, "-2") $guihig = GUICtrlCreateInput(0, 140, 180, 50, 20, 8192, 512) GUICtrlCreateUpdown(-1) $guiwid = GUICtrlCreateInput("0", 140, 150, 50, 20, 8192, 512) GUICtrlCreateUpdown(-1) GUICtrlCreateLabel("GUI Hight:", 40, 183, 59, 15, -1, -1) GUICtrlSetBkColor(-1, "-2") GUICtrlCreateLabel("Px", 200, 183, 50, 15, -1, -1) GUICtrlSetBkColor(-1, "-2") GUICtrlCreateLabel("GUI Width:", 40, 153, 59, 15, -1, -1) GUICtrlSetBkColor(-1, "-2") GUICtrlCreateLabel("Px", 200, 153, 50, 15, -1, -1) GUICtrlSetBkColor(-1, "-2") GUICtrlCreateTabItem("") GUICtrlCreateLabel("GUI Colour", 40, 213, 71, 15, -1, -1) GUICtrlSetBkColor(-1, "-2") $colour = GUICtrlCreateInput("0xF0F0F0", 140, 210, 75, 20, -1, 512) GUICtrlCreateButton("Colour", 220, 210, 50, 20, -1, -1) $gcl = GUICtrlCreateButton("Cancel", 180, 270, 100, 30, -1, -1) $gok = GUICtrlCreateButton("Ok", 80, 270, 100, 30, -1, -1) $ctrledit = GUICreate("Control editor", 230, 400, @DesktopWidth / 4 * 3, -1, $WS_CAPTION, $WS_EX_TOPMOST) $apply = GUICtrlCreateButton("apply", 15, 340, 100, 30) $compile = GUICtrlCreateButton("compile", 115, 340, 100, 30) GUICtrlCreateTab(10, 30, 210, 300, $TCS_VERTICAL) GUICtrlCreateTabItem("General") $xpos = GUICtrlCreateInput("", 60, 40, 40, 22, $ES_NUMBER) GUICtrlCreateUpdown($xpos) GUICtrlCreateLabel("X", 50, 42, 22, 22) $ypos = GUICtrlCreateInput("", 120, 40, 40, 22, $ES_NUMBER) GUICtrlCreateUpdown($ypos) GUICtrlCreateLabel("Y", 110, 42, 22, 22) $name = GUICtrlCreateInput("", 60, 100, 100, 22) GUICtrlCreateLabel("Data", 60, 85, 50, 22) GUICtrlCreateLabel("handle", 60, 125, 50, 22) $handle = GUICtrlCreateInput("", 60, 144, 100, 22) GUICtrlCreateTabItem("Apearance") $width1 = GUICtrlCreateInput("", 60, 40, 40, 22, $ES_NUMBER) GUICtrlCreateUpdown($width1) $hight1 = GUICtrlCreateInput("", 120, 40, 40, 22, $ES_NUMBER) GUICtrlCreateUpdown($hight1) GUICtrlCreateTabItem("Style") GUICtrlCreateTabItem("StyleEx") GUICtrlCreateTabItem("State") Global $key[1][2] GUISetState(@SW_SHOW, $ctrledit) $board = GUICreate("new window", 350, 350, -1, -1, $WS_OVERLAPPEDWINDOW, $WS_EX_TOPMOST + $WS_EX_TOOLWINDOW) $del = GUICtrlCreateDummy() $copy = GUICtrlCreateDummy() $paste = GUICtrlCreateDummy() Global $keys[3][2] $keys[0][1] = $del $keys[0][0] = "{del}" $keys[1][1] = $copy $keys[1][0] = "^c" $keys[2][1] = $paste $keys[2][0] = "^v" GUISetAccelerators($keys) GUISetState(@SW_SHOW, $board) While 1  $cMsg = GUIGetCursorInfo($board)  $nMsg = GUIGetMsg()  Switch $nMsg   Case $GUI_EVENT_CLOSE    Exit   Case $ok    GUISetState(@SW_HIDE, $codescreen)    GUISetState(@SW_SHOW, $board)    $crc = 0   Case $prop    $oo = WinGetClientSize($board)    GUICtrlSetData($wintit, WinGetTitle($board))    GUICtrlSetData($guihig, $oo[1])    GUICtrlSetData($guiwid, $oo[0])    GUISetState(@SW_SHOW, $GUIprop)    $xx = 1   Case $gok    WinMove($board, "", @DesktopWidth / 2 - GUICtrlRead($guihig) / 2, @DesktopHeight / 2 - GUICtrlRead($guiwid) / 2, GUICtrlRead($guiwid) + 16, GUICtrlRead($guihig) + 34)    WinSetTitle($board, "", GUICtrlRead($wintit))    $guihandle = "$" & GUICtrlRead($hgui)    $xx = 0    GUISetState(@SW_Hide, $GUIprop)    GUISetState(@SW_SHOW, $board)   Case $gcl    GUISetState(@SW_hide, $GUIprop)    GUISetState(@SW_SHOW, $board)    $xx = 0   Case $sc    GUISetState(@SW_HIDE, $codescreen)    GUISetState(@SW_HIDE, $board)    GUISetState(@SW_HIDE, $ctrledit)    $dat = FilesaveDialog("Save script", "", "Autoit 3 script files(*.au3)")    If $dat <> "" Then     FileWrite($dat & ".au3", $au3)    endif    $crc = 0    GUISetState(@SW_SHOW, $ctrledit)    GUISetState(@SW_SHOW, $board)   Case $iFile_Export    _compile(0)    GUISetState(@SW_HIDE, $codescreen)    GUISetState(@SW_HIDE, $board)    GUISetState(@SW_HIDE, $ctrledit)    $dat = FilesaveDialog("Save script", "", "Autoit 3 script files(*.au3)")    If $dat <> "" Then     $id = FileOpen($dat & ".au3",2)     FileWrite($id, $au3)    endif    GUISetState(@SW_SHOW, $ctrledit)    GUISetState(@SW_SHOW, $board)   Case $cc    ClipPut($au3)   Case $width1, $hight1    _itemsetsize(GUICtrlRead($width1), GUICtrlRead($hight1))   Case $xpos, $ypos    _itemsetpos(GUICtrlRead($xpos), GUICtrlRead($ypos))   Case $name    _itemsetname(GUICtrlRead($name))   Case $apply    _itemsetname(GUICtrlRead($name))    _itemsetpos(GUICtrlRead($xpos), GUICtrlRead($ypos))    _itemsetsize(GUICtrlRead($width1), GUICtrlRead($hight1))    If GUICtrlRead($handle) <> "" Then     For $i = 0 to UBound($ctrldata) - 1      If $ctrldata[$i][0] = $lao and $lao <> "" Then       $ctrldata[$i][7] = "$" & GUICtrlRead($handle)      EndIf     Next    EndIf   Case $del    _deleteitem($lao)   Case $copy    _copy()   Case $paste    _paste()   Case -7, -11    If $cMsg[4] > 0 Then _guictrldrag($cMsg[4], $board)   Case $b    _createitem("button")   Case $l    _createitem("label")   case $pb    _createitem("progress")   case $i    _createitem("input")   Case $e    _createitem("edit")   Case $c    _createitem("checkbox")   Case $r    _createitem("radiobox")   Case $s    _createitem("slider")   Case $ic    _createitem("icon")   case $im    _createitem("image")   Case $d    _createitem("date")   case $ca    _createitem("calender")   Case $co    _createitem("combo")   Case $li    _createitem("listbox")   case $t    _createitem("tree")   Case $g    _createitem("group")   Case $compile    _compile()   Case $GUI_EVENT_MINIMIZE    GUISetState(@SW_HIDE, $board)    GUISetState(@SW_HIDE, $ctrledit)    GUISetState(@SW_HIDE, $codescreen)    GUISetState(@SW_HIDE, $GUIprop)   Case $GUI_EVENT_RESTORE    GUISetState(@SW_show, $ctrledit)    GUISetState(@SW_Show, $board)    If $crc Then GUISetState(@SW_SHOW, $codescreen)    If $xx Then GUISetState(@SW_SHOW, $GUIprop)  EndSwitch  WinSetOnTop($ctrledit, "", 1) WEnd Func _guictrldrag($control, $hgui)  $cbutton = $control  $lao = $control  $cInfo = GUIGetCursorInfo($hGUI)  $aPos = ControlGetPos($hGUI, "", $cButton)  $iSubtractX = $cInfo[0] - $aPos[0]  $iSubtractY = $cInfo[1] - $aPos[1]  Sleep(200)  $cInfo = GUIGetCursorInfo($hGUI)  If $cInfo[2] = 1 Then   $cInfo = GUIGetCursorInfo($hGUI)   If $cInfo[4] = $cButton Then    Do     $cInfo = GUIGetCursorInfo($hGUI)     ControlMove($hGUI, "", $cButton, $cInfo[0] - $iSubtractX, $cInfo[1] - $iSubtractY)     For $i = 0 to UBound($ctrldata) - 1      If $ctrldata[$i][0] = $control and $control <> "" Then       $ctrldata[$i][1] = $cInfo[0] - $iSubtractX       $ctrldata[$i][2] = $cInfo[1] - $iSubtracty      EndIf     Next     For $i = 0 to UBound($ctrldata) - 1      If $ctrldata[$i][0] = $lao and $lao <> "" Then       GUICtrlSetData($xpos, $ctrldata[$i][1])       GUICtrlSetData($ypos, $ctrldata[$i][2])       GUICtrlSetData($width1, $ctrldata[$i][3])       GUICtrlSetData($hight1, $ctrldata[$i][4])       GUICtrlSetData($name, $ctrldata[$i][5])       GUICtrlSetData($handle, StringTrimLeft($ctrldata[$i][7], 1))      EndIf     next    Until Not $cInfo[2]   EndIf  Else   return 0  EndIf  Do  Until GUIGetMsg() = 0  _itemsetpos(_round($cInfo[0] - $iSubtractX), _round($cInfo[1] - $iSubtractY)) EndFunc Func _createitem($type, $x = 0, $y = 0, $width = -1, $hight = -1)  $rdm += 1  Switch $type   Case "button"    If $width = -1 then $width = 50    If $hight = -1 then $hight = 30    $ct = GUICtrlCreateButton("my text", $x, $y, $width, $hight)    ReDim $ctrldata[$rdm + 1][8]    $ctrldata[$rdm][0] = $ct    $ctrldata[$rdm][1] = $x    $ctrldata[$rdm][2] = $y    $ctrldata[$rdm][3] = $width    $ctrldata[$rdm][4] = $hight    $ctrldata[$rdm][5] = "my text"   Case "label"    If $width = -1 then $width = 100    If $hight = -1 then $hight = 20    $ct = GUICtrlCreateLabel("my text", $x, $y, $width, $hight)    ReDim $ctrldata[$rdm + 1][8]    $ctrldata[$rdm][0] = $ct    $ctrldata[$rdm][1] = $x    $ctrldata[$rdm][2] = $y    $ctrldata[$rdm][3] = $width    $ctrldata[$rdm][4] = $hight    $ctrldata[$rdm][5] = "my text"   Case "input"    If $width = -1 then $width = 100    If $hight = -1 then $hight = 20    $ct = GUICtrlCreateinput("my text", $x, $y, $width, $hight)    ReDim $ctrldata[$rdm + 1][8]    $ctrldata[$rdm][0] = $ct    $ctrldata[$rdm][1] = $x    $ctrldata[$rdm][2] = $y    $ctrldata[$rdm][3] = $width    $ctrldata[$rdm][4] = $hight    $ctrldata[$rdm][5] = "my text"   Case "Edit"    If $width = -1 then $width = 150    If $hight = -1 then $hight = 150    $ct = GUICtrlCreateEdit("my text", $x, $y, $width, $hight)    ReDim $ctrldata[$rdm + 1][8]    $ctrldata[$rdm][0] = $ct    $ctrldata[$rdm][1] = $x    $ctrldata[$rdm][2] = $y    $ctrldata[$rdm][3] = $width    $ctrldata[$rdm][4] = $hight    $ctrldata[$rdm][5] = "my text"   Case "progress"    If $width = -1 then $width = 100    If $hight = -1 then $hight = 20    $ct = GUICtrlCreateProgress($x, $y, $width, $hight)    GUICtrlSetData(-1, 50)    ReDim $ctrldata[$rdm + 1][8]    $ctrldata[$rdm][0] = $ct    $ctrldata[$rdm][1] = $x    $ctrldata[$rdm][2] = $y    $ctrldata[$rdm][3] = $width    $ctrldata[$rdm][4] = $hight    $ctrldata[$rdm][5] = 50   Case "checkbox"    If $width = -1 then $width = 50    If $hight = -1 then $hight = 20    $ct = GUICtrlCreateCheckbox("my text", $x, $y, $width, $hight)    ReDim $ctrldata[$rdm + 1][8]    $ctrldata[$rdm][0] = $ct    $ctrldata[$rdm][1] = $x    $ctrldata[$rdm][2] = $y    $ctrldata[$rdm][3] = $width    $ctrldata[$rdm][4] = $hight    $ctrldata[$rdm][5] = "my text"   Case "radiobox"    If $width = -1 then $width = 50    If $hight = -1 then $hight = 20    $ct = GUICtrlCreateRadio("my text", $x, $y, $width, $hight)    ReDim $ctrldata[$rdm + 1][8]    $ctrldata[$rdm][0] = $ct    $ctrldata[$rdm][1] = $x    $ctrldata[$rdm][2] = $y    $ctrldata[$rdm][3] = $width    $ctrldata[$rdm][4] = $hight    $ctrldata[$rdm][5] = "my text"   Case "slider"    If $width = -1 then $width = 150    If $hight = -1 then $hight = 20    $ct = GUICtrlCreateSlider($x, $y, $width, $hight)    ReDim $ctrldata[$rdm + 1][8]    $ctrldata[$rdm][0] = $ct    $ctrldata[$rdm][1] = $x    $ctrldata[$rdm][2] = $y    $ctrldata[$rdm][3] = $width    $ctrldata[$rdm][4] = $hight    $ctrldata[$rdm][5] = 0   Case "icon"    If $width = -1 then $width = 50    If $hight = -1 then $hight = 50    $ct = GUICtrlCreateIcon(@scriptdir & "\dummy.ico", -1, $x, $y, $width, $hight)    ReDim $ctrldata[$rdm + 1][8]    $ctrldata[$rdm][0] = $ct    $ctrldata[$rdm][1] = $x    $ctrldata[$rdm][2] = $y    $ctrldata[$rdm][3] = $width    $ctrldata[$rdm][4] = $hight    $ctrldata[$rdm][5] = "my text"   Case "image"    If $width = -1 then $width = 50    If $hight = -1 then $hight = 50    $ct = GUICtrlCreatePic(@scriptdir & "\dummy.bmp", $x, $y, $width, $hight)    ReDim $ctrldata[$rdm + 1][8]    $ctrldata[$rdm][0] = $ct    $ctrldata[$rdm][1] = $x    $ctrldata[$rdm][2] = $y    $ctrldata[$rdm][3] = $width    $ctrldata[$rdm][4] = $hight    $ctrldata[$rdm][5] = ""   Case "date"    If $width = -1 then $width = 150    If $hight = -1 then $hight = 20    $ct = GUICtrlCreateDate("", $x, $y, $width, $hight)    ReDim $ctrldata[$rdm + 1][8]    $ctrldata[$rdm][0] = $ct    $ctrldata[$rdm][1] = $x    $ctrldata[$rdm][2] = $y    $ctrldata[$rdm][3] = $width    $ctrldata[$rdm][4] = $hight    $ctrldata[$rdm][5] = ""   Case "calender"    If $width = -1 then $width = 180    If $hight = -1 then $hight = 164    $ct = GUICtrlCreateMonthCal("", $x, $y, $width, $hight)    ReDim $ctrldata[$rdm + 1][8]    $ctrldata[$rdm][0] = $ct    $ctrldata[$rdm][1] = $x    $ctrldata[$rdm][2] = $y    $ctrldata[$rdm][3] = $width    $ctrldata[$rdm][4] = $hight    $ctrldata[$rdm][5] = ""   Case "combo"    If $width = -1 then $width = 50    If $hight = -1 then $hight = 30    $ct = GUICtrlCreateCombo("my text", $x, $y, $width, $hight)    GUICtrlSetData(-1, "item1|item2|item3", "item1")    ReDim $ctrldata[$rdm + 1][8]    $ctrldata[$rdm][0] = $ct    $ctrldata[$rdm][1] = $x    $ctrldata[$rdm][2] = $y    $ctrldata[$rdm][3] = $width    $ctrldata[$rdm][4] = $hight    $ctrldata[$rdm][5] = "item1|item2|item3"   Case "listbox"    If $width = -1 then $width = 150    If $hight = -1 then $hight = 150    $ct = GUICtrlCreatelist("my text", $x, $y, $width, $hight)    ReDim $ctrldata[$rdm + 1][8]    $ctrldata[$rdm][0] = $ct    $ctrldata[$rdm][1] = $x    $ctrldata[$rdm][2] = $y    $ctrldata[$rdm][3] = $width    $ctrldata[$rdm][4] = $hight    $ctrldata[$rdm][5] = "my text"   Case "tree"    If $width = -1 then $width = 150    If $hight = -1 then $hight = 150    $ct = GUICtrlCreateTreeView("my text", $x, $y, $width, $hight)    $td = GUICtrlCreateTreeViewItem("my text", $ct)    GUICtrlCreateTreeViewItem("sub", $td)    ReDim $ctrldata[$rdm + 1][8]    $ctrldata[$rdm][0] = $ct    $ctrldata[$rdm][1] = $x    $ctrldata[$rdm][2] = $y    $ctrldata[$rdm][3] = $width    $ctrldata[$rdm][4] = $hight    $ctrldata[$rdm][5] = "my text"   Case "group"    If $width = -1 then $width = 150    If $hight = -1 then $hight = 150    $ct = GUICtrlCreateGroup("my text", $x, $y, $width, $hight)    ReDim $ctrldata[$rdm + 1][8]    $ctrldata[$rdm][0] = $ct    $ctrldata[$rdm][1] = $x    $ctrldata[$rdm][2] = $y    $ctrldata[$rdm][3] = $width    $ctrldata[$rdm][4] = $hight    $ctrldata[$rdm][5] = "my text"  EndSwitch  GUICtrlSetCursor($ct, 9)  $ctrldata[$rdm][6] = $type  $ctrldata[$rdm][7] = "$" & $type & $rdm - 1  $lao = $ct  For $i = 0 to UBound($ctrldata) - 1   If $ctrldata[$i][0] = $lao and $lao <> "" Then    GUICtrlSetData($xpos, $ctrldata[$i][1])    GUICtrlSetData($name, $ctrldata[$i][5])    GUICtrlSetData($width1, $ctrldata[$i][3])    GUICtrlSetData($hight1, $ctrldata[$i][4])    GUICtrlSetData($ypos, $ctrldata[$i][2])    GUICtrlSetData($handle, StringTrimLeft($ctrldata[$i][7], 1))   EndIf  Next  ControlFocus($board, "", GUICtrlGetHandle($ct)) EndFunc Func _deleteitem($item)  GUICtrlDelete($item)  For $i = 0 to UBound($ctrldata) - 1   If $ctrldata[$i][0] = $item and $item <> "" Then    _ArrayDelete($ctrldata, $i)    $lao = $ctrldata[$i - 1][0]    GUICtrlSetData($xpos, $ctrldata[$i - 1][1])    GUICtrlSetData($name, $ctrldata[$i - 1][5])    GUICtrlSetData($width1, $ctrldata[$i - 1][3])    GUICtrlSetData($hight1, $ctrldata[$i - 1][4])    GUICtrlSetData($ypos, $ctrldata[$i - 1][2])    GUICtrlSetData($handle, StringTrimLeft($ctrldata[$i - 1][7], 1))   EndIf  Next  ControlFocus($board, "", $item) EndFunc Func _itemsetpos($x, $y, $item = $lao)  GUICtrlSetPos($item, $x, $y)  for $i = 0 to UBound($ctrldata) - 1   If $ctrldata[$i][0] = $item and $item <> "" Then    $ctrldata[$i][1] = $x    $ctrldata[$i][2] = $y    GUICtrlSetData($xpos, $ctrldata[$i][1])    GUICtrlSetData($ypos, $ctrldata[$i][2])   EndIf  Next EndFunc Func _itemsetname($name, $item = $lao)  GUICtrlSetdata($item, $name)  for $i = 0 to UBound($ctrldata) - 1   If $ctrldata[$i][0] = $item and $item <> "" Then    $ctrldata[$i][5] = $name   EndIf  Next EndFunc Func _itemsetsize($x, $y, $item = $lao)  for $i = 0 to UBound($ctrldata) - 1   If $ctrldata[$i][0] = $item and $item <> "" Then    $ctrldata[$i][3] = $x    $ctrldata[$i][4] = $y    GUICtrlSetPos($item, $ctrldata[$i][1], $ctrldata[$i][2], $x, $y)   EndIf  Next EndFunc Func _round($number)  If $number < 0 then Return 0  Global $n = $Number  $ilen = StringLen($n)  if StringTrimLeft($n, $ilen - 1) = 5 or StringTrimleft($n, $ilen - 1) = 0 Then Return $n  if StringTrimLeft($n, $ilen - 1) > 5 Then   Do    $ilen = StringLen($n)    if StringTrimLeft($n, $ilen - 1) <= 7 Then ;so that 7 will become 5 not 10     $n -= 1    ElseIf StringTrimLeft($n, $ilen - 1) >= 7 Then     $n += 1    EndIf    $ilen = StringLen($n)   Until StringTrimLeft($n, $ilen - 1) = 5 or StringTrimleft($n, $ilen - 1) = 0  Else   Do    $ilen = StringLen($n)    if StringTrimLeft($n, $ilen - 1) < 3 Then ;so that 3 will become 5 not 0     $n -= 1    ElseIf StringTrimLeft($n, $ilen - 1) >= 3 Then     $n += 1    EndIf    $ilen = StringLen($n)   Until StringTrimLeft($n, $ilen - 1) = 5 or StringTrimleft($n, $ilen - 1) = 0  EndIf  Return $n EndFunc Func _copy($item = $lao)  For $i = 0 to UBound($ctrldata) - 1   If $ctrldata[$i][0] = $item and $item <> "" Then    $copyobj[1] = $ctrldata[$i][1]    $copyobj[2] = $ctrldata[$i][2]    $copyobj[3] = $ctrldata[$i][3]    $copyobj[4] = $ctrldata[$i][4]    $copyobj[5] = $ctrldata[$i][5]    $copyobj[6] = $ctrldata[$i][6]   EndIf  Next EndFunc Func _paste()  If $copyobj[1] <> "" Then   _createitem($copyobj[6], _round($cMsg[0]), _round($cMsg[1]), $copyobj[3], $copyobj[4])   _itemsetname($copyobj[5])   GUICtrlSetData($name, $copyobj[5])  EndIf EndFunc Func _compile($iflag=1)  Global $au3 = ";created with guibuilder++" & @crlf & "#include <GUIConstantsEx.au3>" & @CRLF & "#include <WindowsConstants.au3>" & @CRLF  $size = WinGetClientSize($board)  $au3 &= $guihandle & " = GUICreate('" & WinGetTitle($board) & "'," & $size[0] & "," & $size[1] & ")" & @CRLF  For $i = 0 To UBound($ctrldata) - 1   Switch $ctrldata[$i][6]    Case "button"     $au3 &= $ctrldata[$i][7] & " = GUICtrlCreateButton('" & $ctrldata[$i][5] & "'," & $ctrldata[$i][1] & "," & $ctrldata[$i][2] & "," & $ctrldata[$i][3] & "," & $ctrldata[$i][4] & ")" & @crlf    Case "label"     $au3 &= $ctrldata[$i][7] & " = GUICtrlCreateLabel('" & $ctrldata[$i][5] & "'," & $ctrldata[$i][1] & "," & $ctrldata[$i][2] & "," & $ctrldata[$i][3] & "," & $ctrldata[$i][4] & ")" & @crlf    Case "input"     $au3 &= $ctrldata[$i][7] & " = GUICtrlCreateInput('" & $ctrldata[$i][5] & "'," & $ctrldata[$i][1] & "," & $ctrldata[$i][2] & "," & $ctrldata[$i][3] & "," & $ctrldata[$i][4] & ")" & @crlf    Case "Edit"     $au3 &= $ctrldata[$i][7] & " = GUICtrlCreateEdit('" & $ctrldata[$i][5] & "'," & $ctrldata[$i][1] & "," & $ctrldata[$i][2] & "," & $ctrldata[$i][3] & "," & $ctrldata[$i][4] & ")" & @crlf    Case "progress"     $au3 &= $ctrldata[$i][7] & " = GUICtrlCreateProgress('" & $ctrldata[$i][5] & "'," & $ctrldata[$i][1] & "," & $ctrldata[$i][2] & "," & $ctrldata[$i][3] & "," & $ctrldata[$i][4] & ")" & @crlf    Case "checkbox"     $au3 &= $ctrldata[$i][7] & " = GUICtrlCreateCheckbox('jmn" & $ctrldata[$i][5] & "'," & $ctrldata[$i][1] & "," & $ctrldata[$i][2] & "," & $ctrldata[$i][3] & "," & $ctrldata[$i][4] & ")" & @crlf    Case "radiobox"     $au3 &= $ctrldata[$i][7] & " = GUICtrlCreateRadio('" & $ctrldata[$i][5] & "'," & $ctrldata[$i][1] & "," & $ctrldata[$i][2] & "," & $ctrldata[$i][3] & "," & $ctrldata[$i][4] & ")" & @crlf    Case "slider"     $au3 &= $ctrldata[$i][7] & " = GUICtrlCreateSlider('" & $ctrldata[$i][1] & "'," & $ctrldata[$i][2] & "," & $ctrldata[$i][3] & "," & $ctrldata[$i][4] & ")" & @crlf & "guictrlsetdata(-1," & $ctrldata[$i][5] & ")" & @crlf    Case "icon"     $au3 &= $ctrldata[$i][7] & " = GUICtrlCreateIcon('" & $ctrldata[$i][5] & "',-1," & $ctrldata[$i][1] & "," & $ctrldata[$i][2] & "," & $ctrldata[$i][3] & "," & $ctrldata[$i][4] & ")" & @crlf    Case "image"     $au3 &= $ctrldata[$i][7] & " = GUICtrlCreatePic('" & $ctrldata[$i][5] & "'," & $ctrldata[$i][1] & "," & $ctrldata[$i][2] & "," & $ctrldata[$i][3] & "," & $ctrldata[$i][4] & ")" & @crlf    Case "date"     $au3 &= $ctrldata[$i][7] & " = GUICtrlCreateDate('" & $ctrldata[$i][5] & "'," & $ctrldata[$i][1] & "," & $ctrldata[$i][2] & "," & $ctrldata[$i][3] & "," & $ctrldata[$i][4] & ")" & @crlf    Case "calender"     $au3 &= $ctrldata[$i][7] & " = GUICtrlCreateMonthCal('" & $ctrldata[$i][5] & "'," & $ctrldata[$i][1] & "," & $ctrldata[$i][2] & "," & $ctrldata[$i][3] & "," & $ctrldata[$i][4] & ")" & @crlf    Case "combo"     $au3 &= $ctrldata[$i][7] & " = GUICtrlCreateCombo('" & $ctrldata[$i][5] & "'," & $ctrldata[$i][1] & "," & $ctrldata[$i][2] & "," & $ctrldata[$i][3] & "," & $ctrldata[$i][4] & ")" & @crlf    Case "listbox"     $au3 &= $ctrldata[$i][7] & " = GUICtrlCreateList('" & $ctrldata[$i][5] & "'," & $ctrldata[$i][1] & "," & $ctrldata[$i][2] & "," & $ctrldata[$i][3] & "," & $ctrldata[$i][4] & ")" & @crlf    Case "tree"     $au3 &= $ctrldata[$i][7] & " = GUICtrlCreateTreeView('" & $ctrldata[$i][5] & "'," & $ctrldata[$i][1] & "," & $ctrldata[$i][2] & "," & $ctrldata[$i][3] & "," & $ctrldata[$i][4] & ")" & @crlf    Case "group"     $au3 &= $ctrldata[$i][7] & " = GUICtrlCreateGroup('" & $ctrldata[$i][5] & "'," & $ctrldata[$i][1] & "," & $ctrldata[$i][2] & "," & $ctrldata[$i][3] & "," & $ctrldata[$i][4] & ")" & @crlf   EndSwitch  next  $au3 &= "GUISetState()" & @CRLF & "while 1" & @CRLF & @TAB & "Switch GUIGetMsg()" & @CRLF & @TAB & @TAB & "Case -3" & @CRLF & @TAB & "Exit" & @crlf & @TAB & "EndSwitch" & @CRLF & "WEnd"  if $iflag Then  GUICtrlSetData($code, $au3)  GUISetState(@SW_SHOW, $codescreen)  EndIf EndFunc
  6. Like
    MachinistProgrammer reacted to mesale0077 in MsgBox++.au3 better looking mesage boxes   
    hi
    nice code
    thank you
    window moved

    modified MsgBox++.au3
    msgbox++.au3
×
×
  • Create New...