Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/31/2016 in all areas

  1. @AutoBert in the future, how about offering suggestions without the constant RTFM vibe? Believe it or not, we're actually trying to welcome and encourage new folks to the forum
    2 points
  2. AutoBert, You have already been told once today about the manner in which you are replying - this is the second and final warning you get to change your ways. If your RTFM emoticon appears again - or if you express a similar unwelcoming attitude in future - your future in this community will be in serious jeopardy. M23
    1 point
  3. ;$txt = "3" &@crlf& "1" &@crlf& "2" &@crlf& "3" &@crlf& "4" &@crlf& "41" &@crlf& "42" &@crlf& "5" &@crlf& "6" &@crlf& "42" ;Msgbox(0,"", $txt) $txt = FileRead("test.txt") $ret = StringRegExpReplace($txt, '(?s)(\b\d+\b)(?!.*\b\1\b)\R?', "") Msgbox(0,"", "duplicates :" & @crlf & $ret )
    1 point
  4. dcop

    Get Real Time Stock Quotes

    If FileExists("C:\Temp\") Then Real() Else DirCreate("C:\Temp\") Real() EndIf Func Real() InetGet ( "http://finance.yahoo.com/q/ecn?s=orcl", "c:\temp\quote.txt", 1) $fil = FileRead("C:\Temp\quote.txt", 100000) $sear = StringInStr ( $fil, "last trade") $par = StringMid ( $fil, $sear, 60) $par2 = StringMid($par, 48, 5) MsgBox(0, "", $par2) FileDelete ( "C:\Temp\quote.txt" ) EndFunc Exit This goes to Yahoo Finance real time quotes and returns the current quote. You could make one for each stock you watch or variable the stock symbol into an input box. This one does Oracle's Price
    1 point
  5. If there is only one "nonneededword" the only change to do in your code from post #1 is this Local $string2 = StringRegExpReplace($read, "(?im)^nonneededword.*\R?", "") If there are several the regex can be adapted very easily using an alternation as showed in the previous codes
    1 point
  6. Solved! The problem was a missing parameter in DllStructSetData of $tNOTIFYICONDATA, "CallbackMessage". After added that you don't need all that stuff of DllCallbackRegister, _WinAPI_SetWindowLong and so on but just a function for intercept the message. Thanks anyway
    1 point
  7. This example deletes all the lines that do not start with any of the words in $sNeededWords. Local $sText = 'Keep never compromize principles.' & @CRLF & _ 'And delete this line if "and" is not needed word.' & @CRLF & _ 'Keep this' & @CRLF & _ 'not keep this line' & @CRLF & _ 'nor this line' & @CRLF & _ 'keep' & @CRLF & _ 'keeper not keep, so delete this line.'; & @CRLF Local $sNeededWords = 'keep|and' ; When more than one needed word, separate the words with "|". $aMatch = StringRegExpReplace($sText, "(?im)^(?!(" & $sNeededWords & ")\b).*\R?", "") ; Delete the lines that do not start with $sNeededWords - "keep" and "and". MsgBox(0, '"keep" & "and"', $aMatch)
    1 point
  8. Maybe if you modify this line: $sDisplayTime = StringFormat('%02d:%02d:%02d.%01d', $iHour, $iMin, $iSec, $iMilli/100)
    1 point
  9. Something like this? Global $sDisplayTime = "" Global $iTimer = TimerInit() AdlibRegister("Sec2Time", 100) While 1 Sleep(50) ToolTip($sDisplayTime, 0, 0) WEnd Func Sec2Time() Local $iCounter = TimerDiff($iTimer) ; Milliseconds since start of script Local $iTempSec = $iCounter / 1000 ; Seconds since start of script $iHour = Int($iTempSec / 3600) $iMin = Int(($iTempSec - $iHour * 3600) / 60) $iSec = Int($iTempSec - $iHour * 3600 - $iMin * 60) $iMilli = Mod($iCounter, 1000) $sDisplayTime = StringFormat('%02d:%02d:%02d.%03d', $iHour, $iMin, $iSec, $iMilli) EndFunc ;==>Sec2Time
    1 point
  10. Or create a small event handler that is easy to expand. See I use exactly the same amount of global variables, but now I have 2 edit controls. If I expand to 3 or 4 or even 99, the global variable amount will be the same, which is one, as the rest are constants and for readability only. #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> ; A clean example taken partially from the help file ; Enumeration for the custom event handler array Global Enum $EVENT_CONTROL_ID, $EVENT_CODE, $EVENT_MAX ; Enumeration for the accessing specific global elements in the global API. See => https://www.autoitscript.com/forum/topic/173803-oop-like-approach-in-autoit/ Global Enum $API_HANDLER, $API_MAX ; Global API for caching global variables and uses a single global variable Global $g_aAPI[$API_MAX] ; Note: Use PreExpand by guinness to remove constants and enumeration values, if "Globals" are not your thing in production code Example() Func Example() Local $hGUI = GUICreate('', 290, 400) Local $iEditOne = GUICtrlCreateEdit('Example text one', 5, 5, 280, 200) Local $iEditTwo = GUICtrlCreateEdit('Example text two', 5, 205, 280, 200) Local $sEditContentsOne = GUICtrlRead($iEditOne) ; This is intentional! Local $sEditContentsTwo = GUICtrlRead($iEditOne) RegisterHandler() GUIRegisterMsg($WM_COMMAND, WM_COMMAND) GUISetState(@SW_SHOW, $hGUI) Local $aEvent = Null, _ $iMsg = 0 While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ExitLoop Case Else ; Check if an event occurred within the GUI If $iMsg > 0 Then ; Read the event handler message to get the control id and code $aEvent = ReadHandler($iMsg) Switch $aEvent[$EVENT_CONTROL_ID] Case $iEditOne Switch $aEvent[$EVENT_CODE] ; Sent when the user has taken an action that may have altered text in an edit control Case $EN_CHANGE GUICtrlSetData($iEditOne, $sEditContentsOne) EndSwitch Case $iEditTwo Switch $aEvent[$EVENT_CODE] ; Sent when the user has taken an action that may have altered text in an edit control Case $EN_CHANGE GUICtrlSetData($iEditTwo, $sEditContentsTwo) EndSwitch EndSwitch EndIf EndSwitch WEnd ; Tidy GUI resources GUIDelete($hGUI) EndFunc ;==>Example ; Private API ; Get the registered event handler Func GetHandler() Return $g_aAPI[$API_HANDLER] EndFunc ;==>GetHandler ; Read the event handler message, that was passed to the dummy control i.e. custom event handler Func ReadHandler($iMsg) Local $iLong = GUICtrlRead($iMsg) Local $aMsg[$EVENT_MAX] $aMsg[$EVENT_CONTROL_ID] = _WinAPI_LoWord($iLong) $aMsg[$EVENT_CODE] = _WinAPI_HiWord($iLong) Return $aMsg EndFunc ;==>ReadHandler ; Register an event handler Func RegisterHandler() Local $iHandler = GUICtrlCreateDummy() $g_aAPI[$API_HANDLER] = $iHandler Return $iHandler EndFunc ;==>RegisterHandler ; Handlers Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg Local $iCode = _WinAPI_HiWord($wParam) Local $iControl = _WinAPI_GetDlgCtrlID($lParam) ; Generate a long value with the control id and code Local $iMakeLong = _WinAPI_MakeLong($iControl, $iCode) ; Pass to the custom handler by sending a message to the event handler GUICtrlSendToDummy(GetHandler(), $iMakeLong) EndFunc ;==>WM_COMMAND
    1 point
  11. With an API-like interface #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> ; A clean example taken partially from the help file ; Enumeration for the accessing specific global elements in the global API. See => https://www.autoitscript.com/forum/topic/173803-oop-like-approach-in-autoit/ Global Enum $API_EDIT_HANDLE, $API_EDIT_CONTENTS, $API_MAX ; Global API for caching global variables and uses a single global variable Global $g_aAPI[$API_MAX] Example() Func Example() Local $hGUI = GUICreate('', 290, 140) Local $iEdit = GUICtrlCreateEdit('Example text', 8, 8, 273, 121) SetEdit(GUICtrlGetHandle($iEdit)) SetEditContents(GUICtrlRead($iEdit)) GUIRegisterMsg($WM_COMMAND, WM_COMMAND) GUISetState(@SW_SHOW, $hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; Tidy GUI resources GUIDelete($hGUI) EndFunc ;==>Example ; Private API Func GetEdit() Return $g_aAPI[$API_EDIT_HANDLE] EndFunc ;==>GetEdit Func GetEditContents() Return $g_aAPI[$API_EDIT_CONTENTS] EndFunc ;==>GetEditContents Func SetEdit($hEdit) $g_aAPI[$API_EDIT_HANDLE] = $hEdit EndFunc ;==>SetEdit Func SetEditContents($sData) $g_aAPI[$API_EDIT_CONTENTS] = $sData EndFunc ;==>SetEditContents ; Handlers Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg Local $iCode = _WinAPI_HiWord($wParam) Local $hEdit = GetEdit() Switch $lParam Case $hEdit Switch $iCode ; Sent when the user has taken an action that may have altered text in an edit control Case $EN_CHANGE GUICtrlSetData(_WinAPI_GetDlgCtrlID($hEdit), GetEditContents()) EndSwitch EndSwitch EndFunc ;==>WM_COMMAND
    1 point
  12. How?? Help file maybe? Also the code is a terrible example to write GUI code, where is GUIDelete()? #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> ; A clean example taken partially from the help file ; Global cache the edit control handle Global $g_hEdit = 0 Global $g_sPreviousContents = '' Example() Func Example() Local $hGUI = GUICreate('', 290, 140) Local $iEdit = GUICtrlCreateEdit('Example text', 8, 8, 273, 121) $g_hEdit = GUICtrlGetHandle($iEdit) $g_sPreviousContents = GUICtrlRead($iEdit) GUIRegisterMsg($WM_COMMAND, WM_COMMAND) GUISetState(@SW_SHOW, $hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; Tidy GUI resources GUIDelete($hGUI) EndFunc ;==>Example Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg Local $iCode = _WinAPI_HiWord($wParam) Switch $lParam Case $g_hEdit Switch $iCode ; Sent when the user has taken an action that may have altered text in an edit control Case $EN_CHANGE GUICtrlSetData(_WinAPI_GetDlgCtrlID($g_hEdit), $g_sPreviousContents) EndSwitch EndSwitch EndFunc ;==>WM_COMMAND
    1 point
  13. A little sneak peek of the next update: (Especially for friends of dark GUIĀ“s) What do you say about the look? (The "classic" white skin will, of course, continue to be available)
    1 point
×
×
  • Create New...