/* Author - Target OCT08 Credits to AHKLerner and Lexikos in the AHK forum for the scroll bar code Script will scan all removable drives on a 1.5 second cycle found drives will launch the kiosk defaults can be set from the tray menu creates numerically sequenced output folders (0001, 0002,0003, etc). Up to 9998 - could be varied by adding further iterations at line 14 script/window title can be set via MyName variable controls are disabled for files already copied or moved Known limitations - duplicated file names - while all found files will be displayed, where more than one file exists with the same name only the first will be successfully copied/moved no keyboard interaction accepted, eg tabbing between controls. up/down arrows will scroll the gui */ #persistent #singleinstance, forced fileinstall, target.ico, target.ico MyName:= "Picturosk" ifnotexist, kiosk.ini { foldind:= 0 gui, add, edit, x10 y10 w200 vOutPath, %target% gui, add, button, x220 y10 gPathout,... gui, add, text, x10 y38, Folder Index: gui, add, edit, x90 y38 w120 vFoldInd gsave, %FoldInd% gui, add, button, x10 y65 w230 gSave, Set Defaults ; Output Directory gui, show, w250 h100 center return } menu, tray, icon, target.ico menu, tray, nostandard Menu, tray, add, Set_Defaults menu, tray, add menu, tray, add, Exit_Script iniread, target, kiosk.ini, HomeDir, target iniread, foldind, kiosk.ini, folderIndex, foldcount foldind++ if foldind < 1000 pad:= "0" if foldind < 100 pad.= "0" if foldind < 10 pad.= "0" progress, zh0 w600 h450 B c11 cwC0c0c0 fs35, `n`nWaiting...`n`n(insert your card) ;cw00FF00 loop { driveget, DrvLst, list, removable loop, parse, drvlst { driveget, drvstat,status, %a_loopfield%: if drvstat = ready { progress, off Break } } if drvstat = Ready break sleep, 1500 } pind = 0 progress, off progress, zh0 w600 h450 B c11 cwc0c0c0 fs35, `n`n`nScanning media`n Please wait... loop, parse, drvlst { loop, %a_loopfield%:\*.*,0,1 { if a_loopfileext contains BMP ,JPG ;,PNG, TIF,GIF,JPEG,JPE,WMF,EMF { pind++ tstr:= substr(a_loopfilelongpath,1,2) if dlst not contains %tstr% dlst.= substr(a_loopfilelongpath,1,2) . "`," gui, add, picture, vt%pind% , %a_loopfilelongpath% guicontrolget,picsize, pos, t%pind% gui, destroy if picsizeh > %picsizew% gui, add, picture, w-1 h125 vt%pind% , %a_loopfilelongpath% else gui, add, picture, w125 h-1 vt%pind% , %a_loopfilelongpath% guicontrolget,picsize, pos, t%pind% gui, destroy if picsizeh > %picsizew% { off:= (125 - picsizew)//2 picsizew:= -1 } else { off:= (125 - picsizeh)//2 picsizeh:= -1 } FLst.= a_loopfilelongpath . "," . picsizeh . "," . picsizew . "," . off . "," . "#" } } } pind:= 0 px = 10 py = 10 cx = 67 cy = 140 looop = 1 OnMessage(0x115, "OnScroll") ; WM_VSCROLL OnMessage(0x114, "OnScroll") ; WM_HSCROLL Gui, +Resize +0x300000 ; WS_VSCROLL | WS_HSCROLL menu, menubar,add, All menu, menubar,add, None menu, menubar,add, Copy menu, menubar,add, Move menu, menubar,add, Quit gui, menu, menubar loop, parse, flst , `# { stringsplit, item, a_loopfield , `, pyy:= py pxx:= px if item3 = -1 ;> item%3% pxx+= item4 else pyy+= item4 gui, add, picture, w%item3% h%item2% y%pyy% x%pxx% vp%a_index% gclicpic, %item1% gui, add, checkbox, x%cx% y%cy% vc%a_index% gclicpic check3 p%a_index%:= item1 c%a_index%:= 0 pind++ looop++ if looop < 7 { px+= 145 cx+= 145 } else { px = 10 py+= 150 cx= 67 cy+= 150 looop = 1 } ; pind:= a_index } progress, off gui, +alwaysontop ;+toolwindow gui, show, w900 center, %MyName% - %Pind% images found ;, autosize center Gui, +LastFound GroupAdd, MyGui, % "ahk_id " . WinExist() return Set_Defaults: progress, off ifexist, kiosk.ini { iniread, target, kiosk.ini, HomeDir, target iniread, foldind, kiosk.ini, folderIndex, foldcount } else foldind:= 0 gui, add, edit, x10 y10 w200 vOutPath, %target% gui, add, button, x220 y10 gPathout,... gui, add, text, x10 y38, Folder Index: gui, add, edit, x90 y38 w120 vFoldInd gsave, %FoldInd% gui, add, button, x10 y65 w230 gSave, Set Defaults ; Output Directory gui, show, w250 h100 center return FoldCount: gui, submit, nohide return Save: iniwrite, %target%, kiosk.ini, homedir, target iniwrite, %foldInd%, kiosk.ini, FolderIndex, foldcount reload return Pathout: fileselectfolder, target, ::{20d04fe0-3aea-1069-a2d8-08002b30309d},3,Select the target folder guicontrol,,OutPath, %target% return #F12:: exit_Script: exitapp All: loop, %pind% { guicontrol, , c%a_index%, 1 gui, submit, nohide } gui, show, w900 return None: loop, %pind% { guicontrol, , c%a_index%, 0 gui, submit, nohide } gui, show, w900 return Copy: ifnotexist, %target%\%pad%%foldind% filecreatedir, %target%\%pad%%foldind% loop, %pind% { guicontrolget, chk,,c%a_index% if chk { guicontrolget, pth,,p%a_index% splashtexton,500,30,Copying, %pth% filecopy, %pth%, %Target%\%pad%%foldind% guicontrol,,c%a_index%, -1 guicontrol,disable,c%a_index% guicontrol,disable,p%a_index% gui, submit, nohide chkval:=1 } } if chkval iniwrite, %foldInd%, kiosk.ini, FolderIndex, foldcount chkval:= splashtextoff return Move: ifnotexist, %target%\%pad%%foldind% filecreatedir, %target%\%pad%%foldind% loop, %pind% { guicontrolget, chk,,c%a_index% if chk { guicontrolget, pth,,p%a_index% splashtexton,500,30,Moving, %pth% filemove, %pth%, %Target%\%pad%%foldind% guicontrol,,c%a_index%, -1 guicontrol,disable,c%a_index% guicontrol,disable,p%a_index% gui, submit, nohide chkval:=1 } } if chkval iniwrite, %foldInd%, kiosk.ini, FolderIndex, foldcount chkval:= splashtextoff return clicpic: stringtrimleft, tmp, a_guicontrol, 1 if c%tmp% guicontrol,, c%tmp%,0 else guicontrol,, c%tmp%,1 gui, submit, nohide ;gui, show, w900 return Quit: guiclose: gui, hide msgbox, Remove card then press OK reload return ^F12:: reload return GuiSize: UpdateScrollBars(A_Gui, A_GuiWidth, A_GuiHeight) return #IfWinActive ahk_group MyGui WheelUp:: WheelDown:: ;+WheelUp:: ;+WheelDown:: up:: Down:: ; SB_LINEDOWN=1, SB_LINEUP=0, WM_HSCROLL=0x114, WM_VSCROLL=0x115 OnScroll(InStr(A_ThisHotkey,"Down") ? 1 : 0, 0, GetKeyState("Shift") ? 0x114 : 0x115, WinExist()) return #IfWinActive UpdateScrollBars(GuiNum, GuiWidth, GuiHeight) { static SIF_RANGE=0x1, SIF_PAGE=0x2, SIF_DISABLENOSCROLL=0x8, SB_HORZ=0, SB_VERT=1 Gui, %GuiNum%:Default Gui, +LastFound ; Calculate scrolling area. Left := Top := 9999 Right := Bottom := 0 WinGet, ControlList, ControlList Loop, Parse, ControlList, `n { GuiControlGet, c, Pos, %A_LoopField% if (cX < Left) Left := cX if (cY < Top) Top := cY if (cX + cW > Right) Right := cX + cW if (cY + cH > Bottom) Bottom := cY + cH } Left -= 8 Top -= 8 Right += 8 Bottom += 8 ScrollWidth := Right-Left ScrollHeight := Bottom-Top ; Initialize SCROLLINFO. VarSetCapacity(si, 28, 0) NumPut(28, si) ; cbSize NumPut(SIF_RANGE | SIF_PAGE, si, 4) ; fMask ; Update horizontal scroll bar. NumPut(ScrollWidth, si, 12) ; nMax NumPut(GuiWidth, si, 16) ; nPage DllCall("SetScrollInfo", "uint", WinExist(), "uint", SB_HORZ, "uint", &si, "int", 1) ; Update vertical scroll bar. ; NumPut(SIF_RANGE | SIF_PAGE | SIF_DISABLENOSCROLL, si, 4) ; fMask NumPut(ScrollHeight, si, 12) ; nMax NumPut(GuiHeight, si, 16) ; nPage DllCall("SetScrollInfo", "uint", WinExist(), "uint", SB_VERT, "uint", &si, "int", 1) if (Left < 0 && Right < GuiWidth) x := Abs(Left) > GuiWidth-Right ? GuiWidth-Right : Abs(Left) if (Top < 0 && Bottom < GuiHeight) y := Abs(Top) > GuiHeight-Bottom ? GuiHeight-Bottom : Abs(Top) if (x || y) DllCall("ScrollWindow", "uint", WinExist(), "int", x, "int", y, "uint", 0, "uint", 0) } OnScroll(wParam, lParam, msg, hwnd) { static SIF_ALL=0x17, SCROLL_STEP=10 bar := msg=0x115 ; SB_HORZ=0, SB_VERT=1 VarSetCapacity(si, 28, 0) NumPut(28, si) ; cbSize NumPut(SIF_ALL, si, 4) ; fMask if !DllCall("GetScrollInfo", "uint", hwnd, "int", bar, "uint", &si) return VarSetCapacity(rect, 16) DllCall("GetClientRect", "uint", hwnd, "uint", &rect) new_pos := NumGet(si, 20) ; nPos action := wParam & 0xFFFF if action = 0 ; SB_LINEUP new_pos -= SCROLL_STEP else if action = 1 ; SB_LINEDOWN new_pos += SCROLL_STEP else if action = 2 ; SB_PAGEUP new_pos -= NumGet(rect, 12, "int") - SCROLL_STEP else if action = 3 ; SB_PAGEDOWN new_pos += NumGet(rect, 12, "int") - SCROLL_STEP else if action = 5 ; SB_THUMBTRACK new_pos := NumGet(si, 24, "int") ; nTrackPos else if action = 6 ; SB_TOP new_pos := NumGet(si, 8, "int") ; nMin else if action = 7 ; SB_BOTTOM new_pos := NumGet(si, 12, "int") ; nMax else return min := NumGet(si, 8, "int") ; nMin max := NumGet(si, 12, "int") - NumGet(si, 16) ; nMax-nPage new_pos := new_pos > max ? max : new_pos new_pos := new_pos < min ? min : new_pos old_pos := NumGet(si, 20, "int") ; nPos x := y := 0 if bar = 0 ; SB_HORZ x := old_pos-new_pos else y := old_pos-new_pos ; Scroll contents of window and invalidate uncovered area. DllCall("ScrollWindow", "uint", hwnd, "int", x, "int", y, "uint", 0, "uint", 0) ; Update scroll bar. NumPut(new_pos, si, 20, "int") ; nPos DllCall("SetScrollInfo", "uint", hwnd, "int", bar, "uint", &si, "int", 1) }