Revolter Posted January 17, 2012 Share Posted January 17, 2012 (edited) I have this small script: expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstants.au3> #include <GUIConstantsEx.au3> #include <NoFocusLines.au3> #include <ScreenCapture.au3> #include <SliderConstants.au3> #include <Misc.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Opt( "GUIOnEventMode" , 1 ) HotKeySet( "{UP}" , "_Up" ) HotKeySet( "{DOWN}" , "_Down" ) HotKeySet( "{LEFT}" , "_Left" ) HotKeySet( "{RIGHT}" , "_Right" ) Global $x = MouseGetPos( 0 ) , $y = MouseGetPos( 1 ) , $pos , $win_pos , $msg , $split , $old_x , $old_y , $zoom = 8 , $color = "F0F0F0" , $pause = False , $dll[ 2 ] $dll[ 0 ] = DllOpen( "user32.dll" ) $dll[ 1 ] = DllOpen( "gdi32.dll" ) $gui = GUICreate( "Cursor Info" , 285 , 390 , @DesktopWidth - 297 , 6 , Default , $WS_EX_TOPMOST ) $paused = GUICtrlCreateLabel( "Paused: " & $pause , 10 , 10 , 200 , 15 ) $cursor_position = GUICtrlCreateLabel( $x & " : " & $y , 10 , 30 , 60 , 15 ) $cursor_position_x = GUICtrlCreateButton( "Copy X co-ordinate" , 70 , 26 , 100 , 20 ) GUICtrlSetOnEvent( $cursor_position_x , "_Cursor_Position_X" ) $cursor_position_y = GUICtrlCreateButton( "Copy Y co-ordinate" , 175 , 26 , 100 , 20 ) GUICtrlSetOnEvent( $cursor_position_y , "_Cursor_Position_Y" ) $cursor_area = GUICtrlCreateLabel( "0 : 0" , 10 , 50 , 60 , 15 ) $cursor_area_x = GUICtrlCreateButton( "Copy X co-ordinate" , 70 , 46 , 100 , 20 ) GUICtrlSetOnEvent( $cursor_area_x , "_Cursor_Area_X" ) $cursor_area_y = GUICtrlCreateButton( "Copy Y co-ordinate" , 175 , 46 , 100 , 20 ) GUICtrlSetOnEvent( $cursor_area_y , "_Cursor_Area_Y" ) $cursor_color = GUICtrlCreateLabel( "" , 10 , 70 , 60 , 15 ) $cursor_color_example = GUICtrlCreateLabel( "" , 70 , 70 , 100 , 15 ) $cursor_color_copy = GUICtrlCreateButton( "Copy color value" , 175 , 66 , 100 , 20 ) GUICtrlSetOnEvent( $cursor_color_copy , "_Cursor_Color_Copy" ) $zoom_level = GUICtrlCreateSlider( 3 , 90 , 175 , 20 , $TBS_NOTICKS ) _NoFocusLines_Set( $zoom_level ) GUICtrlSetLimit( $zoom_level , 15 , 1 ) GUICtrlSetData( $zoom_level , 16 - $zoom ) $zoom_label = GUICtrlCreateLabel( "Zoom level: " & GUICtrlRead( $zoom_level ) , 180 , 92 , 70 , 15 ) $magnifier = GUICreate( "" , 264 , 264 , @DesktopWidth - 285 , 145 , $WS_POPUP + $WS_BORDER , Default , $gui ) GUIRegisterMsg( $WM_HSCROLL , "_Zoom" ) GUIRegisterMsg( $WM_MOVE , "_Drag" ) ;~ GUISetOnEvent( $GUI_EVENT_CLOSE , "_Esc" , $magnifier ) GUISetOnEvent( $GUI_EVENT_CLOSE , "_Esc" , $gui ) GUISetState( @SW_SHOW , $gui ) GUISetState( @SW_SHOW , $magnifier ) While 1 $pos = MouseGetPos() If Not $pause Then $old_x = $pos[ 0 ] $old_y = $pos[ 1 ] _Update() EndIf If _IsPressed( "02" , $dll[ 0 ] ) Then While _IsPressed( "02" , $dll[ 0 ] ) Sleep( 100 ) WEnd $pause = Not $pause GUICtrlSetData( $paused , "Paused: " & $pause ) EndIf If $pos[ 0 ] <> $x OR $pos[ 1 ] <> $y Then If Not WinActive( $gui ) Then WinActivate( $gui ) GUICtrlSetState( $zoom_level , $GUI_FOCUS ) $x = $pos[ 0 ] $y = $pos[ 1 ] If Not $pause Then GUICtrlSetData( $cursor_position , $x & " : " & $y ) If StringRight( Hex( PixelGetColor( $x , $y ) ) , 6 ) <> "0x" & $color Then $color = "0x" & StringRight( Hex( PixelGetColor( $x , $y ) ) , 6 ) GUICtrlSetData( $cursor_color , $color ) GUICtrlSetBkColor( $cursor_color_example , $color ) EndIf EndIf EndIf If Not $pause And _IsPressed( "01" , $dll[ 0 ] ) Then $x_1 = MouseGetPos( 0 ) $y_1 = MouseGetPos( 1 ) While _IsPressed( "01" , $dll[ 0 ] ) If _IsPressed( "02" , $dll[ 0 ] ) Then While _IsPressed( "02" , $dll[ 0 ] ) Sleep( 100 ) WEnd $pause = Not $pause GUICtrlSetData( $paused , "Paused: " & $pause ) EndIf If MouseGetPos( 0 ) <> $x OR MouseGetPos( 1 ) <> $y Then $x = MouseGetPos( 0 ) $y = MouseGetPos( 1 ) GUICtrlSetData( $cursor_position , $x & " : " & $y ) If StringRight( Hex( PixelGetColor( $x , $y ) ) , 6 ) <> "0x" & $color Then $color = "0x" & StringRight( Hex( PixelGetColor( $x , $y ) ) , 6 ) GUICtrlSetData( $cursor_color , $color ) GUICtrlSetBkColor( $cursor_color_example , $color ) EndIf EndIf If MouseGetPos( 0 ) <> $x_1 OR MouseGetPos( 1 ) <> $y_1 Then $old_x = MouseGetPos( 0 ) $old_y = MouseGetPos( 1 ) _Update() $x_1 = $pos[ 0 ] $y_1 = $pos[ 1 ] GUICtrlSetData( $cursor_area , Abs( $x_1 - $old_x ) & " : " & Abs( $y_1 - $old_y ) ) GUICtrlSetData( $cursor_position , $x_1 & " : " & $y_1 ) EndIf WEnd EndIf Sleep( 10 ) WEnd Func _Up() MouseMove( MouseGetPos( 0 ) , MouseGetPos( 1 ) - 1 , 0 ) EndFunc Func _Down() MouseMove( MouseGetPos( 0 ) , MouseGetPos( 1 ) + 1 , 0 ) EndFunc Func _Left() MouseMove( MouseGetPos( 0 ) - 1 , MouseGetPos( 1 ) , 0 ) EndFunc Func _Right() MouseMove( MouseGetPos( 0 ) + 1 , MouseGetPos( 1 ) , 0 ) EndFunc Func _Cursor_Position_X() $split = StringSplit( GUICtrlRead( $cursor_position ) , " : " , 1 ) ClipPut( $split[ 1 ] ) EndFunc Func _Cursor_Position_Y() $split = StringSplit( GUICtrlRead( $cursor_position ) , " : " , 1 ) ClipPut( $split[ 2 ] ) EndFunc Func _Cursor_Area_X() $split = StringSplit( GUICtrlRead( $cursor_area ) , " : " , 1 ) ClipPut( $split[ 1 ] ) EndFunc Func _Cursor_Area_Y() $split = StringSplit( GUICtrlRead( $cursor_area ) , " : " , 1 ) ClipPut( $split[ 2 ] ) EndFunc Func _Cursor_Color_Copy() $split = StringSplit( $color , "0x" , 1 ) ClipPut( $split[ 2 ] ) EndFunc Func _Zoom( $hWnd , $iMsg , $wParam , $lParam ) #forceref $hWnd, $iMsg, $wParam If $lParam = GUICtrlGetHandle( $zoom_level ) Then $zoom = 16 - GUICtrlRead( $zoom_level ) GUICtrlSetData( $zoom_label , "Zoom level: " & $zoom ) _Update() EndIf Return $GUI_RUNDEFMSG EndFunc Func _Drag( $hWnd , $iMsg , $wParam , $lParam ) $win_pos = WinGetPos( $gui ) WinMove( $magnifier , "" , $win_pos[ 0 ] + 12 , $win_pos[ 1 ] + 140 ) Return $GUI_RUNDEFMSG EndFunc Func _Update() $DeskHDC = DLLCall( $dll[ 0 ] , "int" , "GetDC" , "hwnd" , 0 ) $GUIHDC = DLLCall( $dll[ 0 ] , "int" , "GetDC" , "hwnd" , $magnifier ) If Not @error Then DLLCall( $dll[ 1 ] , "int" , "StretchBlt" , "int" , $GUIHDC[ 0 ] , "int" , 0 , "int" , 0 , "int" , 264 , "int" , 264 , "int" , $DeskHDC[ 0 ] , _ "int" , $old_x - 132 / $zoom / 2 + 1 , "int" , $old_y - 132 / $zoom / 2 + 1 , _ "int" , 132 / $zoom , "int" , 132 / $zoom , "long", $SRCCOPY ) DLLCall( $dll[ 0 ] , "int" , "ReleaseDC" , "int" , $DeskHDC[ 0 ] , "hwnd" , 0 ) DLLCall( $dll[ 0 ] , "int" , "ReleaseDC" , "int" , $GUIHDC[ 0 ] , "hwnd" , $magnifier ) $pen = DLLCall( $dll[ 1 ] , "hwnd" , "CreatePen" , "int" , 0 , "int" , 1 , "int" , 0x000000FF ) DLLCall( $dll[ 1 ] ,"hwnd","SelectObject", "hwnd", $GUIHDC[ 0 ] , "hwnd", $pen[ 0 ] ) DLLCall( $dll[ 1 ] , "int" , "MoveToEx" , "hwnd" , $GUIHDC[ 0 ] , "int" , 0 , "int" , 264 / 2 , "ptr" , 0 ) DLLCall( $dll[ 1 ] , "int" , "LineTo" , "hwnd" , $GUIHDC[ 0 ] , "int" , 264 , "int" , 264 / 2 ) DLLCall( $dll[ 1 ] , "int" , "MoveToEx" , "hwnd" , $GUIHDC[ 0 ] , "int" , 264 / 2 , "int" , 0 , "ptr" , 0 ) DLLCall( $dll[ 1 ] , "int" , "LineTo" , "hwnd" , $GUIHDC[ 0 ] , "int" , 264 / 2 , "int" , 264 ) EndIf EndFunc Func _Esc() ConsoleWrite( "before dll" & @CRLF ) DllClose( $dll[ 0 ] ) DllClose( $dll[ 1 ] ) ConsoleWrite( "before delete" & @CRLF ) GUIDelete( $magnifier ) ConsoleWrite( "before exit" & @CRLF ) Exit EndFunc If i run it from scite when i click the x button it doesn't exits, it just deletes the gui window but the process remains opened and i need to "Stop Executing" Why is that? Edited January 17, 2012 by Revolter [center]Sorry for my bad english. Trying my best :Dhttp://iulianonofrei.comhttp://www.last.fm/user/Revolt666 [/center] Link to comment Share on other sites More sharing options...
enaiman Posted January 17, 2012 Share Posted January 17, 2012 In such cases - TrayIconDebug is your friend. You can see very easy where your script is stuck. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
Revolter Posted January 18, 2012 Author Share Posted January 18, 2012 That is a pretty cool script.I think the problem is related to NoFocusLines.au3. I don't have that UDF so I commented out the two lines of codes that use it, and the script exited like it should.A think I found a different bug in your script too. When I set the zoom level to 1 the GUI went crazy.on my pc it works well at zoom level 1 ... can you send me a screenshot or explain with more details the bug please?In such cases - TrayIconDebug is your friend.You can see very easy where your script is stuck.i have never used trayicondebug ... i most likely learn to use it ... thank you for the hint [center]Sorry for my bad english. Trying my best :Dhttp://iulianonofrei.comhttp://www.last.fm/user/Revolt666 [/center] Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now