Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/09/2013 in all areas

  1. Wombat

    SciTE Resource Manager

    First of all, I would like to thank those who helped me immensely on this script: guinness Edano and as well thank those who's script's I barrowed from: Melba23 guinness BrewManNH (if i missed anyone I apologize) I have learned a great deal in a short amount of time, and I certainly couldn't have without the aid of the members of this forum. I've rarely came upon a forum that had such a great community as this, they truly are gems hidden away in the land of internwebs. I made this (with the help of others, which without it this would be a crap script) to aid me in my work, and I hope it helps you with yours as well. If not then at least it's here to serve as an example for others. ResourceManager.au3 CODE: Installation: Description: This tool is used to create a yourscriptname_res.txt file that is associated with your script. This file contains the file paths of all the resources you plan to use in your script for easy access and insertion. Usage Instructions: Tips & Pointers: Changes I Want to Include in An Update: Update: ResourceManager_v2 (a seperate version, see below) Here's an alternate version that runs from a "Resources" file: CODE: You must create a folder named "ResourceManager_v2" in your "Autoit3" folder, also it assumes that the "Autoit3" folder is in your "Program FIles" folder. If it isn't then for now you'll need to change the $ResFileDir variable and all it's occurences to match, UNTIL I update it to find your "Autoit3" folder wherever it is... likely easy peasy but I'm tired and need sleep. This version gives the user the ability to set their own resource file as well in the settings dialogue... ENJOY! Thank you all, Wombat
    1 point
  2. You all know that AutoIt now links to the current PCRE16 v8.33 library (no more UTF8 jig) and includes UCP (Unicode Character Properties) support. This has significant impact over a number of metacharacters and features. The documentation of StringRegExp needs to reflect these changes. In my way I also found a number of errors or vague phrasing which can mislead beginners. Please review the revised doc file and post your comments pointing out my own typos, thinkos, errors and omissions. Old doc file from 3.3.9.15 beta Proposed new doc file Summary of changes PCRE v8.33 pattern reference document
    1 point
  3. You need to register WM_COPYDATA when requesting info from SciTE and need to register the Window handle for receiving general messages like when Files are opened or closed. Jos
    1 point
  4. Gianni

    Comparing variables

    Edano, you're smart, however, not to be anal , but I was just curious as to a solution found by AutID On His code on post >#9, ....but never mind.
    1 point
  5. Thanks Edano, I believe I miscommunicated what I was trying to achieve. I want the child gui to drag the parent so that it appears as one consistent gui when its really two... I'll take your code and suggestions and head back to the workshop Edit: I actually think the solution would be to condense the code into one gui and not use two....
    1 point
  6. I am feeling nice today, so here ya go: #include <ComboConstants.au3> #include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) Local $statesDDLB = IniRead("test.ini", "DDLBValues", "statesDDLB", "") Global $frmForm = GUICreate("Form", 150, 50, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "frmClose") Global $cboPropertyState = GUICtrlCreateCombo("", 10, 10, 97, 25, BitOR($GUI_SS_DEFAULT_COMBO,$CBS_SIMPLE)) GUICtrlSetData($cboPropertyState, $statesDDLB, "PA") GUICtrlSetOnEvent($cboPropertyState, "cboPropertyStateChange") GUISetState(@SW_SHOW) while 1 sleep(200) WEnd Func cboPropertyStateChange() MsgBox(0, "", "You have selected " & GUICtrlRead($cboPropertyState)) EndFunc ;==>cboPropertyStateChange Func frmClose() GUIDelete($frmForm) Exit EndFunc ;==>frmClose
    1 point
  7. Post your script so i can see what you have so far
    1 point
  8. When you compile the script using the obfuscator directives, the compiled script inside your exe is obfuscated, there's no separate exe created called scriptname_obfuscate.exe.
    1 point
  9. hi wombat now i am beginning to get confused. what do you want to achieve ? your last question was to enable the control gui again, and i did it. now you want the control gui to move ? then you have to apply the ex_parentdrag style to the control gui and all controls that are supposed to drag it (that's what i said above). like this: . ;http://www.autoitscript.com/forum/topic/153261-who-wants-to-help-me-learn-enhanced-gui-building/page-3 ;Post #47 ;D:\DOKUME~1\ADMINI~1\LOKALE~1\Temp\SLICER\Avatar\photo-thumb-79839.png ;by Wombat ;Script grabbed by SLICER by Edano here: http://www.autoitscript.com/forum/topic/152402-slicer-autoit-forum-script-grabber/?p=1093575 #region ; Includes #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GDIPlus.au3> #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> #include <StaticConstants.au3> #include <Constants.au3> #include <Array.au3> #endregion ; Includes Opt("GUIOnEventMode", 1) #region;;;;;;GUI Section;;;;;;; Global $sFile = "ciik.png";C:\prog_res\Lab\test_res\ Global Const $AC_SRC_ALPHA = 1 Global $iWidth, $iHeight, $hRegion Global $___hNew_WndProc, $___pNew_WndProc, $___pOld_WndProc _GDIPlus_Startup() $s_Bitmap = $sFile $hLayeredGUI = _GUICreate_Alpha("End-Hancer", $s_Bitmap, $iWidth, $iHeight) GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") GUISetState() ;show the main gui ;when the background color and the transcolor are the same of a layered GUI we receive transparent background ;this would create an invisible window $hControls_GUI = GUICreate("ControlGUI", $iWidth, $iHeight, 0, 0, $WS_POPUP, BitOR($WS_EX_MDICHILD, $WS_EX_LAYERED,$GUI_WS_EX_PARENTDRAG), $hLayeredGUI) GUISetBkColor(0xABCDEF) _WinAPI_SetLayeredWindowAttributes($hControls_GUI, 0xABCDEF, 230) ;set transparency to 230 ;the close button you can use icon also $iCloseButton = GUICtrlCreateLabel("X", 175, 260, 10, 10,-1,$GUI_WS_EX_PARENTDRAG) GUICtrlSetCursor(-1, 0) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetOnEvent(-1, "CloseGUI") ;now lets create the so required controls to sync the user interaction $iProgressBar = GUICtrlCreateProgress(200, 450, 360, 15,-1,$GUI_WS_EX_PARENTDRAG) GUICtrlSetState(-1, $GUI_HIDE) GUICtrlSetData(-1, 100) ;set the initial position of the progress to 20 #Region ; Menu Global $iCheckUpdates = GUICtrlCreateLabel("Check For Updates", 250, 350, 140, 18, BitOR($SS_SUNKEN,$WS_BORDER),$GUI_WS_EX_PARENTDRAG) GUICtrlSetFont(-1, 10, 1000, 4, "MS Sans Serif") GUICtrlSetCursor(-1, 0) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetOnEvent(-1, "UpdateVersion") Global $iGraphicsConfig = GUICtrlCreateLabel("Graphics Config", 425, 350, 115, 18, BitOR($SS_SUNKEN,$WS_BORDER),$GUI_WS_EX_PARENTDRAG) GUICtrlSetFont(-1, 10, 1000, 4, "MS Sans Serif") GUICtrlSetCursor(-1, 0) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetOnEvent(-1, "Opti_Options") Global $iMLConfig = GUICtrlCreateLabel("Launcher Config", 575, 350, 160, 18, BitOR($SS_SUNKEN,$WS_BORDER),$GUI_WS_EX_PARENTDRAG) GUICtrlSetFont(-1, 10, 1000, 4, "MS Sans Serif") GUICtrlSetCursor(-1, 0) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetOnEvent(-1, "LauncherOptions") #endregion ; Menu $iDataBox = GUICtrlCreateGroup("", 250, 450, 300, 200) ;;;;;;;;; GUISetState() ;show the controls window ;;;;;;;;; Local $iMsg, $aInfo, $f_ClkThrough = False While 1 $aInfo = GUIGetCursorInfo($hControls_GUI) If @error Then ContinueLoop ;enable clickthrough for the invisible control gui If $aInfo[4] = 0 And $f_ClkThrough = False Then _WinSetClickThrough($hControls_GUI) $f_ClkThrough = True ElseIf $aInfo[4] And $f_ClkThrough Then _WinSetClickThrough($hControls_GUI, False) $f_ClkThrough = False EndIf WEnd #region ;Version check and update Func UpdateVersion() GUICtrlSetBkColor($iCheckUpdates,0x6E6E6E) GUICtrlSetBkColor($iMLConfig,0xABCDEF) GUICtrlSetBkColor($iGraphicsConfig,0xABCDEF) EndFunc ;==>UpdateVersion #endregion ;Version check and update #region ;About and help Func AboutInfo() EndFunc ;==>AboutInfo Func HelpInfo() EndFunc ;==>HelpInfo #endregion ;About and help #region ;Options section Func LauncherOptions() GUICtrlSetBkColor($iMLConfig,0x6E6E6E) GUICtrlSetBkColor($iCheckUpdates,0xABCDEF) GUICtrlSetBkColor($iGraphicsConfig,0xABCDEF) EndFunc Func Opti_Options() GUICtrlSetBkColor($iGraphicsConfig,0x6E6E6E) GUICtrlSetBkColor($iMLConfig,0xABCDEF) GUICtrlSetBkColor($iCheckUpdates,0xABCDEF) EndFunc #endregion Func CloseGUI() GUIDelete("End-Hancer") Exit EndFunc Func WM_NCHITTEST($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam Return $HTCAPTION EndFunc ;==>WM_NCHITTEST Func _WinSetClickThrough($hWin, $iCLickThrough = True) Local $iExStyle = GUIGetStyle($hWin) $iExStyle = $iExStyle[1] If $iCLickThrough Then $iExStyle = BitOR($iExStyle, BitOR($GUI_WS_EX_PARENTDRAG, $WS_EX_TRANSPARENT)) Else $iExStyle = BitXOR($iExStyle, BitOR($GUI_WS_EX_PARENTDRAG, $WS_EX_TRANSPARENT)) EndIf Return GUISetStyle(Default, $iExStyle) EndFunc ;==>_WinSetClickThrough ;I have not created the following functions.. Func _GUICreate_Alpha($sTitle, $sPath, ByRef $iWidth, ByRef $iHeight, $iX = -1, $iY = -1, $iOpacity = 255) Local $hGUI, $hImage, $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hImage = _GDIPlus_ImageLoadFromFile($sPath) $iWidth = _GDIPlus_ImageGetWidth($hImage) $iHeight = _GDIPlus_ImageGetHeight($hImage) $hGUI = GUICreate($sTitle, $iWidth, $iHeight, $iX, $iY, $WS_POPUP, $WS_EX_LAYERED) SetBitmap($hGUI, $hImage, $iOpacity) _GDIPlus_ImageDispose($hImage) Return $hGUI EndFunc ;==>_GUICreate_Alpha Func SetBitmap($hGUI, $hImage, $iOpacity) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage)) DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage)) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>SetBitmap #endregion;;;;;;GUI Section;;;;;;; . but now you want the controls to move the parent gui ? ok, then i ask for your entire concept, because: why don't you put everything in one gui ? there are more possibilities to move two windows synchronously. you could for example register the gui message "WM_MOVE". or you could add some code to the _Drag() function i gave you: . Func _Drag() DllCall("user32.dll","int","SendMessage","hwnd",@GUI_WinHandle,"int",274,"int",0xF012,"int",0) ;====> if @gui_winhandle=controlgui then move parent gui (winmove) or similar EndFunc . or there is _WinApi_SetParent(). and much more. this is all up to you, but it depends on the concept. you should play around a bit with all the tools i gave you and think about the entire concept, so you don't reach a point where you get stuck. sometimes it's good to step back and simplify things instead of making it even more complicated (ockham's razor). basically, you can do (nearly) everything with AutoIt in one or the other way. cheers E.
    1 point
  10. If there is anything special to any of values returned then it would have been docomented, just as -1 is. BrewManNH, not guinness. Go get some sleep or do whatever you do when you start not making sense.
    1 point
  11. BrewManNH

    AutoIt Vs C++

    This thread is over 2 years old, did you really think it was helpful posting that here?
    1 point
  12. It's an internal AutoIt handle, not a Windows handle. Look at what you get from WinGetHandle to see what a real handle looks like.
    1 point
  13. Edano

    SciTE Resource Manager

    wombat take a look at your other script i fixed it
    1 point
  14. this is your script again with ex-parentdrag #region ; Includes #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GDIPlus.au3> #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> #include <StaticConstants.au3> #include <Constants.au3> #include <Array.au3> #endregion ; Includes Opt("GUIOnEventMode", 1) #region;;;;;;GUI Section;;;;;;; Global $sFile = "C:\prog_res\Lab\test_res\ciik.png" Global Const $AC_SRC_ALPHA = 1 Global $iWidth, $iHeight, $hRegion Global $___hNew_WndProc, $___pNew_WndProc, $___pOld_WndProc _GDIPlus_Startup() $s_Bitmap = $sFile $hLayeredGUI = _GUICreate_Alpha("End-Hancer", $s_Bitmap, $iWidth, $iHeight) GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") GUISetState() ;show the main gui ;when the background color and the transcolor are the same of a layered GUI we receive transparent background ;this would create an invisible window $hControls_GUI = GUICreate("ControlGUI", $iWidth, $iHeight, 0, 0, $WS_POPUP, BitOR($WS_EX_MDICHILD, $WS_EX_LAYERED), $hLayeredGUI) GUISetBkColor(0xABCDEF) _WinAPI_SetLayeredWindowAttributes($hControls_GUI, 0xABCDEF, 230) ;set transparency to 230 ;the close button you can use icon also $iCloseButton = GUICtrlCreateLabel("X", 175, 260, 10, 10) GUICtrlSetCursor(-1, 0) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetOnEvent(-1, "CloseGUI") ;now lets create the so required controls to sync the user interaction $iProgressBar = GUICtrlCreateProgress(200, 450, 360, 15) GUICtrlSetState(-1, $GUI_HIDE) GUICtrlSetData(-1, 100) ;set the initial position of the progress to 20 #Region ; Menu Global $iCheckUpdates = GUICtrlCreateLabel("Check For Updates", 250, 350, 140, 18, BitOR($SS_SUNKEN,$WS_BORDER)) GUICtrlSetFont(-1, 10, 1000, 4, "MS Sans Serif") GUICtrlSetCursor(-1, 0) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetOnEvent(-1, "UpdateVersion") Global $iGraphicsConfig = GUICtrlCreateLabel("Graphics Config", 425, 350, 115, 18, BitOR($SS_SUNKEN,$WS_BORDER)) GUICtrlSetFont(-1, 10, 1000, 4, "MS Sans Serif") GUICtrlSetCursor(-1, 0) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetOnEvent(-1, "Opti_Options") Global $iMLConfig = GUICtrlCreateLabel("Launcher Config", 575, 350, 160, 18, BitOR($SS_SUNKEN,$WS_BORDER)) GUICtrlSetFont(-1, 10, 1000, 4, "MS Sans Serif") GUICtrlSetCursor(-1, 0) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetOnEvent(-1, "LauncherOptions") #endregion ; Menu $iDataBox = GUICtrlCreateGroup("", 250, 450, 300, 200) ;;;;;;;;; GUISetState() ;show the controls window ;;;;;;;;; Local $iMsg, $aInfo, $f_ClkThrough = False While 1 $aInfo = GUIGetCursorInfo($hControls_GUI) If @error Then ContinueLoop ;enable clickthrough for the invisible control gui If $aInfo[4] = 0 And $f_ClkThrough = False Then _WinSetClickThrough($hControls_GUI) $f_ClkThrough = True ElseIf $aInfo[4] And $f_ClkThrough Then _WinSetClickThrough($hControls_GUI, False) $f_ClkThrough = False EndIf WEnd #region ;Version check and update Func UpdateVersion() GUICtrlSetBkColor($iCheckUpdates,0x6E6E6E) GUICtrlSetBkColor($iMLConfig,0xABCDEF) GUICtrlSetBkColor($iGraphicsConfig,0xABCDEF) EndFunc ;==>UpdateVersion #endregion ;Version check and update #region ;About and help Func AboutInfo() EndFunc ;==>AboutInfo Func HelpInfo() EndFunc ;==>HelpInfo #endregion ;About and help #region ;Options section Func LauncherOptions() GUICtrlSetBkColor($iMLConfig,0x6E6E6E) GUICtrlSetBkColor($iCheckUpdates,0xABCDEF) GUICtrlSetBkColor($iGraphicsConfig,0xABCDEF) EndFunc Func Opti_Options() GUICtrlSetBkColor($iGraphicsConfig,0x6E6E6E) GUICtrlSetBkColor($iMLConfig,0xABCDEF) GUICtrlSetBkColor($iCheckUpdates,0xABCDEF) EndFunc #endregion Func CloseGUI() GUIDelete("End-Hancer") Exit EndFunc Func WM_NCHITTEST($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam Return $HTCAPTION EndFunc ;==>WM_NCHITTEST Func _WinSetClickThrough($hWin, $iCLickThrough = True) Local $iExStyle = GUIGetStyle($hWin) $iExStyle = $iExStyle[1] If $iCLickThrough Then $iExStyle = BitOR($iExStyle, BitOR($GUI_WS_EX_PARENTDRAG, $WS_EX_TRANSPARENT)) Else $iExStyle = BitXOR($iExStyle, BitOR($GUI_WS_EX_PARENTDRAG, $WS_EX_TRANSPARENT)) EndIf Return GUISetStyle(Default, $iExStyle) EndFunc ;==>_WinSetClickThrough ;I have not created the following functions.. Func _GUICreate_Alpha($sTitle, $sPath, ByRef $iWidth, ByRef $iHeight, $iX = -1, $iY = -1, $iOpacity = 255) Local $hGUI, $hImage, $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hImage = _GDIPlus_ImageLoadFromFile($sPath) $iWidth = _GDIPlus_ImageGetWidth($hImage) $iHeight = _GDIPlus_ImageGetHeight($hImage) $hGUI = GUICreate($sTitle, $iWidth, $iHeight, $iX, $iY, $WS_POPUP, $WS_EX_LAYERED) SetBitmap($hGUI, $hImage, $iOpacity) _GDIPlus_ImageDispose($hImage) Return $hGUI EndFunc ;==>_GUICreate_Alpha Func SetBitmap($hGUI, $hImage, $iOpacity) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage)) DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage)) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>SetBitmap #endregion;;;;;;GUI Section;;;;;;; you simply forgot the "X" in BitXOr (probably you copied and pasted the line) the script above this script is with guisetonevent drag, both work fine now. E
    1 point
  15. firejack527, Something like this is what I was suggesting: $sBaseFileBase = "FileLog" $iCounter = 0 While 1 ; Increase the counter by 1 $iCounter += 1 ; Create the new filename $sCurrentFileLog = $sBaseFileBase & $iCounter & ".txt" ; Just to show the result MsgBox(0, "This pass", "Counter: " & $iCounter & @CRLF & "This file: " & $sCurrentFileLog) ; And to stop before we get too bored! If $iCounter = 5 Then ExitLoop WEnd All clear? M23
    1 point
  16. Melba23

    Keyloggers

    The Forum Rules specifically mention that "keyloggers" are a prohibited subject on this forum. Of late we have had several threads locked because they have strayed (usually unwittingly) into keylogger territory. Here is a reminder of what Jon (the site owner) has set out as the basis for acceptability: "how to check for a few keys being pressed is one thing" We are not going to define "a few" in absolute terms, but if you post any code which checks for the best part of the keyboard you can be absolutely sure that you are in breach of the rules, that your thread will be locked, and that sanctions may follow. So please do not post such scripts - we do not want to be heavy-handed, but after this announcement your excuses had better be very good ones! M23
    1 point
  17. This is better. Compile it and launch the EXE twice. #Include <GUIConstantsEx.au3> Opt('WinTitleMatchMode', 3) global const $TITLE_SENDER = '#Sender' global const $TITLE_RECEIVER = '#Reseiver' global const $WM_COPYDATA = 0x004A global $sMsg, $Dummy, $Flag = 0 if WinExists($TITLE_RECEIVER) then if WinExists($TITLE_SENDER) then exit endif _Sender() else _Receiver() endif func _Sender() local $Input, $Button, $ID GUICreate($TITLE_SENDER, 400, 100) $Input = GUICtrlCreateinput('', 20, 20, 360, 20) $Button = GUICtrlCreateButton('Send', 165, 60, 70, 23) $Dummy = GUICtrlCreateDummy() GUIRegisterMsg($WM_COPYDATA, '_WM_COPYDATA') GUISetState() while 1 $ID = GUIGetMsg() switch $ID case 0 continueloop case $GUI_EVENT_CLOSE _SendData(WinGetHandle($TITLE_RECEIVER), '@exit') exitloop case $Button $sMsg = GUICtrlRead($Input) $hWnd = WinGetHandle($TITLE_RECEIVER) if (not @error) and ($sMsg > '') then if _SendData($hWnd, $sMsg) then GUICtrlSetState($Button, $GUI_DISABLE) endif endif case $Dummy GUICtrlSetState($Button, $GUI_ENABLE) endswitch wend GUIDelete() endfunc func _Receiver() GUICreate($TITLE_RECEIVER) GUIRegisterMsg($WM_COPYDATA, '_WM_COPYDATA') while 1 Sleep(10) if $Flag then if $sMsg = '@exit' then exitloop endif $Flag = 0 _DoSomething($sMsg) _SendData(WinGetHandle($TITLE_SENDER), '') endif wend GUIDelete() endfunc; _Receiver func _DoSomething($sData) MsgBox(0, 'Message', $sData) endfunc; _DoSomething func _SendData($hWnd, $sData) local $tCOPYDATA, $tMsg $tMsg = DllStructCreate('char[' & StringLen($sData) + 1 & ']') DllStructSetData($tMsg, 1, $sData) $tCOPYDATA = DllStructCreate('dword;dword;ptr') DllStructSetData($tCOPYDATA, 2, StringLen($sData) + 1) DllStructSetData($tCOPYDATA, 3, DllStructGetPtr($tMsg)) $Ret = DllCall('user32.dll', 'lparam', 'SendMessage', 'hwnd', $hWnd, 'int', $WM_COPYDATA, 'wparam', 0, 'lparam', DllStructGetPtr($tCOPYDATA)) if (@error) or ($Ret[0] = -1) then return 0 endif return 1 endfunc; _SendData func _WM_COPYDATA($hWnd, $msgID, $wParam, $lParam) local $tCOPYDATA = DllStructCreate('dword;dword;ptr', $lParam) local $tMsg = DllStructCreate('char[' & DllStructGetData($tCOPYDATA, 2) & ']', DllStructGetData($tCOPYDATA, 3)) $sMsg = DllStructGetData($tMsg, 1) ; For Sender GUICtrlSendToDummy($Dummy) ; For Receiver $Flag = 1 return 0 endfunc; _WM_COPYDATA
    1 point
×
×
  • Create New...