AutoHotkey Community

It is currently May 26th, 2012, 5:04 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 33 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject:
PostPosted: February 14th, 2008, 2:26 am 
Offline
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3328
Location: Simi Valley, CA
M3CSL wrote:
Is it possible to get the drive letter of the new device and open its content in Windows Explorer?

Code:
OnMessage(0x219, "notify_change")
DriveGet, dlist, list, REMOVABLE
Return

notify_change(wParam, lParam, msg, hwnd)
{ ; give the OS two seconds to do whatever (shuffle drivers or whatnot)
   SetTimer, CheckUSBDrives, -2000
}

CheckUSBDrives:
DriveGet, nlist, list, REMOVABLE
Loop Parse, nlist
   IfNotInString, dlist, %a_LoopField%
   {
      run %a_LoopField%:\
      dlist := nlist
   }
return

_________________
Ternary (a ? b : c) guide     TSV Table Manipulation Library
Post code inside [code][/code] tags!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 14th, 2008, 6:26 pm 
Offline

Joined: January 21st, 2008, 6:15 pm
Posts: 36
Location: Germany
Wow, thank you very much, [VxE]!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 18th, 2008, 7:17 pm 
Offline

Joined: January 21st, 2008, 6:15 pm
Posts: 36
Location: Germany
[VxE], I've a litte problem with your script, if I use a smart card reader which adds four removable drives to explorer it tries to open the first drive, even if only in the second drive has a card inseted. Are you able to modify your script?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 19th, 2008, 2:07 am 
Offline
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3328
Location: Simi Valley, CA
Sure, you can try this:
Code:
OnMessage(0x219, "notify_change")
DriveGet, dlist, list, REMOVABLE
Return

notify_change(wParam, lParam, msg, hwnd)
{ ; give the OS two seconds to do whatever (shuffle drivers or whatnot)
   SetTimer, CheckUSBDrives, -2000
}

CheckUSBDrives:
DriveGet, nlist, list, REMOVABLE
Loop Parse, nlist
   IfNotInString, dlist, %a_LoopField%
   {
      DriveGet, Ready, Ready, %a_LoopField%:\
      If Ready = Ready
      {

          run %a_LoopField%:\
          dlist := nlist
      }
   }
return

But it's untested as I don't have a card reader...

_________________
Ternary (a ? b : c) guide     TSV Table Manipulation Library
Post code inside [code][/code] tags!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 20th, 2008, 1:26 pm 
Offline

Joined: January 21st, 2008, 6:15 pm
Posts: 36
Location: Germany
Cool, thx, it perfectly works with my cardreader and card in 2nd device letter. But it was necessary to change one command:

Code:
DriveGet, Ready, Status, %a_LoopField%:\


Makes sense, didn't it?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 27th, 2008, 4:43 am 
Offline

Joined: June 3rd, 2007, 5:49 am
Posts: 36
Hey guys thanks for this..
modified it to detect for images from cameras and automatically open up the folder with the images.

This takes care of program running while the drive is already there, previously the drive list is not reset if the card is already there, thus the program can be left running and keeps readjusting to drive insertion and removal.

Code:
#SingleInstance force
;[======================================================]
;[  Check for these extensions for existence of images  ]
;[======================================================]
ext = jpg,nef,crw,cr2,raf,tif,kdc,dcr,mrw,orf,dng,ptx,pef,arw,srf,x3f,erf,mef,mos,raw,r3d

OnMessage(0x219, "notify_change")
DriveGet, dlist, list, REMOVABLE
Return

notify_change(wParam, lParam, msg, hwnd)
{ ; give the OS two seconds to do whatever (shuffle drivers or whatnot)
   SetTimer, CheckUSBDrives, -2000
}

CheckUSBDrives:
DriveGet, nlist, list, REMOVABLE
;[===============================================]
;[  If Drives are removed instead of plugged in  ]
;[                Then reset dlist               ]
;[===============================================]
If StrLen(nlist) < StrLen(dlist)
{
   dlist=%nlist%
   exit
}

Loop Parse, nlist
   IfNotInString, dlist, %a_LoopField%
   {
      DriveGet, drivestatus, Status, %a_LoopField%:\
      If drivestatus = Ready
      {
          vdrive = %a_LoopField%
          target = %vdrive%:\
          found =
          Loop,Parse,ext,`,
          {
           Loop, %vdrive%:\DCIM\*.%a_LoopField%, 0, 1
           {
            FileDir := A_LoopFileDir
            target = %FileDir%
            found = true
            break
           }
           if found
              break
        }
          run %target%
          break
      }
   }
;[======================================================]
;[  Close the "What do you want windows to do?" window  ]
;[======================================================]   
   IfWinExist, ahk_class #32770
      WinClose, ahk_class #32770   
return

_________________
http://willyfoo.com
http://livestudios.com


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 27th, 2008, 8:02 am 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8775
Related post on retrieving the drive letter: Help required on Bitwise operation


Report this post
Top
 Profile  
Reply with quote  
PostPosted: March 31st, 2008, 6:35 am 
Offline

Joined: January 13th, 2008, 6:00 pm
Posts: 115
Quote:
OnMessage(0x219, "notify_change")
Return

notify_change(wParam, lParam, msg, hwnd)
{
MsgBox, %wParam% %lParam% %msg% %hwnd%
}


I used this to get the right variable values, but I can't get my script to work:

Code:
 OnMessage(0x219, "privatedisk")


 privatedisk(wParam, lParam, msg, hwnd)
 {
 If wParam = 32768
 If lParam = 8977344
 If msg = 0x219
 If hwnd = 0x1208e4
 Run "C:\Program Files\Mozilla Firefox\firefox.exe" -no-remote -p gcal
 return
 }


I've tried several variations on the if expressions. Any ideas??


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 31st, 2008, 7:46 am 
M3CSL wrote:
Paulo wrote:
OnMessage(0x219, "notify_change")
Return

notify_change(wParam, lParam, msg, hwnd)
{
MsgBox, %wParam% %lParam% %msg% %hwnd%
}


Is it possible to get the drive letter of the new device and open its content in Windows Explorer?
1: DriveGet, driveletters, list
2:wait for usb
3: DriveGet, driveletters, list
compare 1&3


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 31st, 2008, 7:10 pm 
Offline

Joined: January 21st, 2008, 6:15 pm
Posts: 36
Location: Germany
widow wrote:
1: DriveGet, driveletters, list
2:wait for usb
3: DriveGet, driveletters, list
compare 1&3


But its necessary to execute line 1 every time the drive letters change... Isn't it?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 9th, 2008, 8:44 am 
Offline

Joined: February 28th, 2006, 8:42 am
Posts: 159
Paulo wrote:
I don't know for sure if it will work with mics but it works with all my usb devices.

OnMessage(0x219, "notify_change")
Return

notify_change(wParam, lParam, msg, hwnd)
{
MsgBox, %wParam% %lParam% %msg% %hwnd%
}


um, any ideas why this doesnt work for me? I'm running winxp home edition SP3. It seems to be working for everyone else here. When i stick it in my ahk file and plug/unplug various usb items (external keyboard for instance), the 'msgbox' does not fire.

thanks


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 9th, 2008, 8:52 am 
Offline
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3328
Location: Simi Valley, CA
jak wrote:
When i stick it in my ahk file and plug/unplug various usb items (external keyboard for instance), the 'msgbox' does not fire.
Are you sure the script is still running? Does the little green "H" stay in the tray while you're plugging in your usb drive? Is your usb drive a U3 drive ?(U3 drives are handled somewhat differently from regular usb storage)

_________________
Ternary (a ? b : c) guide     TSV Table Manipulation Library
Post code inside [code][/code] tags!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 9th, 2008, 9:03 am 
Offline

Joined: February 28th, 2006, 8:42 am
Posts: 159
hi vxe --
i tried it with both an external usb keyboard and with a thumbdrive. (dont know if thumbdrive is u3, but keyboard should have worked too, right?). In both cases, the ahk green H did stay in the system tray and seems to be working normally.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 9th, 2008, 9:04 am 
Offline

Joined: February 28th, 2006, 8:42 am
Posts: 159
let me try a simpler ahk script (my default one is a monster). I'll post back in a sec...

ok, its working -- you might find this interesting....

when the "onmessage" code block is located right under the opening declarations, its working fine.
When its located a page or two into the ahk file, its not working. ;)

for my own edification, why would this simple code block not run when its not near the top of the script? This isnt part of the code that auto executes "one-time" when the script is loaded, right?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 9th, 2008, 9:20 am 
Offline

Joined: April 18th, 2008, 7:57 am
Posts: 1390
Location: The Interwebs
jak wrote:
for my own edification, why would this simple code block not run when its not near the top of the script? This isnt part of the code that auto executes "one-time" when the script is loaded, right?


This line:
Code:
OnMessage(0x219, "notify_change")

needs to be in the autoexecute because it tells the script to begin monitoring the message 0x219.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 33 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Alpha Bravo, Exabot [Bot], mrhobbeys, rbrtryn and 32 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group