Jump to content

SCRIPT: usb_sling


jftuga
 Share

Recommended Posts

I think that I will be running this on startup. :whistle:

Any comments or suggestions are most welcomed.

-John

#cs
usb_sling.au3
-John Taylor
Nov-6-2006

I always hate how long and how many clicks it takes to safely remove a
usb device. This program automates the process, by quickly 'clicking'
all of the buttons for you. Run this program in the background.  Once you
click the USB icon in the system tray, this program takes over and clicks
through all of the dialogs for you.

http://www.iconarchive.com/icon/hardware/fruit-on-the-hand-by-irondevil/IceUSB.ico
#ce


#notrayicon

Opt("MustDeclareVars", 1)

Dim $title="Safely Remove Hardware"
Dim $stop ="Stop a Hardware device"
_ReduceMemory()

while 1
    sleep(1500)
    if WinActive( $title ) then
        ControlClick( $title, "", "Button2") ; "Stop"
        sleep(200)
        if WinActive( $stop ) then
            ControlClick( $stop, "", "Button1") ; "OK"
        endif
        sleep(250)
        ControlClick( $title, "", "Button3") ; "Close"
        _ReduceMemory()
    endif
wend

Func _ReduceMemory($i_PID = -1)
    If $i_PID <> -1 Then
        Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID)
        Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0])
        DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0])
    Else
        Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
    EndIf
    
    Return $ai_Return[0]
EndFunc
Link to comment
Share on other sites

I can't remember ever using the 'safely remove' feature. I just remove it be it a pendrive or compact flash card. I've never experienced any problems, so I don't fully understand the usefulness of it.

Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

Link to comment
Share on other sites

I can't remember ever using the 'safely remove' feature. I just remove it be it a pendrive or compact flash card. I've never experienced any problems, so I don't fully understand the usefulness of it.

Exactly what I do.
# MY LOVE FOR YOU... IS LIKE A TRUCK- #
Link to comment
Share on other sites

Link to comment
Share on other sites

I can't remember ever using the 'safely remove' feature. I just remove it be it a pendrive or compact flash card. I've never experienced any problems, so I don't fully understand the usefulness of it.

You lucky, this is for the time being. Removing this without disconnecting may cause problems. Good, if this just one file, that remain in cache, but I know cases when in result filesystem was destroyed. For example, one my friend lost whole data on his stick, this even not formatting until using special recovery tool. So I'm prefer not be lazy in this case...
Link to comment
Share on other sites

I try to always use it.

And when explorer ain't your shell you can use this:

rundll32.exe shell32.dll,Control_RunDLL hotplug.dll

Works on w2k anyway would be nice to here if it works on XP to but I suppose it will.

Link to comment
Share on other sites

For those that are really lazy - try left clicking - a lot faster.

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

  • 2 weeks later...

For those that are really lazy - try left clicking - a lot faster.

I reread this and it does not make sense, so I thought that I would explain -

The icon that you click to go through all these screens, can be bypassed when you left click rather than right click on the icon. This is a short cut to closing the USB device, as it will show you a list of the devices connected.

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

I reread this and it does not make sense, so I thought that I would explain -

The icon that you click to go through all these screens, can be bypassed when you left click rather than right click on the icon. This is a short cut to closing the USB device, as it will show you a list of the devices connected.

nitekram,

Thanks for the tip. I've always used the right-click and did not realize you could just left-click the icon.

taurus905

"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Link to comment
Share on other sites

nitekram,

Thanks for the tip. I've always used the right-click and did not realize you could just left-click the icon.

taurus905

No problem - I found it a while back and used ever since.

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...