Netol Posted November 11 Share Posted November 11 (edited) Hi my friends, Just to ask about to call a button of the same application I have this button with this code $__hGUI = GUICreate("PTGUI Automate V1", 720, 900, 1920, 0, -1, $WS_EX_ACCEPTFILES + $WS_EX_TOPMOST ) $But_check_1 = GUICtrlCreateButton("Check 1", 245, 118, 70, 25) Local $but_check1h = GUICtrlGetHandle($But_check_1) i need to click $But_check_1 i tried using ControlClick command best regards Edited November 11 by Netol Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 11 Moderators Share Posted November 11 Netol, Why do you need to press a button in your own app? Surely all you need to is call the same code as would run if the button were pressed by an external operation. 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 Link to comment Share on other sites More sharing options...
Netol Posted November 11 Author Share Posted November 11 (edited) thanks for your responce If it is possible to do it another way it would be great i need to call this codes with only one button case $But_check_1 case $But_check_2 case $But_check_3 case $But_check_4 case $But_check_5 Edited November 11 by Netol Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 11 Moderators Share Posted November 11 Netol, That is a clear as mud. Do you mean you wish a single button to run 5 separate checks? If so then what determines which check is run? Please explain more clearly just what you are trying to do. 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 Link to comment Share on other sites More sharing options...
Netol Posted November 11 Author Share Posted November 11 I want the 5 buttons to be pressed automatically, one by one. Link to comment Share on other sites More sharing options...
spudw2k Posted November 11 Share Posted November 11 What Melba was trying to convey is you shouldn't have to click each button, but instead run the code that occurs when a button click Msg is detected. I imagine you have some code beneath each case...is that correct? case $But_check_1 ;button 1 code... ;... ;... case $But_check_2 ;button 2 code... ;... ;... case $But_check_3 ;button 3 code... ;... ;... case $But_check_4 ;button 4 code... ;... ;... case $But_check_5 ;button 5 code... ;... ;... Netol 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 Link to comment Share on other sites More sharing options...
Netol Posted November 11 Author Share Posted November 11 18 minutes ago, spudw2k said: What Melba was trying to convey is you shouldn't have to click each button, but instead run the code that occurs when a button click Msg is detected. I imagine you have some code beneath each case...is that correct? case $But_check_1 ;button 1 code... ;... ;... case $But_check_2 ;button 2 code... ;... ;... case $But_check_3 ;button 3 code... ;... ;... case $But_check_4 ;button 4 code... ;... ;... case $But_check_5 ;button 5 code... ;... ;... Yes, my code has that structure In my case i need to execute case $But_check_1 and them case $But_check_2 and them case $But_check_3 and them case $But_check_4 and them case $But_check_5 with only one button Link to comment Share on other sites More sharing options...
Dan_555 Posted November 12 Share Posted November 12 (edited) If you want to run 5 different code things with only one button increase a variable with each click, then use the switch command to run the code ... something like: #include <GUIConstants.au3> Local $hGUI = GUICreate ( "Test" , 300 , 50 ) Local $idButton = GUICtrlCreateButton ( "LetsGo" , 0 , 0 , 50 , 20 ) GUICtrlSetBkColor($idButton, 0xf0f0f0) GUISetState ( ) $stage=-1 While True Switch GUIGetMsg ( ) Case $GUI_EVENT_CLOSE ExitLoop Case $idButton $stage=$stage+1 Switch $stage case 0 WinSetTitle ($hGUI,"","Stage 0") GUICtrlSetBkColor($idButton, 0xfff00) case 1 WinSetTitle ($hGUI,"","Stage 1") GUICtrlSetBkColor($idButton, 0xffff80) case 2 WinSetTitle ($hGUI,"","Stage 2") GUICtrlSetBkColor($idButton, 0x00ffff) case 3 $stage=-1 GUICtrlSetBkColor($idButton, 0xf0f0f0) WinSetTitle ($hGUI,"","Test") EndSwitch EndSwitch WEnd if you need to run it all in a single click ... place the code in 5 functions then do: case $But_check_1 func1() func2() func3() func4() func5() Edited November 12 by Dan_555 Netol 1 Some of my script sourcecode Link to comment Share on other sites More sharing options...
spudw2k Posted November 12 Share Posted November 12 I think Dan's recommendation isn't bad, but adds more complexity to account for. I would recommend creating a function/routine for each button case; something like this: expandcollapse popupcase $But_check_1 But1() case $But_check_2 But2() case $But_check_3 But3() case $But_check_4 But4() case $But_check_5 But5() Func But1() ;button 1 code... ;... ;... EndFunc Func But2() ;button 2 code... ;... ;... EndFunc Func But3() ;button 3 code... ;... ;... EndFunc Func But4() ;button 4 code... ;... ;... EndFunc Func But5() ;button 5 code... ;... ;... EndFunc then calling the functions directly in order: But1() But2() But3() But4() But5() Netol 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 Link to comment Share on other sites More sharing options...
Solution Werty Posted November 12 Solution Share Posted November 12 (edited) How about...(the but_check_all) #include <GUIConstants.au3> Local $hGUI = GUICreate ( "Test" , 300 , 250 ) Local $But_check_1 = GUICtrlCreateButton ( "Button 1" , 10 , 10 , 50 , 20 ) Local $But_check_2 = GUICtrlCreateButton ( "Button 2" , 10 , 40 , 50 , 20 ) Local $But_check_3 = GUICtrlCreateButton ( "Button 3" , 10 , 70 , 50 , 20 ) Local $But_check_4 = GUICtrlCreateButton ( "Button 4" , 10 , 100 , 50 , 20 ) Local $But_check_5 = GUICtrlCreateButton ( "Button 5" , 10 , 130 , 50 , 20 ) Local $But_check_All = GUICtrlCreateButton ( "Button All" , 10 , 170 , 50 , 20 ) GUISetState ( ) While True Switch GUIGetMsg ( ) Case $GUI_EVENT_CLOSE ExitLoop Case $But_check_1 ;Do something Case $But_check_2 ;Do something Case $But_check_3 ;Do something Case $But_check_4 ;Do something Case $But_check_5 ;Do something Case $But_check_All ControlClick($hGUI, "", "Button 1") ControlClick($hGUI, "", "Button 2") ControlClick($hGUI, "", "Button 3") ControlClick($hGUI, "", "Button 4") ControlClick($hGUI, "", "Button 5") EndSwitch WEnd Or in one line... BitAND(ControlClick($hGUI, "", "Button 1"), ControlClick($hGUI, "", "Button 2"), ControlClick($hGUI, "", "Button 3"), ControlClick($hGUI, "", "Button 4"), ControlClick($hGUI, "", "Button 5")) Edited November 12 by Werty Netol 1 Some guy's script + some other guy's script = my script! Link to comment Share on other sites More sharing options...
Netol Posted November 12 Author Share Posted November 12 1 hour ago, Werty said: How about...(the but_check_all) #include <GUIConstants.au3> Local $hGUI = GUICreate ( "Test" , 300 , 250 ) Local $But_check_1 = GUICtrlCreateButton ( "Button 1" , 10 , 10 , 50 , 20 ) Local $But_check_2 = GUICtrlCreateButton ( "Button 2" , 10 , 40 , 50 , 20 ) Local $But_check_3 = GUICtrlCreateButton ( "Button 3" , 10 , 70 , 50 , 20 ) Local $But_check_4 = GUICtrlCreateButton ( "Button 4" , 10 , 100 , 50 , 20 ) Local $But_check_5 = GUICtrlCreateButton ( "Button 5" , 10 , 130 , 50 , 20 ) Local $But_check_All = GUICtrlCreateButton ( "Button All" , 10 , 170 , 50 , 20 ) GUISetState ( ) While True Switch GUIGetMsg ( ) Case $GUI_EVENT_CLOSE ExitLoop Case $But_check_1 GUICtrlCreateLabel("Button 1", 100, 10) Case $But_check_2 GUICtrlCreateLabel("Button 2", 100, 40) Case $But_check_3 GUICtrlCreateLabel("Button 3", 100, 70) Case $But_check_4 GUICtrlCreateLabel("Button 4", 100, 100) Case $But_check_5 GUICtrlCreateLabel("Button 5", 100, 130) Case $But_check_All ControlClick($hGUI, "", "Button 1") ControlClick($hGUI, "", "Button 2") ControlClick($hGUI, "", "Button 3") ControlClick($hGUI, "", "Button 4") ControlClick($hGUI, "", "Button 5") EndSwitch WEnd Or in one line... BitAND(ControlClick($hGUI, "", "Button 1"), ControlClick($hGUI, "", "Button 2"), ControlClick($hGUI, "", "Button 3"), ControlClick($hGUI, "", "Button 4"), ControlClick($hGUI, "", "Button 5")) Thanks to everyone who responded This is the solution I was waiting for Thank you so much Link to comment Share on other sites More sharing options...
spudw2k Posted November 12 Share Posted November 12 2 hours ago, Werty said: Case $But_check_1 GUICtrlCreateLabel("Button 1", 100, 10) Case $But_check_2 GUICtrlCreateLabel("Button 2", 100, 40) Case $But_check_3 GUICtrlCreateLabel("Button 3", 100, 70) Case $But_check_4 GUICtrlCreateLabel("Button 4", 100, 100) Case $But_check_5 GUICtrlCreateLabel("Button 5", 100, 130) Not a huge fan of creating a new label every time a button is clicked. Seems unnecessary and a recipe for a memory leak. Am I missing something? Werty 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 Link to comment Share on other sites More sharing options...
Werty Posted November 12 Share Posted November 12 (edited) 22 minutes ago, spudw2k said: Not a huge fan of creating a new label every time Completely agree, it was just for sake of the example, i just picked something fast, It's not what OP needed so he wont be using it, only the button part he needed, but nice call, I'll edit the example if someone else should read it and use it. Edited November 12 by Werty Netol 1 Some guy's script + some other guy's script = my script! Link to comment Share on other sites More sharing options...
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