careca Posted January 5, 2018 Posted January 5, 2018 Hi, got this code that gets called when the correspondent button is clicked. Wondering if there's a way to shorten this up, as right now i have 20 of these, GUICtrlCreateButton("...", $FS1X, $FS1Y, 20, 22) GUICtrlSetOnEvent(-1, "SelectFile1") GUICtrlSetTip(-1, $Tip3, "FileSelect", 1) GUICtrlCreateButton("...", $FS1X, $FS1Y + 30, 20, 22) GUICtrlSetOnEvent(-1, "SelectFile2") GUICtrlSetTip(-1, $Tip3, "FileSelect", 1) GUICtrlCreateButton("...", $FS1X, $FS1Y + 60, 20, 22) GUICtrlSetOnEvent(-1, "SelectFile3") GUICtrlSetTip(-1, $Tip3, "FileSelect", 1) Func SelectFile1() $FileDlgApp = FileOpenDialog('Select File', @DesktopDir, "All (*.*)") If Not @error Then IniWrite($Ini, "abc", "AppStr1", $FileDlgApp) GUICtrlSetData($UserAppStr[1], $FileDlgApp) EndIf EndFunc ;==>SelectFile1 ;============================================================================= Func SelectFile2() $FileDlgApp = FileOpenDialog('Select File', @DesktopDir, "All (*.*)") If Not @error Then IniWrite($Ini, "abc", "AppStr2", $FileDlgApp) GUICtrlSetData($UserAppStr[2], $FileDlgApp) EndIf EndFunc ;==>SelectFile2 ;============================================================================= Func SelectFile3() $FileDlgApp = FileOpenDialog('Select File', @DesktopDir, "All (*.*)") If Not @error Then IniWrite($Ini, "abc", "AppStr3", $FileDlgApp) GUICtrlSetData($UserAppStr[3], $FileDlgApp) EndIf EndFunc ;==>SelectFile3 Thanks 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
spudw2k Posted January 5, 2018 Posted January 5, 2018 I would do something like this (tailor as necessary) $idBtnSelect1 = GUICtrlCreateButton("...", $FS1X, $FS1Y, 20, 22) GUICtrlSetOnEvent(-1, "SelectButtonEvent") GUICtrlSetTip(-1, $Tip3, "FileSelect", 1) $idBtnSelect2 = GUICtrlCreateButton("...", $FS1X, $FS1Y + 30, 20, 22) GUICtrlSetOnEvent(-1, "SelectButtonEvent") GUICtrlSetTip(-1, $Tip3, "FileSelect", 1) $idBtnSelect3 = GUICtrlCreateButton("...", $FS1X, $FS1Y + 60, 20, 22) GUICtrlSetOnEvent(-1, "SelectButtonEvent") GUICtrlSetTip(-1, $Tip3, "FileSelect", 1) Func SelectButtonEvent() Switch @GUI_CtrlId Case $idBtnSelect1 SelectFile(1) Case $idBtnSelect2 SelectFile(2) Case $idBtnSelect3 SelectFile(3) EndSwitch EndFunc Func SelectFile($iKey) $FileDlgApp = FileOpenDialog('Select File', @DesktopDir, "All (*.*)") If Not @error Then IniWrite($Ini, "abc", "AppStr" & $iKey, $FileDlgApp) GUICtrlSetData($UserAppStr[$iKey], $FileDlgApp) EndIf EndFunc careca 1 Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
careca Posted January 5, 2018 Author Posted January 5, 2018 Looks like a good idea. thank you. 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
careca Posted January 5, 2018 Author Posted January 5, 2018 End result for 20 buttons if anyone cares. Did some changes but i used the base principle. thanks. $SelBut[1] = GUICtrlCreateButton("...", $FS1X, $FS1Y, 20, 22) GUICtrlSetOnEvent(-1, "SelectFile") GUICtrlSetTip(-1, $Tip3, "FileSelect", 1) $SelBut[2] = GUICtrlCreateButton("...", $FS1X, $FS1Y + 30, 20, 22) GUICtrlSetOnEvent(-1, "SelectFile") GUICtrlSetTip(-1, $Tip3, "FileSelect", 1) $SelBut[3] = GUICtrlCreateButton("...", $FS1X, $FS1Y + 60, 20, 22) GUICtrlSetOnEvent(-1, "SelectFile") GUICtrlSetTip(-1, $Tip3, "FileSelect", 1) Func SelectFile() Local $f = 1 For $f = 1 To 20 If @GUI_CtrlId = $SelBut[$f] Then $FileDlgApp = FileOpenDialog('Select File', @DesktopDir, "All (*.*)") If Not @error Then IniWrite($Ini, "Triggers", "AppStr" & $f, $FileDlgApp) GUICtrlSetData($UserAppStr[$f], $FileDlgApp) EndIf EndIf Next EndFunc ;==>SelectFile 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