C_10
3rd February 2012 09:46 UTC
How to detect flash drive
Hi,
I want to detect a USB flash drive once the user connect it.
It should look like this:
; Disable next button while USB flash drive not identified
GetDlgItem $0 $HWNDPARENT 1 ; next=1, cancel=2, back=3
EnableWindow $0 0
loop:
${If}
# usb is detected
${Else}
Goto loop
${EndIf}
; Enable next button
GetDlgItem $0 $HWNDPARENT 1
EnableWindow $0 1
I hope you have some ideas,
Thanks!
MSG
3rd February 2012 10:10 UTC
See this recent thread: http://forums.winamp.com/showthread.php?t=341152
C_10
7th February 2012 12:34 UTC
Thanks! It works:)
C_10
7th February 2012 14:40 UTC
Now first of all my custom function search the flash drive and then I can see text/label/image and so on...
But i want it the other way round...
How can I do this?
Function customFunction
nsDialogs::Create 1018
; Text, label, image
...
; Disable next button while USB flash drive not identified
GetDlgItem $0 $HWNDPARENT 1 ; next=1, cancel=2, back=3
EnableWindow $0 0
; Search flash drive
...
; Enable next button
GetDlgItem $0 $HWNDPARENT 1
EnableWindow $0 1
nsDialogs::Show
${NSD_FreeImage} $Image
FunctionEnd
Thanks
C_10
10th February 2012 08:48 UTC
Hmm, perhaps I should attach some images.
While searching the flash drive I can't see the images/labels (see attachments).
But I want that you can see the page with all components first, and after that the installer should search the flash drive.
I hope you understand what I mean, please help
MSG
10th February 2012 09:29 UTC
Once you do nsDialogs::Show, the installer will wait until the Next button is pressed (or any other button which has a callback function defined). The installer cannot wait for two things at the same time (Next button and flash drive). So you'll need to do the flashdrive search in the page's leave function. The page would then say "please insert the flash drive and click Next to continue". If in the leave function no drive is found, call abort and the installer will stay on the 'please insert' page.
C_10
10th February 2012 10:20 UTC
Thanks MSG! That's a good idea, but I've one problem:
So you'll need to do the flashdrive search in the page's leave function
I've a custom page, so I can't use "!define MUI_PAGE_CUSTOMFUNCTION_LEAVE"
Can I copy the flashdrive search after
nsDialogs::Show
${NSD_FreeImage} $Image
and make so my own customFunction leave?
Function customFunction
nsDialogs::Create 1018
; Text, label, image
...
nsDialogs::Show
${NSD_FreeImage} $Image
; search flash drive
...
MessageBox MB_YESNO "Leave Function TEST! Go to next page?" IDYES +2
Abort
FunctionEnd
I can see the MessageBox, but when I click on "No", I'm on the next page anyway...
MSG
10th February 2012 10:58 UTC
Page custom customFunction customLeaveFunction
http://nsis.sourceforge.net/Docs/Chapter4.html#4.5.4
C_10
10th February 2012 12:14 UTC
Thanks again MSG!!!
My problem is solved :)