Mriswith2k Posted May 19, 2013 Posted May 19, 2013 (edited) expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> ;~ Opt("GUIOnEventMode", 1) #Region ### START Koda GUI section ### Form= $Form1 = GUICreate(" Image Dimensions", 304, 70, -1, -1,WinGetHandle("AutoItWinGetTitle"),BitOR($WS_EX_ACCEPTFILES, $WS_EX_TOPMOST)) $Button1 = GUICtrlCreateButton("Calc", 114, 3, 60, 19) $Button2 = GUICtrlCreateButton("Reverse", 114, 21, 60, 19) $w = GUICtrlCreateInput("", 4, 21, 49, 18,$SS_CENTER) $h = GUICtrlCreateInput("", 61, 21, 49, 18,$SS_CENTER) $Label1 = GUICtrlCreateLabel("Width", 5, 6, 49, 15,$SS_CENTER) $Label3 = GUICtrlCreateLabel("Height", 61, 6, 49, 15,$SS_CENTER) $Label2 = GUICtrlCreateLabel("x", 54, 22, 7, 11) $new_w= GUICtrlCreateLabel("Width", 178, 21, 49, 18,$SS_CENTER, $SS_BLACKFRAME) $dif_w = GUICtrlCreateLabel("Diff", 178, 3, 49, 18,$SS_CENTER, $SS_BLACKFRAME) $new_h = GUICtrlCreateLabel("Height", 231, 21, 49, 18,$SS_CENTER, $SS_BLACKFRAME) $dif_h = GUICtrlCreateLabel("Diff", 231, 3, 49, 18,$SS_CENTER, $SS_BLACKFRAME) $Button3 = GUICtrlCreateButton("X", 282, 2, 14, 19) $Button4 = GUICtrlCreateButton("R", 282, 21, 14, 19) GUISetState(@SW_SHOW) ;~ GUISetOnEvent($GUI_EVENT_DROPPED, "_DragDrop") ;~ GUICtrlSetState($Label1, $GUI_DROPACCEPTED) #EndRegion ### END Koda GUI section ### ;~ Func _DragDrop() ;~ _GDIPlus_Startup() ;~ $hImage = _GDIPlus_ImageLoadFromFile(@GUI_DRAGFILE) ;~ GuiCtrlSetData($w,_GDIPlus_ImageGetWidth($hImage) ;~ GuiCtrlSetData($h,_GDIPlus_ImageGetHeight($hImage) ;~ _GDIPlus_ImageDispose($hImage) ;~ _GDIPlus_Shutdown() ;~ _Calc() ;~ EndFunc Func _Calc() If (GUICtrlRead($h)/9*16)>GuiCtrlRead($w) then GuiCtrlSetData($new_w,GuiCtrlRead($w)) GuiCtrlSetData($dif_w,"") else GuiCtrlSetData($new_w,Round(GuiCtrlRead($h)/9*16,0)) GuiCtrlSetData($dif_w,Round(GuiCtrlRead($h)/9*16,0)-GuiCtrlRead($w)) EndIf If (GUICtrlRead($w)/16*9)>GuiCtrlRead($h) then GuiCtrlSetData($new_h,GuiCtrlRead($h)) GuiCtrlSetData($dif_h,"") else GuiCtrlSetData($new_h,Round(GuiCtrlRead($w)/16*9,0)) GuiCtrlSetData($dif_h,Round(GuiCtrlRead($w)/16*9,0)-GuiCtrlRead($h)) EndIf GUICtrlSetColor($new_w,0x009900) GUICtrlSetColor($dif_w,0x009900) GUICtrlSetColor($new_h,0x009900) GUICtrlSetColor($dif_h,0x009900) EndFunc Func _Reverse() If (GUICtrlRead($h)/9*16)<GuiCtrlRead($w) then GuiCtrlSetData($new_w,GuiCtrlRead($w)) GuiCtrlSetData($dif_w,"") else GuiCtrlSetData($new_w,Round(GuiCtrlRead($h)/9*16,0)) GuiCtrlSetData($dif_w,"+" & Round(GuiCtrlRead($h)/9*16,0)-GuiCtrlRead($w)) EndIf If (GUICtrlRead($w)/16*9)<GuiCtrlRead($h) then GuiCtrlSetData($new_h,GuiCtrlRead($h)) GuiCtrlSetData($dif_h,"") else GuiCtrlSetData($new_h,Round(GuiCtrlRead($w)/16*9,0)) GuiCtrlSetData($dif_h,"+" & Round(GuiCtrlRead($w)/16*9,0)-GuiCtrlRead($h)) EndIf GUICtrlSetColor($new_w,0xee0000) GUICtrlSetColor($dif_w,0xee0000) GUICtrlSetColor($new_h,0xee0000) GUICtrlSetColor($dif_h,0xee0000) EndFunc Func _Restart() if @compiled then Run('"' & @ScriptFullPath & '"') Else Run(FileGetShortName(@AutoItExe) & " " & '"' & @ScriptFullPath &'"') exit EndIf EndFunc While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_DROPPED _DragDrop() Case $Button1 _Calc() Case $Button2 _Reverse() Case $Button3 Exit Case $Button4 _Restart() EndSwitch Sleep(10) WEnd I've been working on a simple script that checks 2 values (height / width) and then calculates the require difference required to make the values into a 16/9 aspect ratio. And it works well, but I've been trying to integrate a function so I can simply drag and drop an image onto the gui and have it use the images height / width instead of needing to type them in manually. The script above is currently what I'm using with the ;~ lines being what I've been trying to integrate (in multiple ways ;D) and sadly I obviously have no idea what I'm doing >_>. From the testing I've done the issue is that when GUIOnEventMode is set to 1, even if no other parts of the new code is active, this will completely break all the button functions. I've been googling it a lot on it but honestly it seems that I'm not understanding some of the basic issues. Since from the code/examples I've been looking at I don't really understand why the buttons stop working, and even if I run the script in the AutoIt Debugger, the 'while 1' lines that keep running are exactly the same with GuiOnEvenMOde commented out as when I have it implemented, except that nothing happens in the later case. Also I'm not sure if I'm doing something wrong with the actual drag and drop functions since I think I'm never getting that far in the script since the gui becomes unresponsive (well the buttons are) when the GuiOnEventMode is 1. Any help would be very appreciated, I mainly code by trial and error (thats how my learning curve works anyhow) and I can usually get around most issues by googling and trying different solutions others have already tried. But I've gotten to the point where I'm assuming something just isn't working how I assume it's working and before I rewrite everything after someones elses example I thought I should ask if I'm just doing something basicly wrong (which I assume) or if something just isn't supposed to work how I think it should. Edited May 19, 2013 by Mriswith2k
Solution careca Posted May 19, 2013 Solution Posted May 19, 2013 (edited) Got a example script of drag and drop functionality, using a listview. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Example() Func Example() Local $listview, $button, $item1, $item2, $item3, $item4, $msg GUICreate("Drop in Listview", 220, 200, 100, 100, -1, $WS_EX_ACCEPTFILES) $listview = GUICtrlCreateListView("col1|col2|col3 ", 10, 10, 200, 150) GUICtrlSetState(-1, $GUI_DROPACCEPTED) $item1 = GUICtrlCreateListViewItem("1|4|7", $listview) $item2 = GUICtrlCreateListViewItem("2|5|8", $listview) $item3 = GUICtrlCreateListViewItem("3|6|9", $listview) GUISetState() Do $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_DROPPED GUICtrlCreateListViewItem(@GUI_DRAGFILE&'|'&'|', $listview) EndSelect Until $msg = $GUI_EVENT_CLOSE EndFunc ;==>Example Special attention to $WS_EX_ACCEPTFILES, GUICtrlSetState(-1, $GUI_DROPACCEPTED) and @GUI_DRAGFILE to retrieve the dropped file. Ps: sorry dont have time to check your script, but on a fast look seems you're on the good path. Edited May 19, 2013 by careca Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe
Mriswith2k Posted May 20, 2013 Author Posted May 20, 2013 Oh, I assumed the Opt options was a requirement for any kind of drop related action, if this isn't the case I'll have to explore the listview way since that could hopefully bypasses the entire issue I'm having. Can't do much untill tomorrow after work though, since it's far to late for me to try and solve it today. And thanks a lot for the help. Â
guinness Posted May 20, 2013 Posted May 20, 2013 With multiple files being dropped. Search WinAPIEx in the examples section. expandcollapse popup#include <Constants.au3> #include <GUIConstantsEx.au3> #include <WinAPIEx.au3> #include <WindowsConstants.au3> Global $__aGUIDropFiles = 0, $__hGUI = 0 Example() Func Example() $__hGUI = GUICreate('WM_DROPFILES', 400, 200, Default, Default, Default, $WS_EX_ACCEPTFILES) Local Const $iDrop = GUICtrlCreateLabel('', 0, 0, 400, 200) GUICtrlSetBkColor($iDrop, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetState($iDrop, $GUI_DROPACCEPTED) GUISetState(@SW_SHOW, $__hGUI) GUIRegisterMsg($WM_DROPFILES, 'WM_DROPFILES') While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_DROPPED For $i = 1 To $__aGUIDropFiles[0] MsgBox($MB_SYSTEMMODAL, '', $__aGUIDropFiles[$i]) Next EndSwitch WEnd GUIDelete($__hGUI) EndFunc ;==>Example Func WM_DROPFILES($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $lParam Switch $iMsg Case $WM_DROPFILES Local Const $aReturn = _WinAPI_DragQueryFileEx($wParam) If UBound($aReturn) Then $__aGUIDropFiles = $aReturn Else Local Const $aError[1] = [0] $__aGUIDropFiles = $aError EndIf EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_DROPFILES UDF List:  _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
Mriswith2k Posted May 20, 2013 Author Posted May 20, 2013 (edited) I'm greatful for the help and I think I've finally gotten it to work by removing the Opt option, and doing some more debugging on the code. I'll post the script and mark the post as solved after I finish some details. Edited May 20, 2013 by Mriswith2k
Mriswith2k Posted May 20, 2013 Author Posted May 20, 2013 Thanks a lot for the help, it seems I was completely wrong about needing to use Opt("GUIOnEventMode", 1) so I got the drag and drop to work after checking the examples you posted (very much appriciated). Here is the finished (working) script if anyone is interested. expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> Global $Toggle=0 #Region ### START Koda GUI section ### Form= $Form1 = GUICreate(" Image Dimensions", 320, 69, -1, -1,WinGetHandle("AutoItWinGetTitle"),$WS_EX_TOPMOST) $Button1 = GUICtrlCreateButton("Calc", 114, 3, 60, 19) $Button2 = GUICtrlCreateButton("Reverse", 114, 21, 60, 19) $w = GUICtrlCreateInput("", 4, 21, 49, 18,BitOr($SS_CENTER,$ES_NUMBER)) $h = GUICtrlCreateInput("", 61, 21, 49, 18,BitOr($SS_CENTER,$ES_NUMBER)) $arw = GUICtrlCreateInput("", 33, 4, 20, 16,BitOr($SS_CENTER,$ES_NUMBER)) GuiCtrlSetData($arw,16) $arh = GUICtrlCreateInput("", 61, 4, 20, 16,BitOr($SS_CENTER,$ES_NUMBER)) GuiCtrlSetData($arh,9) $Label1 = GUICtrlCreateLabel("W", 10, 5, 20, 15,$SS_CENTER) $Label2 = GUICtrlCreateLabel("H", 84, 5, 20, 15,$SS_CENTER) $Label3 = GUICtrlCreateLabel(":", 56, 4, 5, 11) $Label4 = GUICtrlCreateLabel("x", 54, 22, 7, 11) $new_w= GUICtrlCreateLabel("Width", 178, 21, 49, 18,$SS_CENTER, $SS_BLACKFRAME) $dif_w = GUICtrlCreateLabel("Diff", 178, 3, 49, 18,$SS_CENTER, $SS_BLACKFRAME) $new_h = GUICtrlCreateLabel("Height", 231, 21, 49, 18,$SS_CENTER, $SS_BLACKFRAME) $dif_h = GUICtrlCreateLabel("Diff", 231, 3, 49, 18,$SS_CENTER, $SS_BLACKFRAME) $IBToogle = GUICtrlCreateCheckbox("IB", 283, 22, 30, 19) GUICtrlSetTip($IBToogle, "Image Basket for Drag and drop") $Button3 = GUICtrlCreateButton("R", 282, 3, 15, 19) GUICtrlSetTip($Button3, "Reload Script / Program") $Button4 = GUICtrlCreateButton("X", 297, 3, 15, 19) GUICtrlSetTip($Button4, "Exit") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $ImageBasket = GUICreate("Image Basket",40,76, -1, -1,WinGetHandle("AutoItWinGetTitle"),BitOR($WS_EX_ACCEPTFILES, $WS_EX_TOPMOST)) $DragDrop = GUICtrlCreateLabel("Drag" & @CRLF & "and" & @CRLF &"Drop", 2, 2, 114, 45,$SS_CENTER, $SS_BLACKFRAME) GUICtrlSetState($DragDrop, $GUI_DROPACCEPTED) GUICtrlSetState($IBToogle, $GUI_UNCHECKED) Func _DragDrop() _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile(@GUI_DRAGFILE) GuiCtrlSetData($w,_GDIPlus_ImageGetWidth($hImage)) GuiCtrlSetData($h,_GDIPlus_ImageGetHeight($hImage)) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() _Calc() EndFunc Func _ToggleOn() $Toggle=1 GUISetState(@SW_SHOW,$ImageBasket) GUISetState(@SW_ENABLE, $ImageBasket) EndFunc Func _ToggleOff() $Toggle=0 GUISetState(@SW_HIDE,$ImageBasket) GUISetState(@SW_DISABLE, $ImageBasket) EndFunc Func _Calc() If (GUICtrlRead($h)/GUICtrlRead($arh)*GUICtrlRead($arw))>GuiCtrlRead($w) then GuiCtrlSetData($new_w,GuiCtrlRead($w)) GuiCtrlSetData($dif_w,"") else GuiCtrlSetData($new_w,Round(GuiCtrlRead($h)/GUICtrlRead($arh)*GUICtrlRead($arw),0)) GuiCtrlSetData($dif_w,Round(GuiCtrlRead($h)/GUICtrlRead($arh)*GUICtrlRead($arw),0)-GuiCtrlRead($w)) EndIf If (GUICtrlRead($w)/GUICtrlRead($arw)*GUICtrlRead($arh))>GuiCtrlRead($h) then GuiCtrlSetData($new_h,GuiCtrlRead($h)) GuiCtrlSetData($dif_h,"") else GuiCtrlSetData($new_h,Round(GuiCtrlRead($w)/GUICtrlRead($arw)*GUICtrlRead($arh),0)) GuiCtrlSetData($dif_h,Round(GuiCtrlRead($w)/GUICtrlRead($arw)*GUICtrlRead($arh),0)-GuiCtrlRead($h)) EndIf GUICtrlSetColor($new_w,0x009900) GUICtrlSetColor($dif_w,0x009900) GUICtrlSetColor($new_h,0x009900) GUICtrlSetColor($dif_h,0x009900) EndFunc Func _Reverse() If (GUICtrlRead($h)/GUICtrlRead($arh)*GUICtrlRead($arw))<GuiCtrlRead($w) then GuiCtrlSetData($new_w,GuiCtrlRead($w)) GuiCtrlSetData($dif_w,"") else GuiCtrlSetData($new_w,Round(GuiCtrlRead($h)/GUICtrlRead($arh)*GUICtrlRead($arw),0)) GuiCtrlSetData($dif_w,"+" & Round(GuiCtrlRead($h)/GUICtrlRead($arh)*GUICtrlRead($arw),0)-GuiCtrlRead($w)) EndIf If (GUICtrlRead($w)/GUICtrlRead($arw)*GUICtrlRead($arh))<GuiCtrlRead($h) then GuiCtrlSetData($new_h,GuiCtrlRead($h)) GuiCtrlSetData($dif_h,"") else GuiCtrlSetData($new_h,Round(GuiCtrlRead($w)/GUICtrlRead($arw)*GUICtrlRead($arh),0)) GuiCtrlSetData($dif_h,"+" & Round(GuiCtrlRead($w)/GUICtrlRead($arw)*GUICtrlRead($arh),0)-GuiCtrlRead($h)) EndIf GUICtrlSetColor($new_w,0xee0000) GUICtrlSetColor($dif_w,0xee0000) GUICtrlSetColor($new_h,0xee0000) GUICtrlSetColor($dif_h,0xee0000) EndFunc Func _Restart() if @compiled then Run('"' & @ScriptFullPath & '"') Else Run(FileGetShortName(@AutoItExe) & " " & '"' & @ScriptFullPath &'"') exit EndIf EndFunc While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_DROPPED _DragDrop() Case $Button1 _Calc() Case $Button2 _Reverse() Case $Button3 _Restart() Case $Button4 Exit EndSwitch Sleep(10) If GUICtrlRead($IBToogle) = $GUI_CHECKED and $Toggle=0 Then _ToggleOn() elseif GUICtrlRead($IBToogle) = $GUI_UNCHECKED and $Toggle=1 Then _ToggleOff() EndIf WEnd The script checks written height/width and tells you how much you need to crop / add to get the set aspect ratio (default ratio being set at 16:9) and it has a checkbox that toggles a drag and drop image basket.
guinness Posted May 20, 2013 Posted May 20, 2013 You might want to check that GUICreate line again before you declare it as solved. UDF List:  _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
Mriswith2k Posted May 20, 2013 Author Posted May 20, 2013 You might want to check that GUICreate line again before you declare it as solved. hmm what is the issue though ?, I can't see the problem and it seems to be working. :/
Moderators Melba23 Posted May 20, 2013 Moderators Posted May 20, 2013 Mriswith2k, More by luck than judgement in my opinion. Take a look at the order of the parameters as set out in the Help file and what you have in that script - your order is not correct. M23  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Â
Mriswith2k Posted May 20, 2013 Author Posted May 20, 2013 Mriswith2k, More by luck than judgement in my opinion. Take a look at the order of the parameters as set out in the Help file and what you have in that script - your order is not correct. M23 Will do, I did mention I mainly do it by trial and error though ;P
guinness Posted May 20, 2013 Posted May 20, 2013 OK, but this is likely to lead to problems in the future if you don't read the documentation thoroughly. UDF List:  _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
Mriswith2k Posted May 20, 2013 Author Posted May 20, 2013 (edited) OK, but this is likely to lead to problems in the future if you don't read the documentation thoroughly. Yea I usually do, I've just been switching the different parameters around a lot. Oh I see, now I get why it was taking the program bar into account when calculating the gui area, not sure what I thought at the time but guess I missed that you needed to set the style and just not the extended one, will fix ! edit: actually setting $WS_Border seems to have the same effect as the WinGetHandle("AutoItWinGetTitle") I had before, but at least now everything seems to be correct . Â expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> Global $Toggle=0 #Region ### START Koda GUI section ### Form= $Form1 = GUICreate(" Image Dimensions", 320, 69, -1, -1,$WS_BORDER,$WS_EX_TOPMOST) $Button1 = GUICtrlCreateButton("Calc", 114, 3, 60, 19) $Button2 = GUICtrlCreateButton("Reverse", 114, 21, 60, 19) $w = GUICtrlCreateInput("", 4, 21, 49, 18,BitOr($SS_CENTER,$ES_NUMBER)) $h = GUICtrlCreateInput("", 61, 21, 49, 18,BitOr($SS_CENTER,$ES_NUMBER)) $arw = GUICtrlCreateInput("", 33, 4, 20, 16,BitOr($SS_CENTER,$ES_NUMBER)) GuiCtrlSetData($arw,16) $arh = GUICtrlCreateInput("", 61, 4, 20, 16,BitOr($SS_CENTER,$ES_NUMBER)) GuiCtrlSetData($arh,9) $Label1 = GUICtrlCreateLabel("W", 10, 5, 20, 15,$SS_CENTER) $Label2 = GUICtrlCreateLabel("H", 84, 5, 20, 15,$SS_CENTER) $Label3 = GUICtrlCreateLabel(":", 56, 4, 5, 11) $Label4 = GUICtrlCreateLabel("x", 54, 22, 7, 11) $new_w= GUICtrlCreateLabel("Width", 178, 21, 49, 18,$SS_CENTER, $SS_BLACKFRAME) $dif_w = GUICtrlCreateLabel("Diff", 178, 3, 49, 18,$SS_CENTER, $SS_BLACKFRAME) $new_h = GUICtrlCreateLabel("Height", 231, 21, 49, 18,$SS_CENTER, $SS_BLACKFRAME) $dif_h = GUICtrlCreateLabel("Diff", 231, 3, 49, 18,$SS_CENTER, $SS_BLACKFRAME) $IBToogle = GUICtrlCreateCheckbox("IB", 283, 22, 30, 19) GUICtrlSetTip($IBToogle, "Image Basket for Drag and drop") $Button3 = GUICtrlCreateButton("R", 282, 3, 15, 19) GUICtrlSetTip($Button3, "Reload Script / Program") $Button4 = GUICtrlCreateButton("X", 297, 3, 15, 19) GUICtrlSetTip($Button4, "Exit") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $ImageBasket = GUICreate("Image Basket",40,76, -1, -1,$WS_BORDER,BitOR($WS_EX_ACCEPTFILES, $WS_EX_TOPMOST)) $DragDrop = GUICtrlCreateLabel("Drag" & @CRLF & "and" & @CRLF &"Drop", 2, 2, 114, 45,$SS_CENTER, $SS_BLACKFRAME) GUICtrlSetState($DragDrop, $GUI_DROPACCEPTED) GUICtrlSetState($IBToogle, $GUI_UNCHECKED) Func _DragDrop() _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile(@GUI_DRAGFILE) GuiCtrlSetData($w,_GDIPlus_ImageGetWidth($hImage)) GuiCtrlSetData($h,_GDIPlus_ImageGetHeight($hImage)) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() _Calc() EndFunc Func _ToggleOn() $Toggle=1 GUISetState(@SW_SHOW,$ImageBasket) GUISetState(@SW_ENABLE, $ImageBasket) EndFunc Func _ToggleOff() $Toggle=0 GUISetState(@SW_HIDE,$ImageBasket) GUISetState(@SW_DISABLE, $ImageBasket) EndFunc Func _Calc() If (GUICtrlRead($h)/GUICtrlRead($arh)*GUICtrlRead($arw))>GuiCtrlRead($w) then GuiCtrlSetData($new_w,GuiCtrlRead($w)) GuiCtrlSetData($dif_w,"") else GuiCtrlSetData($new_w,Round(GuiCtrlRead($h)/GUICtrlRead($arh)*GUICtrlRead($arw),0)) GuiCtrlSetData($dif_w,Round(GuiCtrlRead($h)/GUICtrlRead($arh)*GUICtrlRead($arw),0)-GuiCtrlRead($w)) EndIf If (GUICtrlRead($w)/GUICtrlRead($arw)*GUICtrlRead($arh))>GuiCtrlRead($h) then GuiCtrlSetData($new_h,GuiCtrlRead($h)) GuiCtrlSetData($dif_h,"") else GuiCtrlSetData($new_h,Round(GuiCtrlRead($w)/GUICtrlRead($arw)*GUICtrlRead($arh),0)) GuiCtrlSetData($dif_h,Round(GuiCtrlRead($w)/GUICtrlRead($arw)*GUICtrlRead($arh),0)-GuiCtrlRead($h)) EndIf GUICtrlSetColor($new_w,0x009900) GUICtrlSetColor($dif_w,0x009900) GUICtrlSetColor($new_h,0x009900) GUICtrlSetColor($dif_h,0x009900) EndFunc Func _Reverse() If (GUICtrlRead($h)/GUICtrlRead($arh)*GUICtrlRead($arw))<GuiCtrlRead($w) then GuiCtrlSetData($new_w,GuiCtrlRead($w)) GuiCtrlSetData($dif_w,"") else GuiCtrlSetData($new_w,Round(GuiCtrlRead($h)/GUICtrlRead($arh)*GUICtrlRead($arw),0)) GuiCtrlSetData($dif_w,"+" & Round(GuiCtrlRead($h)/GUICtrlRead($arh)*GUICtrlRead($arw),0)-GuiCtrlRead($w)) EndIf If (GUICtrlRead($w)/GUICtrlRead($arw)*GUICtrlRead($arh))<GuiCtrlRead($h) then GuiCtrlSetData($new_h,GuiCtrlRead($h)) GuiCtrlSetData($dif_h,"") else GuiCtrlSetData($new_h,Round(GuiCtrlRead($w)/GUICtrlRead($arw)*GUICtrlRead($arh),0)) GuiCtrlSetData($dif_h,"+" & Round(GuiCtrlRead($w)/GUICtrlRead($arw)*GUICtrlRead($arh),0)-GuiCtrlRead($h)) EndIf GUICtrlSetColor($new_w,0xee0000) GUICtrlSetColor($dif_w,0xee0000) GUICtrlSetColor($new_h,0xee0000) GUICtrlSetColor($dif_h,0xee0000) EndFunc Func _Restart() if @compiled then Run('"' & @ScriptFullPath & '"') Else Run(FileGetShortName(@AutoItExe) & " " & '"' & @ScriptFullPath &'"') exit EndIf EndFunc While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_DROPPED _DragDrop() Case $Button1 _Calc() Case $Button2 _Reverse() Case $Button3 _Restart() Case $Button4 Exit EndSwitch Sleep(10) If GUICtrlRead($IBToogle) = $GUI_CHECKED and $Toggle=0 Then _ToggleOn() elseif GUICtrlRead($IBToogle) = $GUI_UNCHECKED and $Toggle=1 Then _ToggleOff() EndIf WEnd This should hopefully be it, just one quick last question tho , the GUICtrlCreateLabel options SS_Center / SS_Blackframe, are they supposed to be written in "$SS_#, $SS_#" format since every other way of typing them (even just using the blackframe) seems to make it not display any text. Edited May 20, 2013 by Mriswith2k
careca Posted May 20, 2013 Posted May 20, 2013 Nice, the reason i posted the single drop code is because i was under the impression you wanted to drop a file at a time, therefore, no need for more code. Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe
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