Leaderboard
Popular Content
Showing content with the highest reputation on 06/06/2014 in all areas
-
I found different solutions to do it and I finally decided to merge them in a single "optimal" code. During the typing it checks each new word (from the previous whitespace to the current pointer) and proposes to complete it with words included in a array. Predicted words are shown in a list under the input field and can be selected with mouse or with up/down/enter keys. These are the sources considered to create this code: '?do=embed' frameborder='0' data-embedContent>> '?do=embed' frameborder='0' data-embedContent>> '?do=embed' frameborder='0' data-embedContent>> '?do=embed' frameborder='0' data-embedContent>> '?do=embed' frameborder='0' data-embedContent>> '?do=embed' frameborder='0' data-embedContent>> And this is the code: #include <GUIConstantsEx.au3> #include <WinAPI.au3> #Include <GuiListBox.au3> #include <WindowsConstants.au3> Global $asKeyWords[21] = [20, "fight", "first", "fly", "third", "fire", "wall", "hi", "hello", "world", "window", _ "window 1", "window 2", "window 3", "window 4", "window 5", "window 6", "window 7", "window 8", "window 9", "window 10"] _Main() Func _Main() Local $hGUI, $hList, $hInput, $aSelected, $sChosen, $hUP, $hDOWN, $hENTER, $hESC Local $sCurrInput = "", $aCurrSelected[2] = [-1, -1], $iCurrIndex = -1, $hListGUI = -1 $hGUI = GUICreate("AutoComplete Input Text", 300, 100) GUICtrlCreateLabel('Start to type words like "window" or "fire" to test it:', 10, 10, 280, 20) $hInput = GUICtrlCreateInput("", 10, 40, 280, 20) GUISetState(@SW_SHOW, $hGUI) $hUP = GUICtrlCreateDummy() $hDOWN = GUICtrlCreateDummy() $hENTER = GUICtrlCreateDummy() $hESC = GUICtrlCreateDummy() Dim $AccelKeys[4][2] = [["{UP}", $hUP], ["{DOWN}", $hDOWN], ["{ENTER}", $hENTER], ["{ESC}", $hESC]] GUISetAccelerators($AccelKeys) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $hESC If $hListGUI <> -1 Then ; List is visible. GUIDelete($hListGUI) $hListGUI = -1 Else ExitLoop EndIf Case $hUP If $hListGUI <> -1 Then ; List is visible. $iCurrIndex -= 1 If $iCurrIndex < 0 Then $iCurrIndex = 0 EndIf _GUICtrlListBox_SetCurSel($hList, $iCurrIndex) EndIf Case $hDOWN If $hListGUI <> -1 Then ; List is visible. $iCurrIndex += 1 If $iCurrIndex > _GUICtrlListBox_GetCount($hList) - 1 Then $iCurrIndex = _GUICtrlListBox_GetCount($hList) - 1 EndIf _GUICtrlListBox_SetCurSel($hList, $iCurrIndex) EndIf Case $hENTER If $hListGUI <> -1 And $iCurrIndex <> -1 Then ; List is visible and a item is selected. $sChosen = _GUICtrlListBox_GetText($hList, $iCurrIndex) EndIf Case $hList $sChosen = GUICtrlRead($hList) EndSwitch Sleep(10) $aSelected = _GetSelectionPointers($hInput) If GUICtrlRead($hInput) <> $sCurrInput Or $aSelected[1] <> $aCurrSelected[1] Then ; Input content or pointer are changed. $sCurrInput = GUICtrlRead($hInput) $aCurrSelected = $aSelected ; Get pointers of the string to replace. $iCurrIndex = -1 If $hListGUI <> -1 Then ; List is visible. GUIDelete($hListGUI) $hListGUI = -1 EndIf $hList = _PopupSelector($hGUI, $hListGUI, _CheckInputText($sCurrInput, $aCurrSelected)) ; ByRef $hListGUI, $aCurrSelected. EndIf If $sChosen <> "" Then GUICtrlSendMsg($hInput, 0x00B1, $aCurrSelected[0], $aCurrSelected[1]) ; $EM_SETSEL. _InsertText($hInput, $sChosen) $sCurrInput = GUICtrlRead($hInput) GUIDelete($hListGUI) $hListGUI = -1 $sChosen = "" EndIf WEnd GUIDelete($hGUI) EndFunc ;==>_Main Func _CheckInputText($sCurrInput, ByRef $aSelected) Local $sPartialData = "" If (IsArray($aSelected)) And ($aSelected[0] <= $aSelected[1]) Then Local $aSplit = StringSplit(StringLeft($sCurrInput, $aSelected[0]), " ") $aSelected[0] -= StringLen($aSplit[$aSplit[0]]) If $aSplit[$aSplit[0]] <> "" Then For $A = 1 To $asKeyWords[0] If StringLeft($asKeyWords[$A], StringLen($aSplit[$aSplit[0]])) = $aSplit[$aSplit[0]] And $asKeyWords[$A] <> $aSplit[$aSplit[0]] Then $sPartialData &= $asKeyWords[$A] & "|" EndIf Next EndIf EndIf Return $sPartialData EndFunc ;==>_CheckInputText Func _PopupSelector($hMainGUI, ByRef $hListGUI, $sCurr_List) Local $hList = -1 If $sCurr_List = "" Then Return $hList EndIf $hListGUI = GUICreate("", 280, 160, 10, 62, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST, $WS_EX_MDICHILD), $hMainGUI) $hList = GUICtrlCreateList("", 0, 0, 280, 150, BitOR(0x00100000, 0x00200000)) GUICtrlSetData($hList, $sCurr_List) GUISetControlsVisible($hListGUI) ; To Make Control Visible And Window Invisible. GUISetState(@SW_SHOWNOACTIVATE, $hListGUI) Return $hList EndFunc ;==>_PopupSelector Func _InsertText(ByRef $hEdit, $sString) #cs Description: Insert A Text In A Control. Returns: Nothing #ce Local $aSelected = _GetSelectionPointers($hEdit) GUICtrlSetData($hEdit, StringLeft(GUICtrlRead($hEdit), $aSelected[0]) & $sString & StringTrimLeft(GUICtrlRead($hEdit), $aSelected[1])) Local $iCursorPlace = StringLen(StringLeft(GUICtrlRead($hEdit), $aSelected[0]) & $sString) GUICtrlSendMsg($hEdit, 0x00B1, $iCursorPlace, $iCursorPlace) ; $EM_SETSEL. EndFunc ;==>_InsertText Func _GetSelectionPointers($hEdit) Local $aReturn[2] = [0, 0] Local $aSelected = GUICtrlRecvMsg($hEdit, 0x00B0) ; $EM_GETSEL. If IsArray($aSelected) Then $aReturn[0] = $aSelected[0] $aReturn[1] = $aSelected[1] EndIf Return $aReturn EndFunc ;==>_GetSelectionPointers Func GUISetControlsVisible($hWnd) ; By Melba23. Local $aControlGetPos = 0, $hCreateRect = 0, $hRectRgn = _WinAPI_CreateRectRgn(0, 0, 0, 0) Local $iLastControlID = _WinAPI_GetDlgCtrlID(GUICtrlGetHandle(-1)) For $i = 3 To $iLastControlID $aControlGetPos = ControlGetPos($hWnd, '', $i) If IsArray($aControlGetPos) = 0 Then ContinueLoop $hCreateRect = _WinAPI_CreateRectRgn($aControlGetPos[0], $aControlGetPos[1], $aControlGetPos[0] + $aControlGetPos[2], $aControlGetPos[1] + $aControlGetPos[3]) _WinAPI_CombineRgn($hRectRgn, $hCreateRect, $hRectRgn, 2) _WinAPI_DeleteObject($hCreateRect) Next _WinAPI_SetWindowRgn($hWnd, $hRectRgn, True) _WinAPI_DeleteObject($hRectRgn) EndFunc ;==>GUISetControlsVisible Any advice to improve the code is welcome.1 point
-
Your public IP (STUN protocol)
coffeeturtle reacted to trancexx for a topic
Usually you get IP info by connecting to some site that echoes your IP address. The bad thing about that method is almost proverbial need of site administrators to make changes to sites or their policies requiring from you to frequently update your code. Another issue could be caching thingy of the Inet approach. I did some reading about alternative ways to get public IP, and initially tried with SMTP. This Works great but it's kind of slow and on top of that some ISPs tend to block users on port 25 to prevent spam. Then further reading lead me to STUN protocol documentation. STUN servers are made to resolve and echo users' IP addresses, and are often used by VoIP services. The protocol is extremly simple and everything happens very quickly. Client connects (it's UDP so you Know what Imean), sends request, server replies, client parses the response and IP is there. RFC5389 describes STUN in details, so knock yourself out, if you are that crazy. I have found some implementations written in c++ and c sharp, but OMG, some people are just to stubborn and love to write incomprehensible idiotic hundreds of thousands kilobytes of code for something as simple as STUN. That went nowhere for me and gave me only the pain, so I just fall back to RFC and wrote my own client based on documentation. Function is called STUN_GetMyIP() and you can find example of usage in this little script. It's UDP this and UDP that: STUN.au3 If something wouldn't work, do say.1 point -
The answer is: those details should be hidden, and the data should be accessed by a function (or several functions). As a general rule with complex data structures, or even simple data structures, the user (you) should not know how the data is stored in memory exactly. It helps to have some idea, but you don't need to know the exact implementation details. This is actually a very common problem, particularly in graphics (think of drawing a graph in a GUI, the y axis is based on the bottom left corner, but coordinates for GUIs are done on the top right). Here's a Matrix class I wrote for someone this morning who wanted to know about template classes and static_assert: template<int R, int C> class Matrix { static_assert( R > 0 && C > 0, "Matrix dimensions must be positive and non-zero." ); private: int* data; public: Matrix( ) { this->data = new int[R * C]; } ~Matrix() { delete this->data; } int& at( int r, int c ) { if ( r >= R || c >= C ) { // The given index is too big for the matrix! throw std::out_of_range( "Index out of matrix bounds" ); } return ( this->data[r * C + c] ); } }; The user does not need to know that I'm actually storing the matrix as a single array, all they know is that each element is an int in memory, and they can get a reference to it using the at() method. I could have stored it as a 2d jagged array, but this wouldn't have made sense from a programming perspective. The same goes for AutoIt, and languages where you don't get classes and structures to help you with this. Look at the "memory" functions I made >here, they are simple, and could easily be done without the wrapping functions, but with the code as it is I left my options open, and could now go back and write a garbage collector or something without changing much of the current code at all. Even something as simple as reading a memory address I made a wrapping function for.1 point
-
Hamachi
JustSomeone reacted to bogQ for a topic
#Include <GuiToolBar.au3> _SysTray_ClickItem("Hamachi -- offline", "left", 2) ControlClick(WinWaitActive(WinActivate(WinWait('LogMeIn Hamachi'))),'','[CLASS:Button; INSTANCE:1]') ;~ If @error Then MsgBox(48, "Failure", "Required item not found") ;=========# _SysTray_ClickItem #====================================================== ; ;Function Name: _SysTray_ClickItem() ;Description: Click on item in Windows system tray by any substring in the title ;Parameters: $iTitle - The title of the item in Windows system tray (you can see the title of the item when mouse cursor hovered on item). ; $iButton - [optional] The button to click, "left" or "right". Default is the left button. ; $iClick - [optional] The number of times to click the mouse. Default is 1 ; $sMove = [optional] True = Mouse will be moved, False (default) = Mouse will not be moved ; $iSpeed = [optional] Mouse movement speed ;Return Value(s): Success - Returns 1 ; Failure - Returns 0 and sets @error to 1 if required item not found ;Requirement(s): AutoIt 3.2.10.0 and above ;Autor(s): R.Gilman (a.k.a rasim); Siao (Thanks for idea) ; ;==================================================================================== Func _SysTray_ClickItem($iTitle, $iButton = "left", $iClick = 1, $sMove = False, $iSpeed = 1) Local $hToolbar, $iButCount, $aRect, $hButton, $cID, $i $hToolbar = ControlGetHandle("[Class:Shell_TrayWnd]", "", "[Class:ToolbarWindow32;Instance:1]") If @error Then Return SetError(1, 0, 0) EndIf $iButCount = _GUICtrlToolbar_ButtonCount($hToolbar) If $iButCount = 0 Then Return SetError(1, 0, 0) EndIf $hButton = ControlGetHandle("[Class:Shell_TrayWnd]", "", "Button2") If $hButton <> "" Then ControlClick("[Class:Shell_TrayWnd]", "", "Button2") For $i = 0 To $iButCount - 1 $cID = _GUICtrlToolbar_IndexToCommand($hToolBar, $i) If StringInStr(_GUICtrlToolbar_GetButtonText($hToolBar, $cID), $iTitle) Then _GUICtrlToolbar_ClickButton($hToolbar, $cID, $iButton, $sMove, $iClick, $iSpeed) Return 1 EndIf Next Return SetError(1, 0, 0) EndFunc1 point -
$sXML = '<availability>' & @crlf & _ '<members date="2014-06-6" count="2" day="2" night="1" OOA="0" na="0" />' & @crlf & _ '<members date="2014-06-7" count="6" day="5" night="1" OOA="0" na="0" />' & @crlf & _ '<members date="2014-06-8" count="8" day="4" night="1" OOA="0" na="0" />' & @crlf & _ '<members date="2014-06-9" count="9" day="9" night="1" OOA="0" na="0" />' & @crlf & _ '</availability>' $day = StringRegExpReplace($sXML, '(?is).*<availability.*?day="([^"]+).*</availability.*', '$1') ; gets the first one (2) Msgbox(0,"day", $day) $day = StringRegExpReplace($sXML, '(?is).*<availability.*day="([^"]+).*?</availability.*', '$1') ; gets the last one (9) Msgbox(0,"day", $day)1 point
-
Example http://msdn.microsoft.com/en-us/library/aa372865(v=vs.85).aspx #include <Array.au3> Global Const $msiOpenDatabaseModeReadOnly = 0 ;; Opens a database read-only, no persistent changes. Global Static $oInstaller, $oDatabase, $oView, $oRecord, $sFilePath, $aRegistry[101][4] = [[0,100]] $sFilePath = FileOpenDialog("Select a MSI file...", @ScriptDir, "MSI (*.msi)") ;;"MSI (*.msi;*.msp)" If Not @Error Then $oInstaller = ObjCreate("WindowsInstaller.Installer") If IsObj($oInstaller) Then $oDatabase = $oInstaller.OpenDatabase($sFilePath, $msiOpenDatabaseModeReadOnly) If IsObj($oDatabase) Then $oView = $oDatabase.OpenView("SELECT `Registry`.`Key`, `Registry`.`Name`, `Registry`.`Value` FROM `Registry` WHERE `Registry`.`Root`=0 ORDER BY `Registry`.`Root`") If IsObj($oView) Then $oView.Execute() While 1 $oRecord = $oView.Fetch If Not IsObj($oRecord) Then ExitLoop $aRegistry[0][0] += 1 If $aRegistry[0][0] = $aRegistry[0][1] Then $aRegistry[0][1] *= 2 ReDim $aRegistry[$aRegistry[0][1] + 1][4] EndIf $aRegistry[$aRegistry[0][0]][0] = "HKCR" For $i = 1 To 3 $aRegistry[$aRegistry[0][0]][$i] = $oRecord.StringData($i) Next WEnd $oView.Close ReDim $aRegistry[$aRegistry[0][0] + 1][4] Else MsgBox(0, "Error", 4) EndIf Else MsgBox(0, "Error", 3) EndIf Else MsgBox(0, "Error", 2) EndIf Else MsgBox(0, "Error", 1) EndIf $oView = "" $oDatabase = "" _ArrayDisplay($aRegistry) #include <Array.au3> Global Const $msiOpenDatabaseModeReadOnly = 0 ;; Opens a database read-only, no persistent changes. Global Static $oInstaller, $oDatabase, $oView, $oRecord, $sFilePath, $aRegistry[101][4] = [[0,100]] $sFilePath = FileOpenDialog("Select a MSI file...", @ScriptDir, "MSI (*.msi)") ;;"MSI (*.msi;*.msp)" If Not @Error Then $oInstaller = ObjCreate("WindowsInstaller.Installer") If IsObj($oInstaller) Then $oDatabase = $oInstaller.OpenDatabase($sFilePath, $msiOpenDatabaseModeReadOnly) If IsObj($oDatabase) Then $oView = $oDatabase.OpenView("SELECT `Registry`.`Key`, `Registry`.`Name`, `Registry`.`Value` FROM `Registry` WHERE `Registry`.`Root`=1 ORDER BY `Registry`.`Root`") If IsObj($oView) Then $oView.Execute() While 1 $oRecord = $oView.Fetch If Not IsObj($oRecord) Then ExitLoop $aRegistry[0][0] += 1 If $aRegistry[0][0] = $aRegistry[0][1] Then $aRegistry[0][1] *= 2 ReDim $aRegistry[$aRegistry[0][1] + 1][4] EndIf $aRegistry[$aRegistry[0][0]][0] = "HKCU" For $i = 1 To 3 $aRegistry[$aRegistry[0][0]][$i] = $oRecord.StringData($i) Next WEnd $oView.Close ReDim $aRegistry[$aRegistry[0][0] + 1][4] Else MsgBox(0, "Error", 4) EndIf Else MsgBox(0, "Error", 3) EndIf Else MsgBox(0, "Error", 2) EndIf Else MsgBox(0, "Error", 1) EndIf $oView = "" $oDatabase = "" _ArrayDisplay($aRegistry) Ciao.1 point
-
Personally, I would have done it like this: #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiMenu.au3> #include <WinAPI.au3> Global $Counter = 0; Global $isCounting = False; Global $WaitExcel = False; Global $WaitExcelTimeOut = 0; Global $ExcelTimeNow = null; $Form1 = GUICreate("Count 1 to 100", 250, 240) $Button1 = GUICtrlCreateButton("Start", 15, 15, 75, 25) $Label1 = GUICtrlCreateLabel("0", 135, 16, 40, 17) $Button2 = GUICtrlCreateButton("Stop", 15, 55, 75, 25) $Button3 = GUICtrlCreateButton("Reset", 15, 95, 75, 25) $Button4 = GUICtrlCreateButton("Start Excel", 15, 155, 75, 25) $Button5 = GUICtrlCreateButton("Stop waiting Excel", 15, 195, 100, 25) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUIRegisterMsg($WM_SYSCOMMAND, "WM_SYSCOMMAND") While 1 Sleep(10); ;----- loop that can be broken: ---------- if ($isCounting AND $Counter < 100) Then While $Counter < 100 AND $isCounting $Counter += 1 GUICtrlSetData($Label1, $Counter) Sleep(100) WEnd $isCounting = False; EndIf ;----------------------------------------- ;----------------------------------------- if ($WaitExcel) Then While 1 if WinExists("Microsoft Excel", "") Then MsgBox(0, "Success", "Excel is up and running!") ExitLoop EndIf if NOT $WaitExcel Then MsgBox(0, "Canceled", "You are no longer waiting for excel!") ExitLoop EndIf if $ExcelTimeNow <> null AND $WaitExcelTimeOut > 0 Then if (TimerDiff($ExcelTimeNow) >= $WaitExcelTimeOut*1000) then MsgBox(0, "Timed out", "You are no longer waiting for excel!" & @CRLF & "Timed out.") ExitLoop EndIf EndIf Sleep(10); WEnd $WaitExcel = False; EndIf ;----------------------------------------- WEnd Func WM_SYSCOMMAND($hWnd, $iMsg, $WParam, $LParam) Switch $hWnd Case $Form1 Switch $WParam Case $SC_CLOSE ;X button in the GUI form Exit; EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) Local $nID = BitAND($iwParam, 0x0000FFFF) #forceref $hWnd, $iMsg, $iwParam, $ilParam $iCode = _WinAPI_HiWord($iwParam) Switch $nID Case $Button1 $isCounting = True; Case $Button2 $isCounting = False; Case $Button3 $Counter = 0; GUICtrlSetData($Label1, $Counter) Case $Button4 $WaitExcelTimeOut = 30; wait for 30 seconds. $ExcelTimeNow = TimerInit(); ShellExecute("excel.exe"); $WaitExcel = True; Case $Button5 $WaitExcel = False; EndSwitch Return $GUI_RUNDEFMSG EndFunc1 point
-
Hi, As certain people seem to be getting extremely wound up about something that has existed in AutoIt since I started using it many years ago, I have amended the Help file <Operators> page so that the standard "=" operator section points to the "mixed datatypes" note at the bottom of the same page. I hope that will help return any elevated blood pressure readings to a safer level. M231 point
-
Here is an example of the gui always being responsive: #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <Constants.au3> #include <WindowsConstants.au3> $aProcess = "" $iProcessesCreated = 1 $iMsgBoxCreated = 1 $iMsgBox = "" $Form1 = GUICreate("Form1", 623, 446, 192, 114) $Button1 = GUICtrlCreateButton("Wait excell", 192, 64, 105, 49) $Button2 = GUICtrlCreateButton("Stop", 192, 136, 105, 49) $Button3 = GUICtrlCreateButton("msgbox", 192, 208, 105, 49) GUISetState(@SW_SHOW) Local $Flag = False While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE If IsArray($aProcess) Then ConsoleWrite("Killing prior task that was initiated" & @CRLF) ProcessClose($aProcess[0]) EndIf If $iMsgBox Then ProcessClose($iMsgBox) Exit Case $Button2 If IsArray($aProcess) Then ConsoleWrite("Killing prior task that was initiated" & @CRLF) ProcessClose($aProcess[0]) EndIf If $iMsgBox Then ProcessClose($iMsgBox) Exit Case $Button1 $iCounter = 1 If IsArray($aProcess) Then ConsoleWrite("Killing prior task that was initiated" & @CRLF) ProcessClose($aProcess[0]) EndIf $sCommand = 'AutoIt3.exe /ErrorStdOut /AutoIt3ExecuteLine "Exit (Sleep(5000))+' & $iProcessesCreated & '"' $iProcessesCreated+=1 $aProcess = _Parallel_CreateProcess($sCommand) Case $Button3 If $iMsgBox Then ProcessClose($iMsgBox) $sCommand = 'AutoIt3.exe /ErrorStdOut /AutoIt3ExecuteLine "MsgBox(0, ''test'', ''ABC...Initiated=[' & $iMsgBoxCreated & ']x'')"' $iMsgBoxCreated += 1 $iMsgBox = Run($sCommand) EndSwitch If IsArray($aProcess) Then $iCounter+=1 If IsInt($iCounter/50) Then ConsoleWrite("Your command is still running" & @CRLF) EndIf If Not _ProcessExistsByHandle($aProcess[1],10) Then $iReturnOfResult=@extended ConsoleWrite("Returned=" & $iReturnOfResult & @CRLF) $aProcess = 0 EndIf EndIf Sleep (10) WEnd Exit Func _Parallel_CreateProcess($sCommand, $sWrkDir="", $iShow=@SW_MINIMIZE, $iOpts=0) ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Parallel_CreateProcess ; Description ...: Launch a new process. ; Syntax ........: _Parallel_CreateProcess($sCommand, $sWrkDir, $iShow, $iOpts) ; Parameters ....: $sCommand - Command line including parameters. ; $sWrkDir - Working directory. Default = "". ; $iShow - Initial state of any application window, any of the @SW_ macros. ; $iOpts - Options 0x10 or 0x10000 from internal Run() command, BitOR'd. ; Return values .: Success - A two element array: ; [0] - PID ; [1] - process handle (MUST be closed when finished with it) ; Failure - Sets @error = 1 and returns 0 as PID and handle ; Author ........: Erik Pilsits ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== ; use options provided by internal Run() command for consistent usage ; but only supports 0x10 and 0x10000 ; Local $aRet[2] = [0, 0] Local $sSTARTUP = DllStructCreate($tagSTARTUPINFO) Local $sPROCINFO = DllStructCreate($tagPROCESS_INFORMATION) DllStructSetData($sSTARTUP, "Size", DllStructGetSize($sSTARTUP)) DllStructSetData($sSTARTUP, "Flags", $STARTF_USESHOWWINDOW) DllStructSetData($sSTARTUP, "ShowWindow", $iShow) ; ; check options If BitAND($iOpts, 0x10) = 0x10 Then ; inherit parent stdio handles DllStructSetData($sSTARTUP, "Flags", BitOR($STARTF_USESHOWWINDOW, $STARTF_USESTDHANDLES)) DllStructSetData($sSTARTUP, "StdInput", _WinAPI_GetStdHandle(0)) DllStructSetData($sSTARTUP, "StdOutput", _WinAPI_GetStdHandle(1)) DllStructSetData($sSTARTUP, "StdError", _WinAPI_GetStdHandle(2)) EndIf Local $dwCreationFlags = 0 If BitAND($iOpts, 0x10000) = 0x10000 Then ; CREATE_NEW_CONSOLE = 0x10 $dwCreationFlags = 0x10 EndIf ; check working dir Local $sWrkDirType = "wstr" If $sWrkDir = "" Then $sWrkDirType = "ptr" $sWrkDir = 0 EndIf ; Local $ret = DllCall("kernel32.dll", "bool", "CreateProcessW", "ptr", 0, "wstr", $sCommand, "ptr", 0, "ptr", 0, "bool", 0, _ "dword", $dwCreationFlags, "ptr", 0, $sWrkDirType, $sWrkDir, "struct*", $sSTARTUP, "struct*", $sPROCINFO) If @error Or Not $ret[0] Then Return SetError(1, 0, $aRet) ; ; close unused thread handle _WinAPI_CloseHandle(DllStructGetData($sPROCINFO, "hThread")) ; ; return array of info, [0] = PID, [1] = process handle $aRet[0] = DllStructGetData($sPROCINFO, "ProcessID") $aRet[1] = DllStructGetData($sPROCINFO, "hProcess") Return SetError(0, 0, $aRet) EndFunc ;==>_Parallel_CreateProcess Func _ProcessExistsByHandle($hProc,$iTimeOutMilSec) ; #FUNCTION# ==================================================================================================================== ; Name ..........: _ProcessExistsByHandle ; Description ...: Check if a process exists by handle. ; Syntax ........: _ProcessExistsByHandle($hProc) ; Parameters ....: $hProc - Open handle to a process, for example from a call to OpenProcess. ; Return values .: Success - 0 if process has ended, 1 if it still exists ; @extended contains the exit code ; Failure - 0 and sets @error ; Author ........: Erik Pilsits ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== ; there was an error creating the process If Not $hProc Then Return SetError(1, 0, 0) ; Local $iExit = DllCall("kernel32.dll", "bool", "GetExitCodeProcess", "handle", $hProc, "dword*", -1) If @error Or (Not $iExit[0]) Then ; error Return SetError(1, 0, 0) ElseIf $iExit[2] = 259 Then ; process STILL_ACTIVE ; extra check if process used STILL_ACTIVE as a valid exit code, $WAIT_OBJECT_0 If _WinAPI_WaitForSingleObject($hProc, $iTimeOutMilSec) = 0 Then If $iExit[2] = 259 Then _ProcessExistsByHandle($hProc,$iTimeOutMilSec) Return SetExtended(@extended,0) Else Return SetExtended($iExit[2], 0) EndIf Else Return 1 EndIf Else ; process does not exist, return exit code in @extended Return SetExtended($iExit[2], 0) EndIf EndFunc ;==>_ProcessExistsByHandle1 point
-
DXRW4E, You assign an integer value to a variable - AutoIt thinks you want to store this as an integer and so it types $sString as Int32 (use VarGetType to check). Then when you compare using the "=" operator, AutoIt sees an integer datatype on one side and converts @UserName to an integer as well - which of course resolves as 0 (unless you happen to have leading numbers in your user name). Hence 0=0 and you get True as a response. If you want to compare the 2 elements as strings, use the "==" operator which will force both sides to string datatype. All clear? M231 point
-
Kovacic, You might be able to do something with an owner-drawn tab control - funkey has one here. Or perhaps you could use my GUIExtender UDF (the link is in my sig) which allows you to open and close sections of a GUI. M231 point
-
MultiLang.au3
simplercoder000 reacted to BrettF for a topic
MultiLang.au3 V1.0.0.0- 14 AUG 2010 MultiLang.zip This is a UDF version of how I chose to load different languages into my GUI for AAMP. It uses different XML language files to provide multi-language support. The download includes the UDF, example GUI with 3 languages (English, German, French) to play with. Languages were translated using Google Translate. Don't expect it to be correct. In your programs try not to do this. Wherever possible find a fluent speaker and give them a cookie. Change Log: 1.0.0.0 - 14 AUG 2010 Inital Version Released Comments and Criticism welcome.1 point -
Hi, I recently needed to place a semi transparent layer over a background image in order to make my label(text) controls more readable. Although I've tinkered with GDI+ functions, child guis etc., in the end I've come up with this. This UDF takes advantage of trancexx's GIFAnimations UDF and creates semi-transparent layer using several embeded(binary) PNG images. I think it is very easy to use and it does the job the effective way without calling/registering bunch of redraw functions etc. (thanks to GIFAnimations UDF.) An alternative function which creates the semi-transparent layer as child gui is also included. I really prefer _CreateBlankBox but it can be helpful if you are curious. I hope it will be useful. Sincerely, Tip P.S.: Example is included... CreateBlankBox.zip1 point