Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/12/2013 in all areas

  1. JohnOne

    select a starting func

    HotKeySet("{TAB}", "exmpl") Func exmpl() Global $p = Int(InputBox("title", "prompt")) MsgBox(0, 0, $p) While 1 Select Case $p = 1 a1() Case $p = 2 a2() Case $p = 3 a3() EndSelect WEnd EndFunc ;==>exmpl
    1 point
  2. careca

    select a starting func

    there are lots of ways to do that, checkboxes, dropdown items, whatever...
    1 point
  3. Probably neither. AutoIt doesn't allow the use of any keywords (const, byref, ...) for callback functions parameters.
    1 point
  4. Hmmm...communication fails miserably in this medium... What I was thinking when I posted that was that I should have pointed this out specifically. When I re-read it I was afraid that you would take it critically. The return comment refers specifically to what guinness is warning you about. kylomas edit: additional info Because CONST vars cannot change, the parms to this procedure change with every call.
    1 point
  5. I did see the Const and of course wondered that too, but didn't think it would make a blind bit of difference as they're being passed as values and not a references.
    1 point
  6. Jury

    some regex troubles

    Whatever but don't forget the powerful; (?=[d+]) This asserts that this: [d+]) can be matched, then continues by starting at this position and so on until end of file Z in my script. #include <Array.au3> $text = FileRead(@MyDocumentsDir & "\test.txt") $state = StringRegExp($text, '(?-s)\[\d+\].*?\r?\n.*?\["Active"\]\s*=\s*"(\d+)"(?s).*?(?=\[\d+\]|\Z)', 3) Dim $array[UBound($state)+1][2] = [["device", "status"]] For $i = 1 to UBound($state) $array[$i][0] = $i $array[$i][1] = $state[$i-1] Next _ArrayDisplay($array)
    1 point
  7. I don't have two monitors to test but I can give you some pointers. 1. Your 'WindowFromPoint' doesn't sit right with me, as this should use a POINT structure instead. I'm actually surprised it works. Why not create a wrapper function of _WinAPI_WindowFromPoint OR just use _WinAPI_WindowFromPoint. 2. I don't quite see the difference between using $WH_MOUSE_LL with _WinAPI_SetWindowsHookEx and the DLL?
    1 point
  8. UEZ

    Image in traytip?

    Here another way to create a fake traytip with option to display an image within. This is an alpha version and just a proof of concept (needs still a lot of work)! ;coded by UEZ build 2013-05-13 alpha version #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GDIPlus.au3> #include <StaticConstants.au3> _GDIPlus_Startup() Global $sText = "This is a fake traytip" & @CRLF & _ "created with GDI+ :-)" & @CRLF & @CRLF & _ "Coded by UEZ 2013" Global $hImage = _GDIPlus_ImageLoadFromFile("c:\Program Files (x86)\AutoIt3\Examples\GUI\Merlin.gif") _GDIPlus_CreateTrayTip($sText, "Information", $hImage) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() Func _GDIPlus_CreateTrayTip($sText, $sHeader, $hImage = 0, $sFont = "Arial", $fFontSize = 14, $iFontColor = 0xFF000000) Local $iBGColor = 0xFFFFFFFF Local $hPath = DllCall($ghGDIPDll, "uint", "GdipCreatePath", "int", 0, "int*", 0) $hPath = $hPath[2] Local $hFamily = _GDIPlus_FontFamilyCreate($sFont) Local $tLayout = _GDIPlus_RectFCreate(0, 0, 0, 0) ;measure text size DllCall($ghGDIPDll, "uint", "GdipAddPathString", "handle", $hPath, "wstr", $sHeader, "int", -1, "handle", $hFamily, "int", 0, "float", $fFontSize + 4, "struct*", $tLayout, "handle", 0) DllStructSetData($tLayout, "Y", $fFontSize * 2) DllCall($ghGDIPDll, "uint", "GdipAddPathString", "handle", $hPath, "wstr", $sText, "int", -1, "handle", $hFamily, "int", 0, "float", $fFontSize, "struct*", $tLayout, "handle", 0) Local $tRectF = DllStructCreate($tagGDIPRECTF) DllCall($ghGDIPDll, "uint", "GdipGetPathWorldBounds", "handle", $hPath, "struct*", $tRectF, "handle", 0, "handle", 0) ;create bitmap Local $iW = Floor(DllStructGetData($tRectF, 3)) + 90, $iH = Floor(DllStructGetData($tRectF, 4)) + $fFontSize + 15, $iPenSize = 1 Local $hBitmap = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iW + $iPenSize, "int", $iH + $iPenSize + 20, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0) $hBitmap = $hBitmap[6] Local $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hCtxt, 2) DllCall($ghGDIPDll, "uint", "GdipSetTextRenderingHint", "handle", $hCtxt, "int", 4) DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "handle", $hCtxt, "int", 7) DllCall($ghGDIPDll, "uint", "GdipResetPath", "handle", $hPath) Local $iWin = 1, $bVisible = False, $iPosX Local $iIconIndex = _SysTrayIconIndex(@AutoItPID, 2, $iWin) Local $aPosIcon = _SysTrayGetButtonInfo($iIconIndex, $iWin, 4) If $iIconIndex > -1 Then $bVisible = True $iPosX = $aPosIcon[0] $iPosWinX = $aPosIcon[0] $iPosWinY = $aPosIcon[1] Else Local $aTaskbar = WinGetPos("[CLASS:Shell_TrayWnd;INSTANCE:1]", "") $iPosWinX = @DesktopWidth - $iW - 30 $iPosWinY = $aTaskbar[1] EndIf ;draw ballon Local $iX = 0, $iY = 0, $iRadius = 20, $iDX, $iLimit DllCall($ghGDIPDll, "uint", "GdipAddPathArc", "handle", $hPath, "float", $iX + $iW - ($iRadius * 2), "float", $iY, "float", $iRadius * 2, "float", $iRadius * 2, "float", 270, "float", 90) DllCall($ghGDIPDll, "uint", "GdipAddPathArc", "handle", $hPath, "float", $iX + $iW - ($iRadius * 2), "float", $iY + $iH - ($iRadius * 2), "float", $iRadius * 2, "float", $iRadius * 2, "float", 0, "float", 90) If $bVisible > 0 Then $iDX = @DesktopWidth - ($iPosX + $iW + $iRadius + $iPenSize) If $iDX < 0 Then $iDX *= -1.15 If $iDX > ($iW - $iRadius * 3) Then $iDX = $iW - $iRadius * 3 If $iDX < $iRadius * 2 Then $iDX = 2 * $iRadius + 4 ElseIf $iDX > $iW / 2 Then $iDX = $iW / 2 EndIf DllCall($ghGDIPDll, "uint", "GdipAddPathLine", "handle", $hPath, "float", $iX + $iW - ($iRadius * 2), "float", $iY + $iH, "float", $iX + $iRadius + $iDX, "float", $iY + $iH) DllCall($ghGDIPDll, "uint", "GdipAddPathLine", "handle", $hPath, "float", $iX + $iRadius + $iDX, "float", $iY + $iH, "float", $iX + $iRadius + $iDX - 20, "float", $iY + $iH + 20) DllCall($ghGDIPDll, "uint", "GdipAddPathLine", "handle", $hPath, "float", $iX + $iRadius + $iDX - 20, "float", $iY + $iH + 20, "float", $iX + $iRadius + $iDX - 20, "float", $iY + $iH) EndIf DllCall($ghGDIPDll, "uint", "GdipAddPathArc", "handle", $hPath, "float", $iX, "float", $iY + $iH - ($iRadius * 2), "float", $iRadius * 2, "float", $iRadius * 2, "float", 90, "float", 90) DllCall($ghGDIPDll, "uint", "GdipAddPathArc", "handle", $hPath, "float", $iX, "float", $iY, "float", $iRadius * 2, "float", $iRadius * 2, "float", 180, "float", 90) DllCall($ghGDIPDll, "uint", "GdipClosePathFigure", "handle", $hPath) Local $hPen = _GDIPlus_PenCreate(0xFF000000, $iPenSize) DllCall($ghGDIPDll, "uint", "GdipDrawPath", "handle", $hCtxt, "handle", $hPen, "handle", $hPath) Local $hBrush = _GDIPlus_BrushCreateSolid($iBGColor) DllCall($ghGDIPDll, "uint", "GdipFillPath", "handle", $hCtxt, "handle", $hBrush, "handle", $hPath) DllCall($ghGDIPDll, "uint", "GdipResetPath", "handle", $hPath) ;draw text _GDIPlus_BrushSetSolidColor($hBrush, 0xFF0000FF) DllStructSetData($tLayout, "X", 60) DllStructSetData($tLayout, "Y", 10) DllCall($ghGDIPDll, "uint", "GdipAddPathString", "handle", $hPath, "wstr", $sHeader, "int", -1, "handle", $hFamily, "int", 0, "float", $fFontSize + 4, "struct*", $tLayout, "handle", 0) DllCall($ghGDIPDll, "uint", "GdipFillPath", "handle", $hCtxt, "handle", $hBrush, "handle", $hPath) DllCall($ghGDIPDll, "uint", "GdipResetPath", "handle", $hPath) _GDIPlus_BrushSetSolidColor($hBrush, $iFontColor) DllStructSetData($tLayout, "Y", $fFontSize * 2 + 10) DllCall($ghGDIPDll, "uint", "GdipAddPathString", "handle", $hPath, "wstr", $sText, "int", -1, "handle", $hFamily, "int", 0, "float", $fFontSize, "struct*", $tLayout, "handle", 0) DllCall($ghGDIPDll, "uint", "GdipFillPath", "handle", $hCtxt, "handle", $hBrush, "handle", $hPath) If $hImage Then _GDIPlus_GraphicsDrawImageRect($hCtxt, $hImage, $iRadius, $iRadius, 32, 32) DllCall($ghGDIPDll, "uint", "GdipDeletePath", "handle", $hPath) _GDIPlus_PenDispose($hPen) _GDIPlus_BrushDispose($hBrush) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_GraphicsDispose($hCtxt) Local $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _GDIPlus_BitmapDispose($hBitmap) $iW += $iPenSize $iH += $iPenSize + 20 ;create GUI Local $hGUI = GUICreate("", $iW, $iH, -1, -1, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_TOPMOST + $WS_EX_TOOLWINDOW), $iBGTColor = 0x010101 GUISetBkColor($iBGTColor) Local $iPic = GUICtrlCreatePic("", 0, 0, $iW, $iH) GUICtrlSetState(-1, $GUI_DISABLE) Local $iSizeBtn = 18 ;~ Local $iBtn = GUICtrlCreateButton("X", $iW - $iRadius - $iSizeBtn, $iRadius, $iSizeBtn, $iSizeBtn, BitOR($BS_CENTER,$BS_VCENTER,$BS_FLAT)) Local $iLabel = GUICtrlCreateLabel("X", $iW - $iSizeBtn - 4, $iSizeBtn, $iSizeBtn, $iSizeBtn, $SS_SIMPLE + $SS_CENTER) GUICtrlSetBkColor(-1, -2) Local $hB = GUICtrlSendMsg($iPic, 0x0172, 0, $hHBitmap) If $hB Then _WinAPI_DeleteObject($hB) _WinAPI_SetLayeredWindowAttributes($hGUI, $iBGTColor, 0x00) Local $aWin = WinGetPos($hGUI) WinMove($hGUI, "", $iPosWinX - ($iRadius + $iDX - 30), $iPosWinY - $iH + 20) GUISetState() For $i = 0 To 0xFF _WinAPI_SetLayeredWindowAttributes($hGUI, $iBGTColor, $i) Sleep(10) Next Local $iTimer = TimerInit(), $iTimerWait = 5 Do Switch GUIGetMsg() Case $iLabel, $GUI_EVENT_CLOSE ExitLoop EndSwitch If TimerDiff($iTimer) > $iTimerWait * 1000 Then ExitLoop Until False For $i = 0xFF To 0 Step - 2 _WinAPI_SetLayeredWindowAttributes($hGUI, $iBGTColor, $i) Sleep(10) Next GUIDelete($hGUI) _WinAPI_DeleteObject($hHBitmap) EndFunc #region interanl functions #region _Systray (Author: Tuape, Modified: Erik Pilsits -> build 5/13/2013) Func _SysTrayIconCount($iWin = 1) Local Const $TB_BUTTONCOUNT = 1048 Local $hWnd = _FindTrayToolbarWindow($iWin) If $hWnd = -1 Then Return -1 Local $count = DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", $hWnd, "uint", $TB_BUTTONCOUNT, "wparam", 0, "lparam", 0) If @error Then Return -1 Return $count[0] EndFunc ;==>_SysTrayIconCount Func _SysTrayIconTitles($iWin = 1) Local $count = _SysTrayIconCount($iWin) If $count <= 0 Then Return -1 Local $titles[$count] For $i = 0 To $count - 1 $titles[$i] = WinGetTitle(_SysTrayIconHandle($i, $iWin)) Next Return $titles EndFunc ;==>_SysTrayIconTitles Func _SysTrayIconPids($iWin = 1) Local $count = _SysTrayIconCount($iWin) If $count <= 0 Then Return -1 Local $processes[$count] For $i = 0 To $count - 1 $processes[$i] = WinGetProcess(_SysTrayIconHandle($i, $iWin)) Next Return $processes EndFunc ;==>_SysTrayIconPids Func _SysTrayIconProcesses($iWin = 1) Local $pids = _SysTrayIconPids($iWin) If Not IsArray($pids) Then Return -1 Local $processes[UBound($pids)] Local $list = ProcessList() For $i = 0 To UBound($pids) - 1 For $j = 1 To $list[0][0] If $pids[$i] = $list[$j][1] Then $processes[$i] = $list[$j][0] ExitLoop EndIf Next Next Return $processes EndFunc ;==>_SysTrayIconProcesses Func _SysTrayIconIndex($test, $mode = 0, $iWin = 1) Local $ret = -1, $compare = -1 If $mode < 0 Or $mode > 2 Or Not IsInt($mode) Then Return -1 Switch $mode Case 0 $compare = _SysTrayIconProcesses($iWin) Case 1 $compare = _SysTrayIconTitles($iWin) Case 2 $compare = _SysTrayIconPids($iWin) EndSwitch If Not IsArray($compare) Then Return -1 For $i = 0 To UBound($compare) - 1 If $compare[$i] = $test Then $ret = $i ExitLoop EndIf Next Return $ret EndFunc ;==>_SysTrayIconIndex Func _SysTrayGetButtonInfo($iIndex, $iWin = 1, $iInfo = 1) Local Const $TB_GETBUTTON = 1047 Local Const $TB_GETITEMRECT = 1053 Local Const $ACCESS = BitOR(0x0008, 0x0010, 0x0400) Local $TBBUTTON If @OSArch = "X86" Then $TBBUTTON = DllStructCreate("int iBitmap;int idCommand;byte fsState;byte fsStyle;byte bReserved[2];dword dwData;int iString") Else $TBBUTTON = DllStructCreate("int iBitmap;int idCommand;byte fsState;byte fsStyle;byte bReserved[6];uint64 dwData;int64 iString") EndIf Local $TRAYDATA If @OSArch = "X86" Then $TRAYDATA = DllStructCreate("hwnd hwnd;uint uID;uint uCallbackMessage;dword Reserved[2];handle hIcon") Else $TRAYDATA = DllStructCreate("uint64 hwnd;uint uID;uint uCallbackMessage;dword Reserved[2];uint64 hIcon") EndIf Local $trayHwnd = _FindTrayToolbarWindow($iWin) If $trayHwnd = -1 Then Return SetError(1, 0, -1) Local $return, $err = 0 Local $ret = DllCall("user32.dll", "dword", "GetWindowThreadProcessId", "hwnd", $trayHwnd, "dword*", 0) If @error Or Not $ret[2] Then SetError(2, 0, -1) Local $pId = $ret[2] Local $procHandle = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", $ACCESS, "bool", False, "dword", $pId) If @error Or Not $procHandle[0] Then Return SetError(3, 0, -1) Local $lpData = DllCall("kernel32.dll", "ptr", "VirtualAllocEx", "handle", $procHandle[0], "ptr", 0, "ulong", DllStructGetSize($TBBUTTON), "dword", 0x1000, "dword", 0x04) If Not @error And $lpData[0] Then $ret = DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", $trayHwnd, "uint", $TB_GETBUTTON, "wparam", $iIndex, "lparam", $lpData[0]) If Not @error And $ret[0] Then DllCall("kernel32.dll", "bool", "ReadProcessMemory", "handle", $procHandle[0], "ptr", $lpData[0], "struct*", $TBBUTTON, "ulong", DllStructGetSize($TBBUTTON), "ulong*", 0) Switch $iInfo Case 2 DllCall("kernel32.dll", "bool", "ReadProcessMemory", "handle", $procHandle[0], "ptr", DllStructGetData($TBBUTTON, 6), "struct*", $TRAYDATA, "ulong", DllStructGetSize($TRAYDATA), "ulong*", 0) $return = $TRAYDATA Case 3 $return = "" If BitShift(DllStructGetData($TBBUTTON, 7), 16) <> 0 Then Local $intTip = DllStructCreate("wchar[1024]") DllCall("kernel32.dll", "bool", "ReadProcessMemory", "handle", $procHandle[0], "ptr", DllStructGetData($TBBUTTON, 7), "struct*", $intTip, "ulong", DllStructGetSize($intTip), "ulong*", 0) $return = DllStructGetData($intTip, 1) EndIf Case 4 If Not BitAND(DllStructGetData($TBBUTTON, 3), 8) Then Local $pos[2], $RECT = DllStructCreate("int;int;int;int") DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", $trayHwnd, "uint", $TB_GETITEMRECT, "wparam", $iIndex, "lparam", $lpData[0]) DllCall("kernel32.dll", "bool", "ReadProcessMemory", "handle", $procHandle[0], "ptr", $lpData[0], "struct*", $RECT, "ulong", DllStructGetSize($RECT), "ulong*", 0) $ret = DllCall("user32.dll", "int", "MapWindowPoints", "hwnd", $trayHwnd, "ptr", 0, "struct*", $RECT, "uint", 2) $pos[0] = DllStructGetData($RECT, 1) $pos[1] = DllStructGetData($RECT, 2) $return = $pos Else $return = -1 EndIf Case Else $return = $TBBUTTON EndSwitch Else $err = 5 EndIf DllCall("kernel32.dll", "bool", "VirtualFreeEx", "handle", $procHandle[0], "ptr", $lpData[0], "ulong", 0, "dword", 0x8000) Else $err = 4 EndIf DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $procHandle[0]) If $err Then Return SetError($err, 0, -1) Else Return $return EndIf EndFunc ;==>_SysTrayGetButtonInfo Func _SysTrayIconHandle($iIndex, $iWin = 1) Local $TRAYDATA = _SysTrayGetButtonInfo($iIndex, $iWin, 2) If @error Then Return SetError(@error, 0, -1) Else Return Ptr(DllStructGetData($TRAYDATA, 1)) EndIf EndFunc ;==>_SysTrayIconHandle Func _FindTrayToolbarWindow($iWin = 1) Local $hWnd, $ret = -1 If $iWin = 1 Then $hWnd = DllCall("user32.dll", "hwnd", "FindWindow", "str", "Shell_TrayWnd", "ptr", 0) If @error Then Return -1 $hWnd = DllCall("user32.dll", "hwnd", "FindWindowEx", "hwnd", $hWnd[0], "hwnd", 0, "str", "TrayNotifyWnd", "ptr", 0) If @error Then Return -1 If @OSVersion <> "WIN_2000" Then $hWnd = DllCall("user32.dll", "hwnd", "FindWindowEx", "hwnd", $hWnd[0], "hwnd", 0, "str", "SysPager", "ptr", 0) If @error Then Return -1 EndIf $hWnd = DllCall("user32.dll", "hwnd", "FindWindowEx", "hwnd", $hWnd[0], "hwnd", 0, "str", "ToolbarWindow32", "ptr", 0) If @error Then Return -1 $ret = $hWnd[0] ElseIf $iWin = 2 Then $hWnd = DllCall("user32.dll", "hwnd", "FindWindow", "str", "NotifyIconOverflowWindow", "ptr", 0) If @error Then Return -1 $hWnd = DllCall("user32.dll", "hwnd", "FindWindowEx", "hwnd", $hWnd[0], "hwnd", 0, "str", "ToolbarWindow32", "ptr", 0) If @error Then Return -1 $ret = $hWnd[0] EndIf Return $ret EndFunc ;==>_FindTrayToolbarWindow #endregion _Systray #endregion Has anybody an idea how to get the position of the tray icon in the taskbar to position the fake traytip appropriately? Added _Systray UDF to get the tray icon position. Br, UEZ
    1 point
  9. acidman

    Autoit Future

    I might not be as informed with programming languages like c, c++, java, visual c# and so forth. I am one of the unlucky folks that does not have access to some bursary or rich parents that would pay for a course in some programming language that would give me extensive knowledge about programming in general. I had to teach my self on how to program/code in a language I knew nothing of at the time.Sure I might feel as if I know a lot of Autoit but I realize more every day that I dont really know that much, I was pressurized when I started to learn autoit to develop a full-blown application. Becuase at the time it was my only method of making a survival becuase I was unemployed at the time. I like autoit, someone once said autoit has as much limits as you want to limit the language to - and I know now that is true, I think Valik made that statement. I like autoit just the way it is and I will most likely never switch to some Other language. But do note I have started learning some intense language like c++ and it has indeed taught me a lot. I know now there is not limit in autoit, it is very strong and can be compared to something like visual c#, Sure the language is still growing but I know for a fact there are a lot of gifted people that is challanging tasks like BUILDING games and many other tasks. 'Autoit I think you are the best thing that has happened to me' I love you!!! And i DO appreciate the fact that there is so much support on this forum...
    1 point
  10. acidman

    Autoit Future

    I think autoitv3 is fine just the way it is, I mean really, there's no need for a v4. Autoit is more than capable of doing for what it was initially designed for and now it's capable of doing so waaaayyyy much more. Besides I really think it's pointless to make it v4 if our scripts can't be backwards compatible, most of us (MOST OF US) actually use autoit for developing applications, so in THEE FUTURE. if there's a v4 and some folks need support for v3 it wouldnt really work to the v3 user's advantage. So if our scripts cant be backwards compatible we have to re-write our apps in v4 code? noooo that will not work, please dont ever make a v4.
    1 point
  11. Devol

    Autoit Future

    I think there`s no need to support non Windows platforms, and I know that many autoit user want to write apps in IOS,Android,etc.. like GuiCreate(),GuiCtrlCreate(),... For me , it would be enough if Windows 8 will be supported, I read that apps are going to be written in HTML & JScript. If Autoit has to be rewritten for supporting Windows 8, I hope that au3/4 will be multi-threaded. citation from the Things NOT on the ToDo List : "It would be far more beneficial to re-write AutoIt and add in multi-threading that way. " Greetz Devol
    1 point
×
×
  • Create New...