Jump to content

ichigo325

Active Members
  • Posts

    34
  • Joined

  • Last visited

Everything posted by ichigo325

  1. Didn't see that in help file. Ok thanks. Really appreciated it!
  2. Any way to change context menu background color? from this example script... #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> Example2() Func Example2() Local $hGui, $OptionsBtn, $OptionsDummy, $OptionsContext, $OptionsCommon, $OptionsFile, $msg Local $OptionsExit, $HelpBtn, $HelpDummy, $HelpContext, $HelpWWW, $HelpAbout $hGui = GUICreate("My GUI", 170, 40) $OptionsBtn = GUICtrlCreateButton("&Options", 10, 10, 70, 20, $BS_FLAT) ; At first create a dummy control for the options and a contextmenu for it $OptionsDummy = GUICtrlCreateDummy() $OptionsContext = GUICtrlCreateContextMenu($OptionsDummy) $OptionsCommon = GUICtrlCreateMenuItem("Common", $OptionsContext) $OptionsFile = GUICtrlCreateMenuItem("File", $OptionsContext) GUICtrlCreateMenuItem("", $OptionsContext) $OptionsExit = GUICtrlCreateMenuItem("Exit", $OptionsContext) $HelpBtn = GUICtrlCreateButton("&Help", 90, 10, 70, 20, $BS_FLAT) ; Create a dummy control and a contextmenu for the help too $HelpDummy = GUICtrlCreateDummy() $HelpContext = GUICtrlCreateContextMenu($HelpDummy) $HelpWWW = GUICtrlCreateMenuItem("Website", $HelpContext) GUICtrlCreateMenuItem("", $HelpContext) $HelpAbout = GUICtrlCreateMenuItem("About...", $HelpContext) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $OptionsExit, $GUI_EVENT_CLOSE ExitLoop Case $OptionsBtn ShowMenu($hGui, $msg, $OptionsContext) Case $HelpBtn ShowMenu($hGui, $msg, $HelpContext) Case $HelpAbout MsgBox(64, "About...", "GUICtrlGetHandle-Sample") EndSwitch WEnd GUIDelete() EndFunc ;==>Example2 ; Show a menu in a given GUI window which belongs to a given GUI ctrl Func ShowMenu($hWnd, $CtrlID, $nContextID) Local $arPos, $x, $y Local $hMenu = GUICtrlGetHandle($nContextID) $arPos = ControlGetPos($hWnd, "", $CtrlID) $x = $arPos[0] $y = $arPos[1] + $arPos[3] ClientToScreen($hWnd, $x, $y) TrackPopupMenu($hWnd, $hMenu, $x, $y) EndFunc ;==>ShowMenu ; Convert the client (GUI) coordinates to screen (desktop) coordinates Func ClientToScreen($hWnd, ByRef $x, ByRef $y) Local $stPoint = DllStructCreate("int;int") DllStructSetData($stPoint, 1, $x) DllStructSetData($stPoint, 2, $y) DllCall("user32.dll", "int", "ClientToScreen", "hwnd", $hWnd, "ptr", DllStructGetPtr($stPoint)) $x = DllStructGetData($stPoint, 1) $y = DllStructGetData($stPoint, 2) ; release Struct not really needed as it is a local $stPoint = 0 EndFunc ;==>ClientToScreen ; Show at the given coordinates (x, y) the popup menu (hMenu) which belongs to a given GUI window (hWnd) Func TrackPopupMenu($hWnd, $hMenu, $x, $y) DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $x, "int", $y, "hwnd", $hWnd, "ptr", 0) EndFunc ;==>TrackPopupMenu
  3. You can easily do this using WinApiEx Uploaded with ImageShack.us #Include <WinAPIEx.au3> #Include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Global $hForm, $AlphaKey = 0xABABAB $hForm = GUICreate('MyGUI', 400, 400, -1, -1, -1, $WS_EX_LAYERED) GUISetBkColor($AlphaKey) GUICtrlCreateInput('Simple Text', 20, 20, 360, 19) GUICtrlCreateEdit('', 20, 47, 360, 200) GUICtrlCreateButton('OK', 165, 370, 70, 23) GUICtrlCreateLabel("Label1",25,250,150,50) GUICtrlSetFont(-1,25,800) GUICtrlCreateLabel("Label1+1",25,300,150,50) GUICtrlSetFont(-1,25,800) GUICtrlSetColor(-1,0x00ff00) _WinAPI_SetLayeredWindowAttributes($hForm, $AlphaKey, 0, $LWA_COLORKEY) _WinAPI_DwmExtendFrameIntoClientArea($hForm) GUISetState() Do Until GUIGetMsg() = -3
  4. Hmm?? Try this.. RunWait("schtasks /create /s \\hostname /Ru SYSTEM /tn ""EncryptionTest"" /tr ""cmd /c sgestate /l | findstr /i ""Return code"" > c:\temp\enc.txt"" /sc once /st 00:00:00", "", @SW_HIDE)
  5. Ah, try Ghost Installer, you can fully customized your GUI but it is not free. Demo version available~
  6. Hmm.. I don't think you want this quite long codes.. But you may try.. #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GuiTreeView.au3> #include <WindowsConstants.au3> Global $TreeView1, $hSelected, $DayChild1, $Button2, $mListDay, $Button2 $Form1 = GUICreate("Form1", 633, 454, 192, 114) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") $Style = BitOR($TVS_NOHSCROLL, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP) $TreeView1 = _GUICtrlTreeView_Create($Form1, 40, 24, 185, 185, $Style, $WS_EX_CLIENTEDGE) $mListDay = _GUICtrlTreeView_Add($TreeView1, 0, "Daily") $DayChild1 = _GUICtrlTreeView_AddChild($TreeView1, $mListDay, "1. ") $DayChild2 = _GUICtrlTreeView_AddChild($TreeView1, $mListDay, "2. ") $mListMonth = _GUICtrlTreeView_Add($TreeView1, 0, "Monthly") $MonthChild1 = _GUICtrlTreeView_AddChild($TreeView1, $mListMonth, "11. ") $MonthChild2 = _GUICtrlTreeView_AddChild($TreeView1, $mListMonth, "22. ") $Button1 = GUICtrlCreateButton("Button1", 40, 232, 75, 25, $WS_GROUP) $Button2 = GUICtrlCreateButton("Button2", 152, 232, 75, 25, $WS_GROUP) GUICtrlSetState(-1, $GUI_DISABLE) GUISetState(@SW_SHOW) While 1 ;*If style loops $nMsg = GUIGetMsg() If $nMsg = -3 Then Exit EndIf WEnd Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndTreeview $hWndTreeview = $TreeView1 If Not IsHWnd($TreeView1) Then $hWndTreeview = GUICtrlGetHandle($TreeView1) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndTreeview Switch $iCode Case $NM_CLICK ; The user has clicked the left mouse button within the control _DebugPrint("$NM_CLICK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) ;~ Return 1 ; nonzero to not allow the default processing $hSelected = _GUICtrlTreeView_GetSelection($TreeView1) If $hSelected = $DayChild1 Then GUICtrlSetState($Button2, 128) If $hSelected = $mListDay Then GUICtrlSetState($Button2, 64) Return 0 ; zero to allow the default processing Case $NM_DBLCLK ; The user has double-clicked the left mouse button within the control _DebugPrint("$NM_DBLCLK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) ;~ Return 1 ; nonzero to not allow the default processing Return 0 ; zero to allow the default processing Case $NM_RCLICK ; The user has clicked the right mouse button within the control _DebugPrint("$NM_RCLICK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) ;~ Return 1 ; nonzero to not allow the default processing Return 0 ; zero to allow the default processing Case $NM_RDBLCLK ; The user has clicked the right mouse button within the control _DebugPrint("$NM_RDBLCLK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) ;~ Return 1 ; nonzero to not allow the default processing Return 0 ; zero to allow the default processing Case $NM_SETFOCUS ; control has received the input focus _DebugPrint("$NM_SETFOCUS" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) ; No return value Case $NM_KILLFOCUS ; control has lost the input focus _DebugPrint("$NM_KILLFOCUS" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) ; No return value EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func _DebugPrint($s_text, $line = @ScriptLineNumber) ConsoleWrite( _ "!===========================================================" & @LF & _ "+======================================================" & @LF & _ "-->Line(" & StringFormat("%04d", $line) & "):" & @TAB & $s_text & @LF & _ "+======================================================" & @LF) EndFunc ;==>_DebugPrint
  7. If you're very interested, try AutoIt and start making your installer but the script may be longer than NSIS script because every dialog/GUI you need to create. It depends on you whether you want to write customizable GUI which is more codes or standard installer GUI which is less code to write.
  8. For installer, i recommend you to use NSIS which is more easy and less code to write. Moreover, NSIS is specially built for writing installer, while AutoIt for automating the Windows GUI and general scripting.
  9. ;Right-click/ESC to exit ;Playing with AutoIt GUI $mGui = GUICreate("Full Transparent GUI", 300, 300, -1, -1, 0x80000000) GUISetBkColor(0xffffff, $mGui) WinSetTrans($mGui, "", 160) GUICtrlCreatePic("", 0, 0, 181, 101, -1) ;test code GUICtrlCreateLabel("wololo~", 5, 6, 300, 100,-1,0x00080000) GUICtrlSetFont(-1, 48, 600, -1, "Lucida Handwriting", "CLEARTYPE_QUALITY=5") GUICtrlSetBkColor(-1, -2) GUICtrlCreateProgress(10, 80, 280, 20,-1) GUICtrlSetData(-1,99.9) GUICtrlSetState(-1,256) GUICtrlCreateEdit(FileRead(FileOpen(@ScriptFullPath,0)),10,110,280,100,-1,0x00100000) GUICtrlSetBkColor(-1,0xfffffe) GUISetState() While 1 $Msg2 = GUIGetMsg() If $Msg2 = -9 Then Exit WEnd Can someone tell me why the GUI fully transparent after i added "GuiCtrlCreatePic"?
  10. Uhhmm.. Maybe this help you.. #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GuiTreeView.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 633, 454, 192, 114) $Style = BitOR($TVS_NOHSCROLL, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP) $TreeView1 = _GUICtrlTreeView_Create($Form1, 40, 24, 185, 185, $Style, $WS_EX_CLIENTEDGE) $mListDay = _GUICtrlTreeView_Add($TreeView1, 0, "Daily") $DayChild1 = _GUICtrlTreeView_AddChild($TreeView1, $mListDay, "1. ") $DayChild2 = _GUICtrlTreeView_AddChild($TreeView1, $mListDay, "2. ") $mListMonth = _GUICtrlTreeView_Add($TreeView1, 0, "Monthly") $MonthChild1 = _GUICtrlTreeView_AddChild($TreeView1, $mListMonth, "11. ") $MonthChild2 = _GUICtrlTreeView_AddChild($TreeView1, $mListMonth, "22. ") $Button1 = GUICtrlCreateButton("Button1", 40, 232, 75, 25, $WS_GROUP) $Button2 = GUICtrlCreateButton("Button2", 152, 232, 75, 25, $WS_GROUP) GUICtrlSetState(-1, $GUI_DISABLE) GUISetState(@SW_SHOW) ;~ While 1 ;*If style loops ;~ $nMsg = GUIGetMsg() ;~ If $nMsg = $GUI_EVENT_PRIMARYDOWN Then ;~ $hSelected = _GUICtrlTreeView_GetSelection($TreeView1) ;~ If $hSelected = $DayChild1 Then GUICtrlSetState($Button2,64) ;~ If $hSelected = $mListDay Then GUICtrlSetState($Button2,128) ;~ EndIf ;~ If $nMsg = -3 Then ;~ Exit ;~ EndIf ;~ WEnd While 1 ;*Switch/case style loop $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_PRIMARYDOWN $hSelected = _GUICtrlTreeView_GetSelection($TreeView1) If $hSelected = $DayChild1 Then GUICtrlSetState($Button2, 64) If $hSelected = $mListDay Then GUICtrlSetState($Button2, 128) EndSwitch WEnd
  11. See AutoIt Help, it will guide you with many example for each function.
  12. Try... #RequireAdmin Ping("www.google.com") If Not @error Then MsgBox(0, "Ping", "Online.") Else MsgBox(0, "Ping", "@error=" & @error) EndIf
  13. Here some simple example : $hFile = FileOpen(".\milk.txt",0) Run("notepad.exe") WinWaitActive("Untitled - Notepad") ControlSetText("[CLASS:Notepad]","","Edit1",FileRead($hFile)) FileClose($hFile)
  14. See help AutoIt Help -> AutoIt3 Limits/defaults Alternative way... #include <Array.au3> $x =FileOpen(".\urstring.txt",0) $sString = FileRead($x) $aString = StringSplit($sString, "],[", 3) _ArrayDisplay($aString)
  15. Hi, i can't test your code because i don't have Excel.. But i think i know how to do it.. Maybe you can use this simple code: _ExcelBookSaveAs($oExcel, $sPath & $Filename & ".xls", "xls")
  16. Hi, i tried your code.. I found 2 solution.. First example, #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $GUI_Width = 800 $GUI_Height = 800 $Path = @ScriptDir & "\" $Main_GUI = GUICreate("", $GUI_Width, $GUI_Height , Default , Default , $WS_POPUP , $WS_EX_LAYERED) GUICtrlCreatePic($Path & "Vis.Gif" , 0 , 0 , $GUI_Width , $GUI_Height) GUICtrlCreatePic($Path & "Frame.gif", 0, 0, 415, 338) GUICtrlCreatePic($Path & "Ext_Frame.gif", 270, 270, 315, 257) ;change the x and y position GUISetState(@SW_SHOW) While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Second example, used gdi+ (png format).. This works perfect but the picture is small! #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3>;used gdi+ $GUI_Width = 800 $GUI_Height = 800 $Path = @ScriptDir & "\" $Main_GUI = GUICreate("", $GUI_Width, $GUI_Height , Default , Default , $WS_POPUP , $WS_EX_LAYERED) _GDIPlus_StartUp() $hImage = _GDIPlus_ImageLoadFromFile("D:\Frame.png") $hImage2 = _GDIPlus_ImageLoadFromFile("D:\Ext_Frame.png") $hGraphic = _GDIPlus_GraphicsCreateFromHWND($Main_GUI) GUICtrlCreatePic($Path & "Vis.Gif" , 0 , 0 , $GUI_Width , $GUI_Height) ;~ GUICtrlCreatePic($Path & "Frame.gif", 0, 0, 415, 338) ;~ GUICtrlCreatePic($Path & "Ext_Frame.gif", 257, 257, 315, 257) GUIRegisterMsg($WM_PAINT, "MY_WM_PAINT") GUISetState(@SW_SHOW) While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($hImage) _GDIPlus_ShutDown() Func MY_WM_PAINT($hWnd, $Msg, $wParam, $lParam) _WinAPI_RedrawWindow($Main_GUI, 0, 0, $RDW_UPDATENOW) _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0) _GDIPlus_GraphicsDrawImage($hGraphic, $hImage2, 150, 110) _WinAPI_RedrawWindow($Main_GUI, 0, 0, $RDW_VALIDATE) Return $GUI_RUNDEFMSG EndFunc
  17. Maybe this code should help you.. #include <Misc.au3> Local $x = 0, $y = 0 GUICreate("", 140, 40) $hEdit = GUICtrlCreateInput("", 10, 10, 120, 25) GUISetState() While 1 $msg = GUIGetMsg() If _IsPressed(10) And $x = 0 Then GUICtrlSetData($hEdit, GUICtrlRead($hEdit) & "SHIFT + ") $x = 1 ElseIf _IsPressed(11) And $x = 0 Then GUICtrlSetData($hEdit, GUICtrlRead($hEdit) & "CTRL + ") $x = 1 ElseIf _IsPressed(12) And $x = 0 Then GUICtrlSetData($hEdit, GUICtrlRead($hEdit) & "ALT + ") $x = 1 EndIf If $x = 1 Then $y += 1 If $y = 100 Then $x = 0 $y = 0 EndIf EndIf If $msg = -3 Then ExitLoop WEnd
  18. InetGet - Downloads a file from the internet using the http or ftp protocol.
  19. Hmm.. I used Win7 too.. This never happen to me. Maybe you should check your syntax and tidy your script.
  20. You've made a small mistake, i found a solution.. ;testing tab glitch with bk color #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <SliderConstants.au3> #include <StaticConstants.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Glitch", 441, 286, 192, 124) $Tab1 = GUICtrlCreateTab(40, 64, 369, 193) GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT) $TabSheet1 = GUICtrlCreateTabItem("1") $Button2 = GUICtrlCreateButton("Am I covered?", 112, 128, 209, 105, $WS_GROUP) $TabSheet2 = GUICtrlCreateTabItem("2") $Slider2 = GUICtrlCreateSlider(72, 96, 265, 41) $Button1 = GUICtrlCreateButton("Pink", 144, 216, 145, 25, $WS_GROUP) $TabSheet3 = GUICtrlCreateTabItem("3") $Slider1 = GUICtrlCreateSlider(72, 152, 305, 33) $Label1 = GUICtrlCreateLabel("Slider", 128, 128, 30, 17) ;~ GUICtrlCreateTabItem("") ; <- this is the problem ;~ GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### GUICtrlSetBkColor($Slider1, 0xFFFFFF) GUICtrlSetBkColor($Slider2, 0xFFFFFF) GUICtrlSetBkColor($Button2, 0xD02875) ;~ GUISetState() GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd
  21. This example code is working if run as administrator, RunWait("net stop ""Windows Update""",@SystemDir)
  22. I've make a small changed in your code. It works as you want it (i think ).. Maybe this will help you ;Author: MatheusGM ; Função do Script: ; One-click Installer MHU + GEN B #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #RequireAdmin #NoTrayIcon #Region ### START Koda GUI section ### $Form1_1 = GUICreate("One-click Installer MHU + GEN-B", 516, 348, 192, 124) $Fundo = GUICtrlCreatePic("C:\Users\MatheusGM\Desktop\PSP.jpg", 0, 0, 513, 345, 0) $Browse = GUICtrlCreateButton("Browse", 360, 152, 105, 25, 0) $Go = GUICtrlCreateButton("Go", 128, 248, 137, 33) $Help = GUICtrlCreateButton("Help", 272, 248, 137, 33) $var1 = "MS Letter" $Input = GUICtrlCreateInput($var1, 272, 152, 81, 21) $Exit = GUICtrlCreateButton("Exit", 208, 280, 121, 33) $Browse1 = 0 GUICtrlCreateLabel("Progress:", 8, 320, 54, 17) $Progress1 = GUICtrlCreateProgress(72, 315, 161, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $msg = GUIGetMsg() Select Case $msg = $Browse $file = FileSelectFolder("Choose file...", "") ; FileSelectFolder instead of FileOpenDIalog If @error <> 1 Then GUICtrlSetData($Input, $file) GUICtrlSetData($Progress1,30) $Browse1 = 1 Else MsgBox(0, "Error!", "You didn't Select Your PSP MS!") EndIf Case $msg = $Go If GUICtrlRead($Input) <> "MS Letter" Then ; changed $var to $var1, = to <> ;~ $msg = $Browse ; no need this If $Browse1 = 1 Then $resposta = MsgBox(4, "One-click Installer MHU + GEN-B", "Do you wanna Install?") If $resposta = 6 Then Run("notepad") GUICtrlSetData(-1, 100) Sleep(3000) MsgBox(0, "One-click Installer MHU + GEN-B", "All Done! See Ya!") EndIf If $resposta = 7 Then MsgBox(0, "One-click Installer MHU + GEN-B", "Ok! See Ya!") EndIf EndIf Else ; changed MsgBox(0, "One-click Installer MHU + GEN-B", "You didn't Select Your MS!") EndIf Case $msg = $Help #Region ### START Koda GUI section ### Form=d:\listas\programas\autoit3\koda_1.7.2.0\templates\about box.kxf $dlgAbout = GUICreate("Help", 325, 238, 302, 218) $GroupBox1 = GUICtrlCreateGroup("", 8, 8, 305, 185) $Label4 = GUICtrlCreateLabel("Help:", 16, 24, 49, 28, $WS_GROUP) GUICtrlSetFont(-1, 15, 400, 0, "MS Sans Serif") $Label1 = GUICtrlCreateLabel("Just Click on Browse, Select your MS,", 16, 72, 269, 24, $WS_GROUP) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $Label2 = GUICtrlCreateLabel("Then click on Go!", 16, 96, 126, 24, $WS_GROUP) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") GUICtrlCreateGroup("", -99, -99, 1, 1) $Exit1 = GUICtrlCreateButton("Exit", 120, 208, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Sleep(3000) GUIDelete() Case $msg = $Exit ExitLoop Case $msg = -3 ExitLoop EndSelect WEnd GUIDelete() Exit
  23. Hi, madmorgan.. For your information, i have tried your code. But things changed, i already mess up the script and now its unusable.. I don't know what is wrong with your code but when i write my own code, its working! I have no idea about your script.. You can compare my code with yours, maybe you can find something.. Good luck!
  24. Hi, i have create this script based on AutoIt Help. You should try to explore and read the AutoIt help file, there are many things in it that should solve your problems.. This is just a simple script, but i added some functions such as SoundPlay and WinFlash when you received messages.. ;AutoIt Messanger by Ichigo325 #include <GUIConstantsEx.au3> #include <GuiEdit.au3> Opt('MustDeclareVars', 1) Example() Func Example() Local $szIPADDRESS = @IPAddress1 Local $nPORT = 33891 Local $MainSocket, $Gui, $edit, $ConnectedSocket, $szIP_Accepted, $ConnectedSocket2 Local $msg, $recv, $btn, $input, $input2, $nick TCPStartup() $MainSocket = TCPListen($szIPADDRESS, $nPORT) If $MainSocket = -1 Then Exit $Gui = GUICreate("AutoIt Messenger [" & $szIPADDRESS & "]", 300, 323) GUICtrlCreateLabel("Incoming messages:", 10, 5, 150, 15) $edit = _GUICtrlEdit_Create($Gui, "", 10, 20, 280, 180) GUICtrlSetFont(-1, 9, -1, -1, "Tahoma") GUICtrlCreateLabel("Nickname:", 10, 205, 100, 15) $nick = GUICtrlCreateInput("", 10, 220, 280, 22) GUICtrlCreateLabel("Text to send: ", 10, 245, 100, 15) $input = GUICtrlCreateInput("", 10, 260, 280, 22) GUICtrlSetFont(-1, 9, -1, -1, "Tahoma") GUICtrlSetState(-1, $GUI_FOCUS) $btn = GUICtrlCreateButton("Send...", 10, 290, 100, 25, 0x0001) GUICtrlCreateLabel("IP: ", 175, 295, 12, 25) $input2 = GUICtrlCreateInput("", 190, 290, 100, 25, 0x0001) GUICtrlSetData(-1, $szIPADDRESS) GUICtrlSetFont(-1, 9, -1, -1, "Tahoma") GUISetState() $ConnectedSocket = -1 While 1 $msg = GUIGetMsg() $ConnectedSocket = TCPAccept($MainSocket) If $msg = $GUI_EVENT_CLOSE Then ExitLoop $recv = TCPRecv($ConnectedSocket, 2048) If $recv <> "" Then If _GUICtrlEdit_GetText ($edit) <> "" Then _GUICtrlEdit_SetText($edit, _GUICtrlEdit_GetText($edit) & @CRLF & $recv) Else _GUICtrlEdit_SetText($edit, _GUICtrlEdit_GetText($edit) & $recv) EndIf If Not WinActive($Gui) Then WinFlash($Gui) SoundPlay(@WindowsDir & "\Media\Ding.wav") _GUICtrlEdit_LineScroll ($edit,_GUICtrlEdit_GetLineCount ($edit)+1,_GUICtrlEdit_GetLineCount ($edit)+1) EndIf If $msg = $btn Then If GUICtrlRead($nick) = "" Or GUICtrlRead($input) = "" Then MsgBox(48, "Error", "Please type something in ""Nickname"" and ""Text to send""!") ContinueLoop EndIf $szIPADDRESS = GUICtrlRead($input2) If StringRegExp($szIPADDRESS, "\d.\d.\d.\d") Then $ConnectedSocket2 = TCPConnect($szIPADDRESS, $nPORT) If $ConnectedSocket2 <> -1 Then TCPSend($ConnectedSocket2, GUICtrlRead($nick) & ": " & GUICtrlRead($input)) If _GUICtrlEdit_GetText ($edit) <> "" Then _GUICtrlEdit_SetText($edit, _GUICtrlEdit_GetText($edit) & @CRLF & GUICtrlRead($nick) & ": " & GUICtrlRead($input)) Else _GUICtrlEdit_SetText($edit, _GUICtrlEdit_GetText($edit) & GUICtrlRead($nick) & ": " & GUICtrlRead($input)) EndIf GUICtrlSetData($input, "") _GUICtrlEdit_LineScroll ($edit,_GUICtrlEdit_GetLineCount ($edit)+1,_GUICtrlEdit_GetLineCount ($edit)+1) GUICtrlSetState($input, $GUI_FOCUS) Else MsgBox(0, "Error!", "Couldn't connect " & $szIPADDRESS & "!" & @CRLF & "Make sure IP is exist!") GUICtrlSetState($input2, $GUI_FOCUS) EndIf EndIf EndIf WEnd If $ConnectedSocket <> -1 Then TCPCloseSocket($ConnectedSocket) TCPShutdown() Exit EndFunc ;==>Example Tested, works with Windows 7 and XP.. Hope this script help you..
×
×
  • Create New...