
Alek
Active Members-
Posts
323 -
Joined
-
Last visited
Content Type
Forums
Downloads
Forum Articles
Events
Everything posted by Alek
-
StringIsInt should do the job edit: argh, too slow
-
Not sure about enableing/disabeling the checkbox but here is a example (from the help file) of a listview with checkbox #include <GuiListView.au3> Opt('MustDeclareVars', 1) $Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work _Main() Func _Main() Local $exStyles = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES), $hListView GUICreate("ListView Set Item Checked State", 400, 300) $hListView = GUICtrlCreateListView("", 2, 2, 394, 268) _GUICtrlListView_SetExtendedListViewStyle($hListView, $exStyles) GUISetState() ; Add columns _GUICtrlListView_AddColumn($hListView, "Column 1", 100) _GUICtrlListView_AddColumn($hListView, "Column 2", 100) _GUICtrlListView_AddColumn($hListView, "Column 3", 100) ; Add items _GUICtrlListView_AddItem($hListView, "Row 1: Col 1", 0) _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 2", 1) _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 3", 2) _GUICtrlListView_AddItem($hListView, "Row 2: Col 1", 1) _GUICtrlListView_AddSubItem($hListView, 1, "Row 2: Col 2", 1) _GUICtrlListView_AddItem($hListView, "Row 3: Col 1", 2) ; Check item 2 _GUICtrlListView_SetItemChecked($hListView, 1) MsgBox(4160, "Information", "Item 2 Checked: " & _GUICtrlListView_GetItemChecked($hListView, 1)) ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>_Main
-
not sure 100% sure what you are asking for, but something like this?? #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> $Form = GUICreate("Hello", 800, 480, -1, -1, BitOR($WS_SYSMENU, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_THICKFRAME, $WS_CLIPSIBLINGS)) $Listview = GUICtrlCreateListView("Test 1|Test 2|Test 3", 10, 10, 780, 435, -1) GUICtrlSetResizing($Listview, BitOR($GUI_DOCKLEFT, $GUI_DOCKRIGHT, $GUI_DOCKTOP, $GUI_DOCKBOTTOM)) GUIRegisterMsg($WM_SIZE, "WM_SIZE") GUISetState() While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam) Local $width = BitAND($lParam, 0x0000FFFF) - 22 _GUICtrlListView_SetColumnWidth($Listview, 0, $width / 3) _GUICtrlListView_SetColumnWidth($Listview, 1, $width / 3) _GUICtrlListView_SetColumnWidth($Listview, 2, $width / 3) EndFunc
-
you need to register the WM_PAINT event #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Gdiplus.au3> _GDIPlus_Startup() $Form = GUICreate("Hello world", 400, 400) GUISetState() $Main_Graphics = _GDIPlus_GraphicsCreateFromHWND($Form) _GDIPlus_GraphicsDrawLine($Main_Graphics, 0, 200, 400, 200) GUIRegisterMsg($WM_PAINT, "WM_PAINT") While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd _GDIPlus_GraphicsDispose($Main_Graphics) _GDIPlus_Shutdown() Func WM_PAINT($hWnd, $nMsg, $wParam, $lParam) _GDIPlus_GraphicsDrawLine($Main_Graphics, 0, 200, 400, 200) EndFunc
-
hmm, thats weird it uses 11% cpu on my system but changing it from mouseclick to mousedown mouseup uses < 1% While True Sleep(15) MouseDown("Left") MouseUp("Left") WEnd Edit: its due to MouseClickDelay and MouseClickDownDelay, changing them to 0 or 15+ makes the cpu usage drop.
-
Was diging trough some old scrips and I found my old multi-process lan scanner and I thought it would be a nice script for the example forum How it works: the main script runs another script with a few parameters (IP and main scripts form handle) and the other script executes the ping command and uses SendMessage to send the result back to the main script. Orignaly the main script just re-ran it self with the same parameters but it was to much of a cpu and memory hog so I had to create a seperate script for the pinging. so here it is main script. #include <iNet.au3> #Include <GuiListView.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Include <GuiStatusBar.au3> Global $ProcLimit = RegRead("HKEY_CURRENT_USER\Software\LanScanner\Settings","ProcessLimit") Global $UseExternalPinger = False If $ProcLimit = 0 Then $ProcLimit = 20 EndIf #Region RealPing.au3 #Include <SendMessage.au3> #NoTrayIcon Global $PingTimeout = RegRead("HKEY_CURRENT_USER\Software\LanScanner\Settings","PingTimeout") If $PingTimeout = 0 Then $PingTimeout = 1000 EndIf If $Cmdline[0] = 2 Then $ping = Ping($Cmdline[1], $PingTimeout) If $ping = 0 Then _SendMessage($Cmdline[2], 0x0F01) Else _SendMessage($Cmdline[2], 0x0F00, _IpToHex($Cmdline[1]), String($ping)) EndIf Exit EndIf Func _IpToHex($Ip) Local $array = StringSplit($Ip, ".") Return "0x" & Hex($array[1], 2) & Hex($array[2], 2) & Hex($array[3], 2) & Hex($array[4], 2) EndFunc #EndRegion TCPStartup() Global $RunTimer = 0 $Form = GUICreate("Lan scanner", 470, 175) $Menu_File = GUICtrlCreateMenu("&File") $Menu_Exit = GUICtrlCreateMenuItem("&Exit", $Menu_File) $Menu_Tools = GUICtrlCreateMenu("&Tools") $Menu_Settings = GUICtrlCreateMenuItem("&Settings", $Menu_Tools) $ListView =_GUICtrlListView_Create($Form, "IP|Name|Ping", 10, 10, 290, 115) _GUICtrlListView_SetExtendedListViewStyle($ListView, BitOR($LVS_EX_FULLROWSELECT,$LVS_EX_DOUBLEBUFFER, $LVS_EX_GRIDLINES)) GUICtrlCreateLabel("Start IP:", 310, 13) $Input1 = GUICtrlCreateInput(@IPAddress1, 360, 10, 100) GUICtrlCreateLabel("End IP:", 310, 43) $Input2 = GUICtrlCreateInput(@IPAddress1, 360, 40, 100) $Button1 = GUICtrlCreateButton("Start", 310, 70, 150, 25) $Progress1 = GUICtrlCreateProgress(4, 0, -1, -1) _GUICtrlListView_SetColumnWidth($Listview, 0, 100) _GUICtrlListView_SetColumnWidth($Listview, 1, 150) _GUICtrlListView_SetColumnWidth($Listview, 2, 40) $StatusBar = _GUICtrlStatusBar_Create($Form) Dim $StatusBar_Parts[4] = [150, 250, 370, -1] _GUICtrlStatusBar_SetParts ($StatusBar, $StatusBar_Parts) _GUICtrlStatusBar_SetText($StatusBar, "Running Process: 0") _GUICtrlStatusBar_SetText($StatusBar, "IP: ", 1) _GUICtrlStatusBar_EmbedControl($StatusBar, 3, GUICtrlGetHandle($Progress1)) GUIRegisterMsg(0x0F00, "_PingSucess") GUIRegisterMsg(0x0F01, "_PingDone") GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState() $Form2 = GUICreate("Settings", 400, 190) $Label1 = GUICtrlCreateLabel("Number of active processes at one time: " & $ProcLimit, 10, 10,380, 20) $Slider1 = GUICtrlCreateSlider(10, 30, 380, 40) GUICtrlSetLimit($Slider1, 40, 0) GUICtrlSetData($Slider1, $ProcLimit / 5) $Label2 = GUICtrlCreateLabel("Ping Timeout in milliseconds: 4000", 10, 80,380, 20) $Slider2 = GUICtrlCreateSlider(10, 100, 380, 40) GUICtrlSetLimit($Slider2, 100, 1) GUICtrlSetData($Slider2, $PingTimeout / 50) $Button2 = GUICtrlCreateButton("Apply", 280, 155, 50, 25) $Button3 = GUICtrlCreateButton("Close", 340, 155, 50, 25) GUISetState(@SW_HIDE) Global $ip = 0 Dim $ProcCount = 0 Dim $Run = False Dim $SliderData1 = $ProcLimit Dim $SliderData2 = $PingTimeout While True $Msg = GUIGetMsg(1) Switch $Msg[1] Case $Form Switch $Msg[0] Case $GUI_EVENT_CLOSE, $Menu_Exit Exit Case $Button1 If $ip = 0 Then _GUICtrlListView_DeleteAllItems($Listview) $ip = GUICtrlRead($Input1) GUICtrlSetState($Input1, $GUI_DISABLE) GUICtrlSetState($Input2, $GUI_DISABLE) GUICtrlSetData($Button1, "Stop") $Run = True $RunTimer = TimerInit() Else $ip = 0 GUICtrlSetState($Input1, $GUI_ENABLE) GUICtrlSetState($Input2, $GUI_ENABLE) GUICtrlSetData($Button1, "Start") GUICtrlSetData($Progress1, 0) $Run = False EndIf Case $Menu_Settings GUISetState(@SW_SHOW, $Form2) Case Else If $Msg[0] > 0 Then ConsoleWrite($Msg[0] & @CRLF) EndSwitch Case $Form2 Switch $Msg[0] Case $GUI_EVENT_CLOSE, $Button3 GUISetState(@SW_HIDE, $Form2) Case $Button2 If GUICtrlRead($Slider1) = 0 Then RegWrite("HKEY_CURRENT_USER\Software\LanScanner\Settings","ProcessLimit", "REG_DWORD", 1) $ProcLimit = 1 Else RegWrite("HKEY_CURRENT_USER\Software\LanScanner\Settings","ProcessLimit", "REG_DWORD", GUICtrlRead($Slider1) * 5) $ProcLimit = GUICtrlRead($Slider1) * 5 EndIf RegWrite("HKEY_CURRENT_USER\Software\LanScanner\Settings","PingTimeout", "REG_DWORD", GUICtrlRead($Slider2) * 50) GUISetState(@SW_HIDE, $Form2) Case $Slider1 If GUICtrlRead($Slider1) = 0 Then GUICtrlSetData($Label1, "Number of active processes at one time: 1") Else GUICtrlSetData($Label1, "Number of active processes at one time: " & GUICtrlRead($Slider1) * 5) EndIf EndSwitch EndSwitch If $SliderData1 <> GUICtrlRead($Slider1) Then $SliderData1 = GUICtrlRead($Slider1) If GUICtrlRead($Slider1) = 0 Then GUICtrlSetData($Label1, "Number of active processes at one time: 1") Else GUICtrlSetData($Label1, "Number of active processes at one time: " & GUICtrlRead($Slider1) * 5) EndIf EndIf If $SliderData2 <> GUICtrlRead($Slider2) Then $SliderData2 = GUICtrlRead($Slider2) GUICtrlSetData($Label2,"Ping Timeout in milliseconds: " & GUICtrlRead($Slider2) * 50) EndIf If Not $Run Or $ProcCount >= $ProcLimit Then ContinueLoop If $UseExternalPinger Then ;We get signicent effincy by running a external script rather then re-running this 1. If @Compiled Then $Pid = Run("RealPing.exe" & " " & $ip & " " & $Form, @WorkingDir) Else $Pid = Run(@AutoItExe & ' "' & @ScriptDir & "\RealPing.au3" & '" ' & $ip & " " & $Form, @WorkingDir) EndIf Else If @Compiled Then $Pid = Run(@AutoItExe & " " & $ip & " " & $Form, @WorkingDir) Else $Pid = Run(@AutoItExe & ' "' & @ScriptFullPath & '" ' & $ip & " " & $Form, @WorkingDir) EndIf EndIf If $Pid <> 0 Then ;ProcessSetPriority($Pid, 0) EndIf _GUICtrlStatusBar_SetText($StatusBar, "IP: " & $ip, 1) _GUICtrlStatusBar_SetText($StatusBar, _MsToTime(TimerDiff($RunTimer)), 2) $ProcCount += 1 GUICtrlSetData($Progress1, _IPGetPercentDiff($ip, GUICtrlRead($Input2))) If _IpGetNext($ip, GUICtrlRead($Input1), GUICtrlRead($Input2)) = 1 Then $ip = 0 GUICtrlSetState($Input1, $GUI_ENABLE) GUICtrlSetState($Input2, $GUI_ENABLE) GUICtrlSetData($Button1, "Start") $Run = False EndIf _GUICtrlStatusBar_SetText($StatusBar, "Running Process: " & $ProcCount & " / " & $ProcLimit) WEnd Func _PingSucess($hWnd, $Msg, $wParam, $lParam) Local $index = _GUICtrlListView_AddItem($Listview, _HexToIp($wParam), 0) _GUICtrlListView_AddSubItem($Listview, $index, _TCPIpToName(_HexToIp($wParam)), 1) _GUICtrlListView_AddSubItem($Listview, $index, Int("0x" & Hex($lParam)), 2) $ProcCount -= 1 _GUICtrlStatusBar_SetText($StatusBar, "Running Process: " & $ProcCount & " / " & $ProcLimit) EndFunc Func _PingDone($hWnd, $Msg, $wParam, $lParam) $ProcCount -= 1 _GUICtrlStatusBar_SetText($StatusBar, "Running Process: " & $ProcCount & " / " & $ProcLimit) EndFunc Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iCode, $tNMHDR, $hWndListView $hWndListView = $ListView If Not IsHWnd($ListView) Then $WndListView = GUICtrlGetHandle($ListView) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) $Index = DllStructGetData($tInfo, "Index") $subitemNR = DllStructGetData($tInfo, "SubItem") ; make sure user clicks on the listview & only the activate If $Index <> -1 Then ; col1 ITem index $item = StringSplit(_GUICtrlListView_GetItemTextString($ListView, $Index),'|') $item = $item[1] $ping = Ping($item, 1000) If $ping = 0 Then Switch @error Case 1 _GUICtrlListView_SetItemText($Listview, $Index, "Off", 2) Case 2 _GUICtrlListView_SetItemText($Listview, $Index, "Non", 2) Case 3 _GUICtrlListView_SetItemText($Listview, $Index, "Bad", 2) Case 4 _GUICtrlListView_SetItemText($Listview, $Index, "Err", 2) EndSwitch Else _GUICtrlListView_SetItemText($Listview, $Index, $ping, 2) EndIf EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func _HexToIp($Hex) Local $array = StringSplit($Hex, "") If StringLeft($Hex, 2) = "0x" Then Return Int("0x" & $array[3] & $array[4]) & "." & Int("0x" & $array[5] & $array[6]) & "." & Int("0x" & $array[7] & $array[8]) & "." & Int("0x" & $array[9] & $array[10]) Else Return Int("0x" & $array[1] & $array[2]) & "." & Int("0x" & $array[3] & $array[4]) & "." & Int("0x" & $array[5] & $array[6]) & "." & Int("0x" & $array[7] & $array[8]) EndIf EndFunc Func _IpGetDiff($ip1, $ip2) Local $ret[4] If _IpGetValue($ip1) > _IpGetValue($ip2) Then Return $ret EndIf Local $array1 = StringSplit($ip1, ".") Local $array2 = StringSplit($ip2, ".") $ret[0] = $array2[1] - $array1[1] $ret[1] = $array2[2] - $array1[2] $ret[2] = $array2[3] - $array1[3] $ret[3] = $array2[4] - $array1[4] Return $ret EndFunc Func _IpGetNext(ByRef $ip, $ip1, $ip2) Local $array = _IpGetDiff($ip, $ip2) Local $iparray = _IpGetDiff("0.0.0.0", $ip) Local $iparray1 = _IpGetDiff("0.0.0.0", $ip1) If $array[3] = 0 Then If $array[2] = 0 Then If $array[1] = 0 Then If $array[0] = 0 Then Return 1 Else $iparray[0] += 1 $iparray[1] = $iparray1[1] $iparray[2] = $iparray1[2] $iparray[3] = $iparray1[3] EndIf Else $iparray[1] += 1 $iparray[2] = $iparray1[2] $iparray[3] = $iparray1[3] EndIf Else $iparray[2] += 1 $iparray[3] = $iparray1[3] EndIf Else $iparray[3] += 1 EndIf $ip = $iparray[0] & "." & $iparray[1] & "." & $iparray[2] & "." & $iparray[3] Return 0 EndFunc Func _IpGetValue($ip) Local $array = StringSplit($Ip, ".") Return $array[1] + $array[2] + $array[3] + $array[4] EndFunc Func _IPGetPercentDiff($ip, $ip2) Local $array = StringSplit($ip, ".") Local $array2 = StringSplit($ip2, ".") $array[4] = ($array[4] + 1) / ($array2[4] + 1) $array[3] = ($array[3] + 1) / ($array2[3] + 1) $array[2] = ($array[2] + 1) / ($array2[2] + 1) $array[1] = ($array[1] + 1) / ($array2[1] + 1) Return $array[4] * $array[3] * $array[2] * $array[1] * 100 EndFunc Func _Swap(ByRef $1, ByRef $2) Local $tmp = $2 $2 = $1 $1 = $tmp EndFunc Func _HwndToInt($hWnd) Return Int("0x" & Hex($hWnd)) EndFunc Func _MsToTime($ms) Local $sec = Floor($ms / 1000) Local $hour = Floor($sec / 3600) $sec -= $hour * 3600 Local $min = Floor($sec / 60) $sec-= $min * 60 Return StringFormat("%02d:%02d:%02d", $hour, $min, $sec) EndFunc Real Pinger.au3 #Include <SendMessage.au3> #NoTrayIcon Global $PingTimeout = RegRead("HKEY_CURRENT_USER\Software\LanScanner\Settings","PingTimeout") If $PingTimeout = 0 Then $PingTimeout = 1000 EndIf If $Cmdline[0] = 2 Then $ping = Ping($Cmdline[1], $PingTimeout) If $ping = 0 Then _SendMessage($Cmdline[2], 0x0F01) Else _SendMessage($Cmdline[2], 0x0F00, _IpToHex($Cmdline[1]), String($ping)) EndIf Exit EndIf Func _IpToHex($Ip) Local $array = StringSplit($Ip, ".") Return "0x" & Hex($array[1], 2) & Hex($array[2], 2) & Hex($array[3], 2) & Hex($array[4], 2) EndFunc
-
I'm guessing the adll files are stringtobinary (encrypted??) autoitscript which are called using execute. The only part of this that I find usfull is that you can update the adll file rather then the entire exe. other then that, why not just use #include??
-
I usally use if ubound($Array) < $Expected_Array_Size then ;Handle array error endif PS: "Line 12734" Holy crap!!!!
-
I...I...I...don't know what to say...
-
math for changing a range of numbers?
Alek replied to SystemWontAccept's topic in AutoIt General Help and Support
Something like this? -
wouldn't #NoTrayIcon #include <ScreenCapture.au3> $Pos = WinGetPos("Program Manager") If $CmdLine[0] = 1 Then _ScreenCapture_Capture($CmdLine[1], $Pos[0], $Pos[1], $Pos[0] + $Pos[2], $Pos[1] + $Pos[3]) Else _ScreenCapture_Capture(@ScriptDir & "\screenshot.jpg", $Pos[0], $Pos[1], $Pos[0] + $Pos[2], $Pos[1] + $Pos[3]) EndIfwork just as well?
-
Might want to try with timer, it would make the resizing much more constant. Example a similar function I made a while back. Func WindowGlide($hwnd, $text, $x, $y, $width, $height, $time = 200) Local $OrgPos = WinGetPos($hwnd, $text) If @error Then Return SetError(1, 0, 0) EndIf Local $NewPos[4] Local $timer = TimerInit() Local $percent_done = 0 While TimerDiff($timer) < $time Sleep(10) $percent_done = TimerDiff($timer) / $time $NewPos[0] = $OrgPos[0] + ($x - $OrgPos[0]) * $percent_done $NewPos[1] = $OrgPos[1] + ($y - $OrgPos[1]) * $percent_done $NewPos[2] = $OrgPos[2] + ($width - $OrgPos[2]) * $percent_done $NewPos[3] = $OrgPos[3] + ($height - $OrgPos[3]) * $percent_done WinMove($hwnd, $text, $NewPos[0], $NewPos[1], $NewPos[2], $NewPos[3]) WEnd WinMove($hwnd, $text, $x, $y, $width, $height) Return 1 EndFunc
-
Bin working on some bezier UDFs, wanted to be able to get coords along a bezier curve. here is a example of what i came up with. just click around on the GUI and see what happens #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <WinApi.au3> Opt("GUIOnEventMode", 1) ; Create GUI $hGUI = GUICreate("GDI+", 800, 600, -1, -1, $WS_SIZEBOX) ; Draw a cardinal spline _GDIPlus_Startup () $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hGUI) $BackBuffer = _GDIPlus_BitmapCreateFromGraphics(400, 300, $hGraphic) $MainGraphic = _GDIPlus_ImageGetGraphicsContext($BackBuffer) _GDIPlus_GraphicsClear($MainGraphic, 0xFFFFFFFF) _GDIPlus_GraphicsSetSmoothingMode($MainGraphic, 2) Global $Bezier Global $MovePoint = -1 GUIRegisterMsg($WM_SIZE, "WM_SIZE") GUISetOnEvent($GUI_EVENT_MOUSEMOVE, "GUI_EVENT_MOUSEMOVE") GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "GUI_EVENT_PRIMARYDOWN") GUISetOnEvent($GUI_EVENT_PRIMARYUP, "GUI_EVENT_PRIMARYUP") GUISetOnEvent($GUI_EVENT_CLOSE, "GUI_EVENT_CLOSE") GUISetState() While True Sleep(10) _Draw() WEnd Func GUI_EVENT_MOUSEMOVE() Local $ginfo = GUIGetCursorInfo() If $MovePoint > -1 Then _Bezier_SetControlPoint($Bezier, $MovePoint, $ginfo) EndIf EndFunc Func GUI_EVENT_PRIMARYDOWN() Local $ginfo = GUIGetCursorInfo() If UBound($Bezier) = 0 Then Local $point[2] $point[0] = $ginfo[0] $point[1] = $ginfo[1] $Bezier = _Bezier_Create($point) Return EndIf For $t = 0 To _Bezier_GetPointCount($Bezier) $P = _Bezier_GetControlPoint($Bezier, $t) If _InRange($ginfo, $P, 3) Then $MovePoint = $t Return EndIf Next $MovePoint = _Bezier_AddControlPoint($Bezier, $ginfo) EndFunc Func GUI_EVENT_PRIMARYUP() $MovePoint = -1 EndFunc Func GUI_EVENT_CLOSE() _GDIPlus_GraphicsDispose ($hGraphic) _GDIPlus_Shutdown () Exit EndFunc Func _InRect($point, $rectp1, $rectp2) If $point[0] > $rectp1[0] And $point[0] < $rectp2[0] And $point[1] > $rectp1[1] And $point[1] < $rectp2[1] Then Return True EndIf Return False EndFunc Func _InRange($point1, $point2, $range) If Sqrt(($point1[0] - $point2[0])^2 + ($point1[1] - $point2[1])^2) < $range Then Return True EndIf Return False EndFunc Func _Draw() Local $timer = TimerInit() _GDIPlus_GraphicsClear($MainGraphic, 0xFFFFFFFF) If UBound($Bezier) <> 0 Then _Bezier_Draw($MainGraphic, $Bezier, 40) EndIf _GDIPlus_GraphicsDrawImage($hGraphic, $BackBuffer, 0, 0) WinSetTitle($hGUI, "", "FPS: " & Round(1000 / TimerDiff($timer), 2)) EndFunc Func WM_SIZE($hWnd, $Msg, $wParam, $lParam) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_GraphicsDispose ($BackBuffer) _GDIPlus_BitmapDispose($BackBuffer) $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hGUI) ConsoleWrite($lParam & @CRLF) $BackBuffer = _GDIPlus_BitmapCreateFromGraphics(_WinAPI_LoWord($lParam), _WinAPI_HiWord($lParam), $hGraphic) $MainGraphic = _GDIPlus_ImageGetGraphicsContext($BackBuffer) _GDIPlus_GraphicsSetSmoothingMode($MainGraphic, 2) _Draw() EndFunc Func _Bezier_Draw($Graphics, $B, $subdivid = 25) Local $oldPoint = _Bezier_GetPoint($B, 0) Local $point For $x = 0 To 1 Step 1/$subdivid $point = _Bezier_GetPoint($B, $x) _GDIPlus_GraphicsDrawLine($Graphics, $oldPoint[0], $oldPoint[1], $point[0], $point[1]) $oldPoint = $point Next $point = _Bezier_GetPoint($B, 1) _GDIPlus_GraphicsDrawLine($Graphics, $oldPoint[0], $oldPoint[1], $point[0], $point[1]) Local $pen = _GDIPlus_PenCreate() _GDIPlus_PenSetDashStyle($pen, $GDIP_DASHSTYLEDASH) ;_GDIPlus_GraphicsDrawLine($Graphics, $B[0][0], $B[0][1], $B[1][0], $B[1][1], $pen) ;_GDIPlus_GraphicsDrawLine($Graphics, $B[2][0], $B[2][1], $B[3][0], $B[3][1], $pen) Local $oldPoint = _Bezier_GetControlPoint($B, 0) Local $point For $x = 0 To UBound($B) - 1 $point = _Bezier_GetControlPoint($B, $x) _GDIPlus_GraphicsDrawLine($Graphics, $oldPoint[0], $oldPoint[1], $point[0], $point[1], $pen) $oldPoint = $point _GDIPlus_GraphicsFillEllipse($Graphics, $B[$x][0] - 3, $B[$x][1] - 3, 6, 6) Next EndFunc #cs This is where the real bezier UDF start #ce Func _Bezier_GetPoint($B, $t) Local $n = UBound($B) - 1 For $k = 1 To $n For $i = 0 To $n - $k $B[$i][0] = (1 - $t) * $B[$i][0] + $t * $B[$i + 1][0] $B[$i][1] = (1 - $t) * $B[$i][1] + $t * $B[$i + 1][1] Next Next Local $ret[2] $ret[0] = $B[0][0] $ret[1] = $B[0][1] Return $ret EndFunc Func _Bezier_Create($points) If Mod(UBound($points), 2) <> 0 Then Return SetError(1, 0, -1) EndIf Local $B[UBound($points) / 2][2] For $x = 0 To UBound($B) - 1 $B[$x][0] = $points[$x * 2] $B[$x][1] = $points[($x * 2) + 1] Next Return $B EndFunc Func _Bezier_GetPointCount($B) Return UBound($B) - 1 EndFunc Func _Bezier_GetControlPoint($B, $point) If $point > UBound($B) - 1 Then Return SetError(1, 0, -1) EndIf Local $ret[2] $ret[0] = $B[$point][0] $ret[1] = $B[$point][1] Return $ret EndFunc Func _Bezier_SetControlPoint(ByRef $B, $point, $newpoint) If $point > UBound($B) - 1 Then Return SetError(1, 0, -1) EndIf $B[$point][0] = $newpoint[0] $B[$point][1] = $newpoint[1] Return $B EndFunc Func _Bezier_AddControlPoint(ByRef $B, $point) ReDim $B[UBound($B) + 1][UBound($B, 2)] $B[UBound($B) - 1][0] = $point[0] $B[UBound($B) - 1][1] = $point[1] Return UBound($B) - 1 EndFunc
-
comment out ControlHide($TaskbarHwnd, "", 304), but why?
-
hmm, it should do that if you close it from the system tray (next to the clock).
-
any reason not to use _GDIPlus_GraphicsMeasureString?
-
Autoit version of ViOrb. incase you dont know what ViOrb is: http://www.lee-soft.com/viorb/ Please report back any problems you may have. #NoTrayIcon #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_outfile=AOrb.exe #AutoIt3Wrapper_Compression=4 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GDIPlus.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> #Include <Misc.au3> #Include <GuiMenu.au3> #include <SendMessage.au3> If $Cmdline[0] Then _SendMessage($Cmdline[1],$WM_CLOSE) EndIf _Singleton("AutoitViOrbScript") Opt("WinTitleMatchMode", 4) Opt("OnExitFunc","OrbExit") ;To avoid trouble :) ;pt("TrayIconHide", 0) ;Settings Global Const $ORB_TRANSPARENCY = 240 ;Stuff Global Const $AC_SRC_ALPHA = 1 _GDIPlus_Startup() Global $TaskBarHwnd = WinGetHandle("[CLASS:Shell_TrayWnd]") Global $StartMenuHwnd = WinGetHandle("[CLASS:DV2ControlHost]") Global $Bitmap_Hwnd = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\flag.png") Global $OrbSize[2] = [_GDIPlus_ImageGetWidth($Bitmap_Hwnd), Floor(_GDIPlus_ImageGetHeight($Bitmap_Hwnd) / 3)] Global $Button_Normal = _GDIPlus_BitmapCloneArea($Bitmap_Hwnd, 0, $OrbSize[1] * 0, $OrbSize[0], $OrbSize[1],$GDIP_PXF32ARGB) Global $Button_Hover = _GDIPlus_BitmapCloneArea($Bitmap_Hwnd, 0, $OrbSize[1] * 1, $OrbSize[0], $OrbSize[1], $GDIP_PXF32ARGB) Global $Button_Push = _GDIPlus_BitmapCloneArea($Bitmap_Hwnd, 0, $OrbSize[1] * 2, $OrbSize[0], $OrbSize[1], $GDIP_PXF32ARGB) Global $OrbPos = _GetOptimalOrbPos() Global $Gui = GUICreate("", $OrbSize[0], $OrbSize[1], $OrbPos[0], $OrbPos[1], 0x80000000, $WS_EX_LAYERED + $WS_EX_TOOLWINDOW, $TaskBarHwnd) RegWrite("HKCR\Directory\Shell\AOrb\", "","REG_SZ", "Exit AOrb") If @Compiled Then RegWrite("HKCR\Directory\Shell\AOrb\Command", "","REG_SZ",'"' & @ScriptFullPath & '" ' & $Gui) Else RegWrite("HKCR\Directory\Shell\AOrb\Command", "","REG_SZ", '"' & @AutoItExe & '" "' & @ScriptFullPath & '" ' & $Gui) EndIf SetBitmap($Gui, $Button_Normal, $ORB_TRANSPARENCY) GUISetState() ControlHide($TaskBarHwnd, "", 304) Global $State = 0 While 1 Sleep(10) ;This is to prevent the app from crashing if "explorer" crash (taskbar disappear) ;It will reinstate the orb once the taskbar appears again If Not BitAND(WinGetState("[CLASS:Shell_TrayWnd]"), 2) And $TaskBarHwnd <> 0 Then ;clear out all the old data from previus taskbar session. $TaskBarHwnd = 0 $StartMenuHwnd = 0 If $Gui <> 0 Then GUIDelete($Gui) $Gui = 0 EndIf ContinueLoop ElseIf $TaskBarHwnd = 0 And BitAND(WinGetState("[CLASS:Shell_TrayWnd]"), 2) Then ;It appears that a new taskbar have merged. $TaskBarHwnd = WinGetHandle("[CLASS:Shell_TrayWnd]") $StartMenuHwnd = WinGetHandle("[CLASS:DV2ControlHost]") ;time to reinstate the orb. $Gui = GUICreate("", 44, 44, $OrbPos[0], $OrbPos[1], 0x80000000, $WS_EX_LAYERED + $WS_EX_TOOLWINDOW, $TaskBarHwnd) $Label = GUICtrlCreateLabel("",0,0,44,44) SetBitmap($Gui, $Button_Normal, $ORB_TRANSPARENCY) If @Compiled Then RegWrite("HKCR\Directory\Shell\AOrb\Command", "","REG_SZ",'"' & @ScriptFullPath & '" ' & $Gui) Else RegWrite("HKCR\Directory\Shell\AOrb\Command", "","REG_SZ", '"' & @AutoItExe & '" "' & @ScriptFullPath & '" ' & $Gui) EndIf ;And hide the old start button. ControlHide($TaskBarHwnd, "", 304) ;Befor showing the orb GUISetState() ElseIf $TaskBarHwnd = 0 Then ;Opps, no taskbar was found, time to start all over again in this loop. ContinueLoop EndIf ;Update orb location in case the taskbar have bin resized/moved $pos = _GetOptimalOrbPos() If $pos[0] <> $OrbPos[0] Or $pos[1] <> $OrbPos[1] Then WinMove($Gui, "", $pos[0], $pos[1]) $OrbPos = $pos EndIf $Msg = GUIGetMsg() $Info = GUIGetCursorInfo($Gui) If $Msg = $GUI_EVENT_CLOSE Then ;Should come from startbutton context menu Exit EndIf If $Info[0] > 0 And $Info[1] > 0 And $Info[0] < $OrbSize[0] And $Info[1] < $OrbSize[1] Then ;Manage events that can happen when cursor is over the button. If $Msg = -7 Then ;set the bitmap to "pushed" orb SetBitmap($Gui, $Button_Push, $ORB_TRANSPARENCY) ;Kinda hack fix, but seems better then expected :) ControlClick($TaskBarHwnd, "", 304) $State = 2 ElseIf $Msg = -9 Then ;Make the "right click" event happen at the correct location so that the menu appears at the correct location like it was the real deal. $taskpos = WinGetPos($TaskBarHwnd) ControlClick($TaskBarHwnd, "", 304, "Right", 1, $OrbPos[0] - $taskpos[0] + $Info[0], $OrbPos[1] - $taskpos[1] + $Info[1]) $State = 3 ElseIf $State <> 1 And Not $Info[2] And Not $Info[3] And BitAND(WinGetState($StartMenuHwnd), 2) = 0 Then ;set the bitmap to "hover over" orb SetBitmap($Gui, $Button_Hover, $ORB_TRANSPARENCY) $State = 1 EndIf ElseIf $State <> 0 And BitAND(WinGetState($StartMenuHwnd), 2) = 0 Then ;"no state" state (default) SetBitmap($Gui, $Button_Normal, $ORB_TRANSPARENCY) $State = 0 ElseIf $State <> 2 And BitAND(WinGetState($StartMenuHwnd), 2) Then ;This usally happens when the user push the window key. SetBitmap($Gui, $Button_Push, $ORB_TRANSPARENCY) $State = 2 EndIf WEnd Func _GetOptimalOrbPos() ;Get the location of the windows taskbar and stuff. Local $taskpos = WinGetPos($TaskBarHwnd) Local $buttonpos = ControlGetPos($TaskBarHwnd, "", 304) Local $retpos[2] If @error Then ;might cause a small hickup but it will prevent the app from cashing. Return $retpos EndIf ;check if its vertical or horizontal If $taskpos[2] > $taskpos[3] Then $retpos[0] = $taskpos[0] + ($buttonpos[0] + (($buttonpos[2] / 2) - ($OrbSize[0] / 2))) $retpos[1] = $taskpos[1] + (($taskpos[3]/2) - ($OrbSize[1] / 2)) + 1 ; + 1 makes it look more correct I think ElseIf $taskpos[3] > $taskpos[2] Then $retpos[1] = $taskpos[1] + ($buttonpos[1] + (($buttonpos[3] / 2) - ($OrbSize[1] / 2))) $retpos[0] = $taskpos[0] + (($taskpos[2]/2) - ($OrbSize[0] / 2)) + 1 ; + 1 makes it look more correct I think EndIf Return $retpos EndFunc Func OrbExit() ;Dispose all the bitmaps _GDIPlus_BitmapDispose($Button_Normal) _GDIPlus_BitmapDispose($Button_Hover) _GDIPlus_BitmapDispose($Button_Push) _GDIPlus_BitmapDispose($Bitmap_Hwnd) ;Show the original start menu ControlShow($TaskBarHwnd, "", 304) RegDelete("HKCR\Directory\Shell\AOrb\") EndFunc ;Yay to autoit examples ^^ 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 Edit: opps, forgot to include a skin Edit again: added a few tweeks, like: -Adds Exit AOrb option to the context menu, this should safely shut down the orb (anyone got any ideas how i can make the "Exit AOrb" appear at the botto of the startbutton context menu?) - Somewhat better way of managing states of the orb. -Smarter orb location calcluations. (should make the skin image size independt with some limits thou)
-
Send($Password,1) Send("{ENTER}",0)
-
Using winapi memory reading only works in xp (or less maybe) #include <Winapi.au3> Global Const $DataPtr = 0x1005330 Global Const $MinesPtr = 0x1005340 Global $MineSweeper_PID = Run("winmine.exe") ;run it Global $hProcess = _WinAPI_OpenProcess(0x1F0FFF, 1, $MineSweeper_PID, True) ;open it dim $read WinWait("Minesweeper") ;wait for the minesweeper to load. $DataStruct = DllStructCreate("dword mines;dword width;dword height") _WinAPI_ReadProcessMemory($hProcess, $DataPtr, DllStructGetPtr($DataStruct), DllStructGetSize($DataStruct), $read) ;Get widht, height and number of mines :) ConsoleWrite(DllStructGetData($DataStruct, "mines") & " Mines in a " & DllStructGetData($DataStruct, "width") & " by " & DllStructGetData($DataStruct, "height") & " grid " & @CRLF) WinActivate("Minesweeper") $Width = DllStructGetData($DataStruct, "width") - 1 $Height = DllStructGetData($DataStruct, "height") - 1 For $y = 0 To $Height For $x = 0 To $Width Switch _IsMine($x,$y) Case -1 ;Already open ContinueLoop Case 0 ;Safe to click on ControlClick("Minesweeper", "", "", "left", 1, 20 + ($x *16),(16 * $y) + 60) Case 1 ;MINE!!!! ControlClick("Minesweeper", "", "", "right", 1, 20 + ($x *16),(16 * $y) + 60) EndSwitch ;Sleep(25) ;Looks cool :P Next Next Func _IsMine($x, $y) $buffer = DllStructCreate("ubyte mine") _WinAPI_ReadProcessMemory($hProcess, $MinesPtr + (32 * ($y + 1)) + ($x + 1) , DllStructGetPtr($buffer), DllStructGetSize($buffer), $read) If DllStructGetData($buffer, "mine") = 0x40 Then Return -1 ElseIf DllStructGetData($buffer, "mine") = 0x0F Then Return 0 ElseIf DllStructGetData($buffer, "mine") = 0x8f Then Return 1 EndIf EndFunc
-
#NoTrayIcon HotKeySet("{Esc}","_Exit") $Desktop_Area = WinGetPos("Program Manager") If $Desktop_Area[0] < 0 Then $Desktop_Area[2] -= Abs($Desktop_Area[0]) EndIf If $Desktop_Area[1] < 0 Then $Desktop_Area[3] -= Abs($Desktop_Area[1]) EndIf While 1 Sleep(10) $Mgp = MouseGetPos() If $Mgp[0] > $Desktop_Area[2] - 2 Then MouseMove ($Desktop_Area[0] + 2, $Mgp[1], '') ElseIf $Mgp[0] < $Desktop_Area[0] + 2 Then MouseMove ($Desktop_Area[2] - 2, $Mgp[1], '') EndIf If $Mgp[1] > $Desktop_Area[3] - 2 Then MouseMove ($Mgp[0], $Desktop_Area[1] + 2, '') ElseIf $Mgp[1] < $Desktop_Area[1] + 2 Then MouseMove ($Mgp[0], $Desktop_Area[3] - 2, '') EndIf WEnd Func _Exit() Exit EndFunc should work with multiple monitors.
-
Rotation problems: Howto calculate shortest way?
Alek replied to zutto's topic in AutoIt General Help and Support
some old function I used once for this, not sure if it works or not. It returns an array, where [0] is direction and [1] is angle difference. [0] can be 1 or -1 (-1 for left and 1 for right I think) Func _Between($s_Next_Rot, $s_Cur_Rot) Local $Array[2] If $s_Cur_Rot > $s_Next_Rot Then If ($s_Cur_Rot - $s_Next_Rot) < 181 Then $Array[0] = 1 $Array[1] = $s_Cur_Rot - $s_Next_Rot Else $Array[0] = -1 $Array[1] = (($s_Next_Rot + 360) - $s_Cur_Rot) EndIf Else If ($s_Next_Rot - $s_Cur_Rot) < 181 Then $Array[0] = -1 $Array[1] = $s_Next_Rot - $s_Cur_Rot Else $Array[0] = 1 $Array[1] = (($s_Cur_Rot + 360) - $s_Next_Rot) EndIf EndIf Return $Array EndFunc -
pretty good replacement. I had 1 problem, quick fix was to comment out _WinAPI_DestroyIcon($hIcon) in the _display_icon for it to work,error said "_Winapi_DestroyIcon: Cannot destroy object created by another thread." also would be cool if you could add blur background instead of a black one when on vista/7. Edit: Realtime update works great when aero is disabled, and if aero is enable there is a function for getting the window thumbnail.
-
new version out added GUI (not 100% done yet)
-
When a GUI is made it will probably include allot of settings that allows you to tweak the compression to suit your needs. you could get a smaller file by changing FPS, bitrate, codec etc.