Jump to content
FMS

Saving GUI info external

Recommended Posts

FMS

Dear reader,

 

At the moment I'm trying to make a script that is changeble by the users.
It is a script that type's words for you whish u can change what it should be.
I was thinking that the users may change the button settings in the second tab whit a pull down menu.
 

At this point the text that must be typed in are hard coded in the program.
I know that I must "save" the text in a diffrent file but i don't now how.
Also mine search on the net or forum wasn't fruitfull.(maybe i was looking wrong;))

Could somebody push me in the right direction?
(I'm still al little bit new at this so any help or info is appreciated)

 

thanks in advanced.

 

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 318, 228, 192, 124)

$Tab1 = GUICtrlCreateTab(8, 32, 289, 177)
$TabSheet1 = GUICtrlCreateTabItem("TabSheet1")
$Btn001 = GUICtrlCreateButton("Button1", 25, 68, 75, 25)
$Btn002 = GUICtrlCreateButton("Button2", 110, 68, 75, 25)
$Btn003 = GUICtrlCreateButton("Button3", 196, 68, 75, 25)
$Btn004 = GUICtrlCreateButton("Button4", 25, 100, 75, 25)
$Btn005 = GUICtrlCreateButton("Button5", 110, 100, 75, 25)
$Btn006 = GUICtrlCreateButton("Button6", 196, 100, 75, 25)
$Btn007 = GUICtrlCreateButton("Button7", 25, 132, 75, 25)
$Btn008 = GUICtrlCreateButton("Button8", 110, 132, 75, 25)
$Btn009 = GUICtrlCreateButton("Button9", 196, 132, 75, 25)
$Btn010 = GUICtrlCreateButton("Button10", 25, 164, 75, 25)
$Btn011 = GUICtrlCreateButton("Button11", 110, 164, 75, 25)
$Btn012 = GUICtrlCreateButton("Button12", 196, 164, 75, 25)

$TabSheet2 = GUICtrlCreateTabItem("TabSheet2")
$Combo1 = GUICtrlCreateCombo("", 144, 72, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, " 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12")
$Btn013 = GUICtrlCreateButton("Button13", 40, 168, 75, 25)
$Btn014 = GUICtrlCreateButton("Button14", 152, 168, 75, 25)

GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
         Case $Btn001
            send("{ALTDOWN}{TAB}{ALTUP}")
            Sleep(1000)
            Send ("Button 1 is pushed")
         Case $Btn002
            send("{ALTDOWN}{TAB}{ALTUP}")
            Sleep(1000)
            Send ("Button 2 is pushed")
         Case $Btn003
            send("{ALTDOWN}{TAB}{ALTUP}")
            Sleep(1000)
            Send ("Button 3 is pushed")
         Case $Btn004
            send("{ALTDOWN}{TAB}{ALTUP}")
            Sleep(1000)
            Send ("Button 4 is pushed")
         Case $Btn005
            send("{ALTDOWN}{TAB}{ALTUP}")
            Sleep(1000)
            Send ("Button 5 is pushed")
         Case $Btn006
            send("{ALTDOWN}{TAB}{ALTUP}")
            Sleep(1000)
            Send ("Button 6 is pushed")
         Case $Btn007
            send("{ALTDOWN}{TAB}{ALTUP}")
            Sleep(1000)
            Send ("Button 7 is pushed")
         Case $Btn008
            send("{ALTDOWN}{TAB}{ALTUP}")
            Sleep(1000)
            Send ("Button 8 is pushed")
         Case $Btn009
            send("{ALTDOWN}{TAB}{ALTUP}")
            Sleep(1000)
            Send ("Button 9 is pushed")
         Case $Btn010
            send("{ALTDOWN}{TAB}{ALTUP}")
            Sleep(1000)
            Send ("Button 10 is pushed")
         Case $Btn011
            send("{ALTDOWN}{TAB}{ALTUP}")
            Sleep(1000)
            Send ("Button 11 is pushed")
         Case $Btn012
            send("{ALTDOWN}{TAB}{ALTUP}")
            Sleep(1000)
            Send ("Button 12 is pushed")
         Case $Btn013
            send("{ALTDOWN}{TAB}{ALTUP}")
            Sleep(1000)
            Send ("Button 13 is pushed")
         Case $Btn014
            send("{ALTDOWN}{TAB}{ALTUP}")
            Sleep(1000)
            Send ("Button 14 is pushed")
    EndSwitch
WEnd

 


as finishing touch god created the dutch

Share this post


Link to post
Share on other sites
AutoBert

You can use IniWrite and IniRead, but there a many other solutions possible. 

Share this post


Link to post
Share on other sites
TheSaint

Not sure why you are sending your ALT and TAB commands, but you could reduce your code by using a function.

Global $altab

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
         Case $Btn001
            SendAltTabCommands(1)
         Case $Btn002
            SendAltTabCommands(2)
         Case $Btn003
            SendAltTabCommands(3)
         Case $Btn004
            SendAltTabCommands(4)
         Case $Btn005
            SendAltTabCommands(5)
         Case $Btn006
            SendAltTabCommands(6)
         Case $Btn007
            SendAltTabCommands(7)
         Case $Btn008
            SendAltTabCommands(8)
         Case $Btn009
            SendAltTabCommands(9)
         Case $Btn010
            SendAltTabCommands(10)
         Case $Btn011
            SendAltTabCommands(11)
         Case $Btn012
            SendAltTabCommands(12)
         Case $Btn013
            SendAltTabCommands(13)
         Case $Btn014
            SendAltTabCommands(14)
    EndSwitch
WEnd

Func SendAltTabCommands($altab)
    send("{ALTDOWN}{TAB}{ALTUP}")
    Sleep(1000)
    Send ("Button " & $altab & " is pushed")
EndFunc

 


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites
FMS

thanks autobert and the saint...
This was totaly what i needed..
I was searching in the wrong direction :(


as finishing touch god created the dutch

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • XinYoung
      By XinYoung
      For fun, I'm building an app that opens a webpage and refreshes it every 30 seconds.
      But once the script performs _IEAction($oIE, "refresh"), the GUI closes.
      Any help is appreciated.
       

      #include <ButtonConstants.au3>
      #include <EditConstants.au3>
      #include <GUIConstantsEx.au3>
      #include <StaticConstants.au3>
      #include <WindowsConstants.au3>
      #include <WinAPIFiles.au3>
      #include <Array.au3>
      #include <File.au3>
      #include <Excel.au3>
      #include <DateTimeConstants.au3>
      #include <MsgBoxConstants.au3>
      #include <WinAPIShellEx.au3>
      #include <MsgBoxConstants.au3>
      #include <Date.au3>
      #include <ComboConstants.au3>
      #include <guimenu.au3>
      #include <IE.au3>
      HotKeySet("{F4}", "_Exit")
      ;Open the file(s) in the selected folder
      $extension = ".txt"
      $app2openWith = @SystemDir & "\notepad.exe"
      Func Begin()
          Global $loopTrick = 0
          #Region ### START Koda GUI section ### Form=c:\users\mchu\downloads\autoit\my code\form1.kxf
          Global $UI = GUICreate("Hit Em Up!", 256, 113, -1, -1)
          GUISetBkColor(0x000000)
          $menu = _GUICtrlMenu_GetSystemMenu($UI)
          _GUICtrlMenu_EnableMenuItem($menu, $SC_CLOSE, 1, False)
          Global $url = GUICtrlCreateInput("https://www.youtube.com/watch?v=dQw4w9WgXcQ", 81, 8, 160, 21)
          $Label1 = GUICtrlCreateLabel("Target:", 16, 8, 55, 17)
          GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
          GUICtrlSetColor(-1, 0x00FF00)
          Global $StartBut = GUICtrlCreateButton("Start", 16, 40, 67, 25)
          GUICtrlSetFont(-1, 13, 800, 0, "MS Sans Serif")
          GUICtrlSetBkColor(-1, 0x008000)
          $Label2 = GUICtrlCreateLabel("(Press F4 to Exit)", 96, 40, 8000, 17)
          GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
          GUICtrlSetColor(-1, 0x00FF00)
          GUISetState(@SW_SHOW)
          #EndRegion ### END Koda GUI section ###
          While 1
              $UIfunc = GUIGetMsg()
              Select
                  Case $UIfunc = $GUI_EVENT_CLOSE
                      _Exit()
                  Case $UIfunc = $StartBut
                      If GUICtrlRead($url) = "" Then
                          MsgBox(48, "Um...", "Give me a target you idiot.")
                      Else
                          GUICtrlSetState($url, $GUI_DISABLE)
                          GUICtrlSetState($StartBut, $GUI_DISABLE)
                          Start()
                      EndIf
              EndSelect
          WEnd
      EndFunc   ;==>Begin
      Func Start()
          If $loopTrick = 0 Then
              Global $oIE = _IECreate(GUICtrlRead($url))
              _IELoadWait($oIE)
              Again()
          ElseIf $loopTrick = 1 Then
              Sleep(3000)
              _IEAction($oIE, "refresh")
              Sleep(3000)
              Start()
          EndIf
      EndFunc   ;==>Start
      Func Again()
          $loopTrick = 1
          Start()
      EndFunc   ;==>Again
      Func _Exit()
          Exit
      EndFunc   ;==>_Exit
    • kcvinu
      By kcvinu
      Hi all,
      I have a button created with _GUICtrlButton_Create function. I know that this function returns a handle of button instead of an ID. So i have obtain control ID by calling _WinAPI_GetDlgCtrlID function. After that i have tried the GUICtrlSetBkColor function. But it didnt worked. Any suggestions will be appreciated. Thanks in advance. 
      Note : - The window which carries this button is not created with native gui create function. Instead, it is created with CreateWindowEx api function.
    • kcvinu
      By kcvinu
      Hi all,
      I am playing with _GUICtrlButton_Create function. How can i change this button's (or the entire form's) font ?. The in-built GUICtrlSetFont function is not working even when i convert the control handle to control ID with _WinAPI_GetDlgCtrlID ( ) function.  Do i need to use CreateFont api finction and send WM_SETFONT message ? Or is there any other easy and safe ways to do this ?. Thanks in advance.
      Note : This window is created by CreateWindowEx function, not by GUICreate function. 
    • Jake_s
      By Jake_s
      Hi All, 
       
      I am a begginer in auto it. I am trying to build simple gui that will show me if for example notepad.exe process is currently running on the system. I have built something like this, but when I execute it shows me message boxes, but I want the results to show in gui. If you can help me start with this.
       
      Thanks
       
        #include <MsgBoxConstants.au3>
      #include <GUIConstantsEx.au3>

      ActiveProcess()

      Func ActiveProcess()
      GUICreate("Act")
               ProcessExists("wuauclt.exe")

             If ProcessExists("wuauclt.exe") Then
       MsgBox($MB_SYSTEMMODAL, "", "Windows Upates are running")
           Else
       MsgBox($MB_SYSTEMMODAL, "", "Windows Updates are not running")
       EndIf
         ;Notepad

               ProcessExists("notepad.exe")

               If ProcessExists("notepad.exe") Then
      MsgBox($MB_SYSTEMMODAL, "", "Notepad is running")
              Else
      MsgBox($MB_SYSTEMMODAL, "", "Notepad is not running")
      EndIf  
       
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.