Jump to content
Sign in to follow this  
JonBMN

[SOLVED]Config GUI; Saving to .Ini file using save button

Recommended Posts

I'm trying to make a GUI interface that recieves data from my Archangel.ini as default, but can be changed and then saved to the .ini from the GUI program. I'm having trouble creating the save button function that actually writes to the .ini file. Any help would be much appreciated.

My ConfigurationGUI.au3

#include <GlobalVars.au3>
#include <ArchLib.au3>
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
#include <GuiButton.au3>
#include <StaticConstants.au3>
#include <EditConstants.au3>
Global $ButtonSave, $ButtonCancel, $msg, $PRI1, $PRI2, $PRI3, $PRI4, $PRI5, $PRI6, $PRI7, $PRI8, $PRI9, $PRI10, $msg2


DecodeIni("Archangel.Ini", False) ;Decodes the .Ini File
;ConsoleWrite($IniProgramGroup & @CR)
GUICreate("Archangel Configuration Setup", 500, 400) ;Creates the GUI window
GUISetBkColor(0x00E0eeeF) ;Sets Background color
$ButtonSave = GUICtrlCreateButton("Save", 200, 350, 45, 30) ;Save button
$ButtonCancel = GUICtrlCreateButton("Cancel", 300, 350, 45, 30) ;Cancel Button
GUICtrlCreateTab(0, 0, 500, 340) ;Creates the tab
GUICtrlCreateTabItem("Speed") ;First tab item
GUICtrlCreateLabel("Speed Settings", 10, 25) ;Creates the label for the configuration drop down menu
GUICtrlCreateLabel("Show the Speed:", 10, 100) ;Creates the label for the Show the speed config
GUICtrlCreateLabel("Speed limit:", 10, 175) ;Creates the label for the Speed limit config
GUICtrlCreateCombo("", 275, 100) ;Creates the drop down box
GUICtrlSetData(10, "Yes|No", $ShowSpeed) ;Puts the data into the drop down box
GUICtrlCreateCombo("", 275, 175) ;Creates the drop down box
GUICtrlSetData(11, "1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30", $SpeedLimit) ;Puts the data into the drop down box

GUICtrlCreateTabItem("Serial Settings") ;Tab with serial settings
GUICtrlCreateLabel("Serial Settings", 10, 25) ;Creates the label for the serial settings
GUICtrlCreateLabel("Communications Port:", 10, 75) ;Creates the label for the commport setting
GUICtrlCreateLabel("Baudrate:", 10, 150) ;Creates the label for the Baudrate
GUICtrlCreateCombo("", 275, 75) ;Creates the drop down box
GUICtrlSetData(16, "1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50", $NumericPort) ;Puts data into drop down box
GUICtrlCreateCombo("", 275, 150) ;Creates drop down box
GUICtrlSetData(17, "2400|4800|9600|19200|38400|57600|115200|31250", $BaudRate) ;Puts data into drop down box

GUICtrlCreateTabItem("Accesories") ;keyboard, mouse, touchscreen options
GUICtrlCreateLabel("Accesories settings", 10, 25) ;Creates label for accesories settings
GUICtrlCreateLabel("Block options:", 10, 75) ;Creates the label for the block options
GUICtrlCreateCombo("", 275, 75) ;Creates the dorp down box
GUICtrlSetData(21, "None|Both|Mouse/Touchscreen|Keyboard", $AlphaBlock[$BlockOption]) ;Puts data into drop down box

GUICtrlCreateTabItem("Run Plates") ;Run plate option tab
GUICtrlCreateLabel("Ability to run plates", 10, 25) ;creates label for plate running config
GUICtrlCreateLabel("Run Plates", 10, 75) ;creates the label for plate running setting
GUICtrlCreateCombo("", 275, 75) ;creates drop down box
GUICtrlSetData(25, "Yes|No", $RunPlates) ;puts data into drop down box

GUICtrlCreateTabItem("Windows Priority") ;windows priority tab
GUICtrlCreateLabel("Select Windows Priority", 10, 25) ;creates label for windows priority config
GUICtrlCreateLabel("Priority 1:", 10, 40) ;creates label for windows priority 1
GUICtrlCreateLabel("Maximize:", 100, 40) ;creates label for maximize window
GUICtrlCreateLabel("Priority 2:", 10, 80) ;creates label for windows priority 2
GUICtrlCreateLabel("Maximize:", 100, 80) ;creates label for maximize window
GUICtrlCreateLabel("Priority 3:", 10, 120) ;creates label for windows priority 3
GUICtrlCreateLabel("Maximize:", 100, 120) ;creates label for maximize window
GUICtrlCreateLabel("Priority 4:", 10, 160) ;creates label for windows priority 4
GUICtrlCreateLabel("Maximize:", 100, 160) ;creates label for maximize window
GUICtrlCreateLabel("Priority 5:", 10, 200) ;creates label for windows priority 5
GUICtrlCreateLabel("Maximize:", 100, 200) ;creates label for maximize window
GUICtrlCreateLabel("Priority 6:", 200, 40) ;creates label for windows priority 6
GUICtrlCreateLabel("Maximize:", 300, 40) ;creates label for maximize window
GUICtrlCreateLabel("Priority 7:", 200, 80) ;creates label for windows priority 7
GUICtrlCreateLabel("Maximize:", 300, 80) ;creates label for maximize window
GUICtrlCreateLabel("Priority 8:", 200, 120) ;creates label for windows priority 8
GUICtrlCreateLabel("Maximize:", 300, 120) ;creates label for maximize window
GUICtrlCreateLabel("Priority 9:", 200, 160) ;creates label for windows priority 9
GUICtrlCreateLabel("Maximize:", 300, 160) ;creates label for maximize window
GUICtrlCreateLabel("Priority 10:", 200, 200) ;creates label for windows priority 10
GUICtrlCreateLabel("Maximize:", 300, 200) ;creates label for maximize window
GUICtrlCreateCombo("", 100, 55) ;Drop down box for maximize selection
GUICtrlSetData(48, "Yes|No", $IniMaximize[1]) ;puts data into drop down box for maximize selection
GUICtrlCreateCombo("", 100, 95) ;Drop down box for maximize selection
GUICtrlSetData(49, "Yes|No", $IniMaximize[2]) ;puts data into drop down box for maximize selection
GUICtrlCreateCombo("", 100, 135) ;Drop down box for maximize selection
GUICtrlSetData(50, "Yes|No", $IniMaximize[3]) ;puts data into drop down box for maximize selection
GUICtrlCreateCombo("", 100, 175) ;Drop down box for maximize selection
GUICtrlSetData(51, "Yes|No", $IniMaximize[4]) ;puts data into drop down box for maximize selection
GUICtrlCreateCombo("", 100, 215) ;Drop down box for maximize selection
GUICtrlSetData(52, "Yes|No", $IniMaximize[5]) ;puts data into drop down box for maximize selection
GUICtrlCreateCombo("", 300, 55) ;Drop down box for maximize selection
GUICtrlSetData(53, "Yes|No", $IniMaximize[6]) ;puts data into drop down box for maximize selection
GUICtrlCreateCombo("", 300, 95) ;Drop down box for maximize selection
GUICtrlSetData(54, "Yes|No", $IniMaximize[7]) ;puts data into drop down box for maximize selection
GUICtrlCreateCombo("", 300, 135) ;Drop down box for maximize selection
GUICtrlSetData(55, "Yes|No", $IniMaximize[8]) ;puts data into drop down box for maximize selection
GUICtrlCreateCombo("", 300, 175) ;Drop down box for maximize selection
GUICtrlSetData(56, "Yes|No", $IniMaximize[9]) ;puts data into drop down box for maximize selection
GUICtrlCreateCombo("", 300, 215) ;Drop down box for maximize selection
GUICtrlSetData(57, "Yes|No", $IniMaximize[10]) ;puts data into drop down box for maximize selection
$PRT1 = GUICtrlCreateCombo("", 10, 55) ;Drop down box for priority input
GUICtrlSetData(58, "Spillman Mobile|None|Example1|Example2", $IniPriority[1]) ;puts data into drop down box for priority input/selection
$PRT2 = GUICtrlCreateCombo("", 10, 95) ;Drop down box for priority input
GUICtrlSetData(59, "Spillman Mobile|None|Example1|Example2", $IniPriority[2]) ;puts data into drop down box for priority input/selection
$PRT3 = GUICtrlCreateCombo("", 10, 135) ;Drop down box for priority input
GUICtrlSetData(60, "Spillman Mobile|None|Example1|Example2", $IniPriority[3]) ;puts data into drop down box for priority input/selection
$PRT4 = GUICtrlCreateCombo("", 10, 175) ;Drop down box for priority input
GUICtrlSetData(61, "Spillman Mobile|None|Example1|Example2", $IniPriority[4]) ;puts data into drop down box for priority input/selection
$PRT5 = GUICtrlCreateCombo("", 10, 215) ;Drop down box for priority input
GUICtrlSetData(62, "Spillman Mobile|None|Example1|Example2", $IniPriority[5]) ;puts data into drop down box for priority input/selection
$PRT6 = GUICtrlCreateCombo("", 200, 55) ;Drop down box for priority input
GUICtrlSetData(63, "Spillman Mobile|None|Example1|Example2", $IniPriority[6]) ;puts data into drop down box for priority input/selection
$PRT7 = GUICtrlCreateCombo("", 200, 95) ;Drop down box for priority input
GUICtrlSetData(64, "Spillman Mobile|None|Example1|Example2", $IniPriority[7]) ;puts data into drop down box for priority input/selection
$PRT8 = GUICtrlCreateCombo("", 200, 135) ;Drop down box for priority input
GUICtrlSetData(65, "Spillman Mobile|None|Example1|Example2", $IniPriority[8]) ;puts data into drop down box for priority input/selection
$PRT9 = GUICtrlCreateCombo("", 200, 175) ;Drop down box for priority input
GUICtrlSetData(66, "Spillman Mobile|None|Example1|Example2", $IniPriority[9]) ;puts data into drop down box for priority input/selection
$PRT10 = GUICtrlCreateCombo("", 200, 215) ;Drop down box for priority input
GUICtrlSetData(67, "Spillman Mobile|None|Example1|Example2", $IniPriority[10]) ;puts data into drop down box for priority input/selection
GUISetState(@SW_SHOW) ;Shows the GUI window
;MsgBox(2, "Checker", $PRT1) ;Checks the ControlID
;MsgBox(2, "error detection", $DataSelect) ;error detection(combo 4)

;Makes cancel button and the close button(top right x) close the program
While -1
$msg = GUIGetMsg()
Select
Case $msg = $ButtonCancel Or $msg = $GUI_EVENT_CLOSE
Case "Show the speed"
If "Yes" Or "No" Then
FileWriteLine("Archangel.ini", 10)
EndIf
ExitLoop
EndSelect
WEnd

My GlobalVars.au3

; Path Variables
Global $IniName = "Archangel.ini"
Global $ProgramDir = @ProgramFilesDir & "\Archangel"

;From ini
Global $IniProgramGroup = ""
Global $IniVersion = ""
Global $ShowSpeed = "No"
Global $CommPort = ""
Global $NumericPort
Global $BaudRate = 9600
Global $SpeedLimit = 15
Global $ClearOnTop = "No"
Global $IniFiles, $IniFileName[10]
Global $IniPriorities, $IniPriority[11], $IniMaximize[11]
Global $RunPlates = "No"
Global $BlockOption = 1
Global $BlockMouse = True
Global $AlphaBlock[4]
$AlphaBlock[0] = "None"
$AlphaBlock[1] = "Both"
$AlphaBlock[2] = "Mouse/TouchScreen"
$AlphaBlock[3] = "Keyboard"

; Log Variables
Global $LogHandle = -1
Global $LogError = False
Global $LogDetail = "No"
Global $LogFile = ""
Global $Sequence = "Init"

; Log / Error / Debugs
Global $Debug = False
Global $IsErrorFatal = "No", $ErrorTitle = "", $ErrorMessage = ""

; Miscellaneous
Const $SpeedCursor = "Current speed is "
Global $LenSpeedCursor = StringLen($SpeedCursor)
Global $SFResult[2]
$SFResult[0] = "failed"
$SFResult[1] = "successful"

; Speed Variables
Global $LastSpeed = 0

; Communications to Herbie
Global $Kernel32Handle = -1
Global $SerialPortHandle = -1
Global $DCB_Struct = ""
Global $CommTimeout = ""
Global $CommTimeout_Struct = ""
Global $CommState = ""
Global $CommState_Struct = ""
Global $HerbieError = False
Global $ReceivedFromHerbie = ""
Global $SpeedValidation = "410D"
Global $CurrentSpeed = 0

; SDX Dongle
Global $SDXHandle = -1
Global $tSDXHID = DllStructCreate("DWORD")

My Archlib.au3

Func DecodeIni($FullIniPath, $LogIt)
Local $NotFound = "Not Found", $Result = 0, $Index = 0
$ErrorTitle = "Error Reading Initialization File"
$ErrorMessage = $FullIniPath
$IsErrorFatal = True
$IniProgramGroup = IniRead($FullIniPath, "Version", "ProgramGroup", $NotFound)
If $IniProgramGroup = $NotFound Then
MyError()
EndIf
$IniVersion = IniRead($FullIniPath, "Version", "VersionNumber", $NotFound)
If $IniVersion = $NotFound Then
_MyError()
EndIf
$NumericPort = IniRead($FullIniPath, "Communication", "Port", $NotFound)
If $IniVersion = $NotFound Then
_MyError()
EndIf
$CommPort = "COM" & $NumericPort
If ($NumericPort > 9) Then
$CommPort = "\\.\" & $CommPort
EndIf
$BaudRate = IniRead($FullIniPath, "Communication", "Baudrate", $NotFound)
If $IniVersion = $NotFound Then
_MyError()
EndIf
$SpeedLimit = IniRead($FullIniPath, "ProgramOptions", "SpeedLimit", $NotFound)
If $IniVersion = $NotFound Then
_MyError()
EndIf
$ShowSpeed = IniRead($FullIniPath, "ProgramOptions", "ShowSpeed", $NotFound)
If $IniVersion = $NotFound Then
_MyError()
EndIf
$ClearOnTop = IniRead($FullIniPath, "ProgramOptions", "ClearOnTop", $NotFound)
If $IniVersion = $NotFound Then
_MyError()
EndIf
$RunPlates = IniRead($FullIniPath, "ProgramOptions", "RunPlates", $NotFound)
If $IniVersion = $NotFound Then
_MyError()
EndIf
$Result = IniRead($FullIniPath, "ProgramOptions", "Block", $NotFound)
If $IniVersion = $NotFound Then
_MyError()
EndIf
$BlockMouse = True
Select
Case $Result = "None"
$BlockOption = 0
$BlockMouse = False
Case $Result = "Both"
$BlockOption = 1
Case $Result = "Mouse"
$BlockOption = 2
Case $Result = "Keyboard"
$BlockOption = 3
$BlockMouse = False
Case Else
$BlockOption = 0
EndSelect
$LogDetail = IniRead($FullIniPath, "LogOptions", "LogDetail", $NotFound)
If $IniVersion = $NotFound Then
_MyError()
EndIf
$LogFile = IniRead($FullIniPath, "LogOptions", "LogFile", $NotFound)
If $IniVersion = $NotFound Then
_MyError()
EndIf
$Index = 1
While 1
$IniFileName[$Index] = IniRead($FullIniPath, "Files", "File" & $Index, $NotFound)
If $IniFileName[$Index] = $NotFound Then
ExitLoop
EndIf
$Index += 1
WEnd
$IniFiles = $Index - 1
$Index = 1
While 1
$IniPriority[$Index] = IniRead($FullIniPath, "WindowPriorties", "WindowPriority" & $Index, $NotFound)
If $IniPriority[$Index] = $NotFound Then
ExitLoop
EndIf
$Index += 1
WEnd
$IniPriorities = $Index - 1
$Index = 1
While 1
$IniMaximize[$Index] = IniRead($FullIniPath, "WindowPriorties", "WindowMaximize" & $Index, $NotFound)
If $IniMaximize[$Index] = $NotFound Then
ExitLoop
EndIf
$Index += 1
WEnd
If $LogIt = False Then
Return
EndIf
WriteLog(" Ini Path: " & $FullIniPath)
WriteLog(" Program: " & $IniProgramGroup)
WriteLog(" Version: " & $IniVersion)
WriteLog(" Port: " & $CommPort)
WriteLog(" Baudrate: " & $BaudRate)
WriteLog("SpeedLimit: " & $SpeedLimit)
WriteLog(" ShowSpeed: " & $ShowSpeed)
WriteLog("ClearOnTop: " & $ClearOnTop)
WriteLog(" RunPlates: " & $RunPlates)
WriteLog(" Block: " & $AlphaBlock[$BlockOption])
WriteLog(" LogDetail: " & $LogDetail)
WriteLog(" LogFile: " & $LogFile)
WriteLog("Priorities: " & $IniPriorities)
If $IniPriorities >= 1 Then
For $Index = 1 To $IniPriorities
WriteLog("Priority " & $Index & ": " & $IniPriority[$Index])
WriteLog("Maximize " & $Index & ": " & $IniMaximize[$Index])
Next
EndIf
EndFunc

Func MyCopyProgressOn($Title, $SFileName, $DFileName, $FileSize, $Operation)
Local $DisplayName = ""
$DisplayName = "Source: " & StringLower($SFileName)
ProgressOn($Title, $DisplayName, "0 of " & _StringAddThousandsSepEx($FileSize) & " bytes " & $Operation & " (0%)")
EndFunc

Func MyCopyProgressSet($ProgressBytes, $FileSize, $Operation)
Local $Percent = 0
$Percent = Round((($ProgressBytes / $FileSize) * 100), 0)
If $Percent >= 100 Then
$Percent = 99
$ProgressBytes = $FileSize - 1
EndIf
ProgressSet($Percent, _StringAddThousandsSepEx($ProgressBytes) & " of " & _StringAddThousandsSepEx($FileSize) & " bytes " & $Operation & " (" & $Percent & "%)")
Sleep(1)
EndFunc

Func MyCopyProgressOff()
ProgressSet(100 , "Done")
Sleep(500)
ProgressOff()
EndFunc

Func MyError()
Beep()
MsgBox(0, $ErrorTitle, $ErrorMessage)
If $IsErrorFatal = True Then
Exit
EndIf
EndFunc

Func MyProgressCopy($FullSRC, $FullDST)
Dim $OptEnv = "", $OptVar = "", $size = 0, $count = 0, $timer = 0, $progress = 0, $in = 0, $out = 0
Local $Bin, $Chunk, $ProgTitle
$ErrorTitle = "Error Copying File"
$ErrorMessage = $FullSRC
$IsErrorFatal = True
; Turn off expanded environment or variables, can cause problems for binary read
$OptEnv = Opt("ExpandEnvStrings", 0)
$OptVar = Opt("ExpandVarStrings", 0)
; Get size of file to determine remaining
$Size = FileGetSize($FullSRC)
If $Size = 0 Then
MyError()
EndIf
; Set up initial variables
$Count = 0 ;keep count of bytes copied
$Chunk = 102400 ;amount of data to copy at a time (bytes) (10kB)
$Progtitle = "Copying File ..." ;title of progress bar window
$Timer = TimerInit() ;initialize timer to keep track of update frequency
; Show progress bar
MyCopyProgressOn("Copying File ...", $FullSRC, $FullDST, $size, "copied")
; Open input and output files (exit if error)
$In = FileOpen($FullSRC, 4)
If @error <> 0 Then
MyError()
EndIf
$Out = FileOpen($FullDST, 2)
If @error = -1 Then
FileClose($In)
MyError()
EndIf
; Start reading input
$Bin = FileRead($In, $Chunk)
While @error = 0
; Write chunk of data, keep trying for up to 10 seconds if failed
Do
FileWrite($Out, $Bin)
Until (@error = 0) Or (TimerDiff($timer) > 10000)
If @error <> 0 Then
FileClose($In)
FileClose($Out)
MyError()
EndIf
; Update copy counter
$Count = $Count + $Chunk
; Update progress as specified
MyCopyProgressSet($Count, $Size, "copied")
$timer = TimerInit()
; get chunk of data
$bin = FileRead($In, $Chunk)
WEnd
FileClose($In)
FileClose($Out)
MyCopyProgressOff()
; Reset expanded environment or variables
Opt("ExpandEnvStrings", $OptEnv)
Opt("ExpandVarStrings", $OptVar)
EndFunc

Func WaitWithProgress($Caption, $Seconds)
ProgressOn($Caption & ". Please wait ...", "")
Local $Loops = 0, $Delay = 0, $Percent = 0
$Loops = Round(($Seconds * 2.0),0)
$Delay = Round ((($Seconds / $Loops) * 1000), 0)
For $I = 1 to $Loops
$Percent = (($I / $Loops) * 100)
ProgressSet($Percent)
Sleep($Delay)
Next
ProgressOff()
EndFunc

Func TurnOffOnTop()
Local $Index = 0, $Result = 0, $WindowList, $iExStyles = 0, $Candidate = 0
$WindowList = WinList()
For $Index = 1 to $WindowList[0][0]
$iExStyles = _WinAPI_GetWindowLong($WindowList[$Index][1],$GWL_EXSTYLE)
$Candidate = ($WindowList[$Index][0] <> "") And (IsWindowVisible($WindowList[$Index][1]))
$Candidate = $Candidate And (BitAND($iExStyles,$WS_EX_TOPMOST))
$Candidate = $Candidate And (StringLeft($WindowList[$Index][0], $LenSpeedCursor) <> $SpeedCursor)
If $Candidate = 1 Then
$Result = WinSetOnTop($WindowList[$Index][1], "", 0)
WriteLog($WindowList[$Index][0] & " topmost set was: " & $SFResult[$Result])
EndIf
Next
EndFunc

Func IsWindowVisible($WindowHandle)
If BitAnd( WinGetState($WindowHandle), 2 ) Then
Return 1
Else
Return 0
EndIf
EndFunc

My Archangel.ini file

[Version]

ProgramGroup=Archangel

VersionNumber=1.00

[Communication]

Port=35

Baudrate=9600

[ProgramOptions]

SpeedLimit=25

ShowSpeed=No

ClearOnTop=Yes

RunPlates=No

Block=None

[LogOptions]

LogDetail=No

LogFile=Archangel.log

[Files]

File1=Archangel.exe

File2=sdx.dll

File3=Green.ico

File4=Red.ico

[WindowPriorties]

WindowPriority1=Spillman Mobile -

WindowMaximize1=Yes

Edited by JonBMN

Share this post


Link to post
Share on other sites

Just reverse the process you use to read from the INI file when you're writing to it. When you press save, you can (for example) use IniWrite($FullIniPath, "LogOptions", "LogDetail", $LogDetail). This will write to the LogOptions section, in the key LogDetail the contents of the variable $LogDetail.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

I'm stuck on getting the window to stay open because of the case statements I put in to save to the .ini file. Any suggestions?

Share this post


Link to post
Share on other sites

I'm not a mind reader, post the script so I can see what you're doing and perhaps I can figure out what is wrong.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#include <GlobalVars.au3>
#include <ArchLib.au3>
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
#include <GuiButton.au3>
#include <StaticConstants.au3>
#include <EditConstants.au3>
Global $ButtonSave, $ButtonCancel, $msg, $PRI1, $PRI2, $PRI3, $PRI4, $PRI5, $PRI6, $PRI7, $PRI8, $PRI9, $PRI10, $msg2


DecodeIni("Archangel.Ini", False)   ;Decodes the .Ini File
;ConsoleWrite($IniProgramGroup & @CR)
GUICreate("Archangel Configuration Setup", 500, 400)   ;Creates the GUI window
GUISetBkColor(0x00E0eeeF)   ;Sets Background color
$ButtonSave = GUICtrlCreateButton("Save", 200, 350, 45, 30)   ;Save button
$ButtonCancel = GUICtrlCreateButton("Cancel", 300, 350, 45, 30)    ;Cancel Button
GUICtrlCreateTab(0, 0, 500, 340)   ;Creates the tab
GUICtrlCreateTabItem("Speed")   ;First tab item
GUICtrlCreateLabel("Speed Settings", 10, 25)   ;Creates the label for the configuration drop down menu
GUICtrlCreateLabel("Show the Speed:", 10, 100)  ;Creates the label for the Show the speed config
GUICtrlCreateLabel("Speed limit:", 10, 175)   ;Creates the label for the Speed limit config
GUICtrlCreateCombo("", 275, 100)   ;Creates the drop down box
GUICtrlSetData(10, "Yes|No", $ShowSpeed)    ;Puts the data into the drop down box
GUICtrlCreateCombo("", 275, 175)   ;Creates the drop down box
GUICtrlSetData(11, "1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30", $SpeedLimit)    ;Puts the data into the drop down box

GUICtrlCreateTabItem("Serial Settings")    ;Tab with serial settings
GUICtrlCreateLabel("Serial Settings", 10, 25)   ;Creates the label for the serial settings
GUICtrlCreateLabel("Communications Port:", 10, 75)    ;Creates the label for the commport setting
GUICtrlCreateLabel("Baudrate:", 10, 150)    ;Creates the label for the Baudrate
GUICtrlCreateCombo("", 275, 75)   ;Creates the drop down box
GUICtrlSetData(16, "1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50", $NumericPort)   ;Puts data into drop down box
GUICtrlCreateCombo("", 275, 150)   ;Creates drop down box
GUICtrlSetData(17, "2400|4800|9600|19200|38400|57600|115200|31250", $BaudRate)  ;Puts data into drop down box

GUICtrlCreateTabItem("Accesories")   ;keyboard, mouse, touchscreen options
GUICtrlCreateLabel("Accesories settings", 10, 25)   ;Creates label for accesories settings
GUICtrlCreateLabel("Block options:", 10, 75) ;Creates the label for the block options
GUICtrlCreateCombo("", 275, 75) ;Creates the dorp down box
GUICtrlSetData(21, "None|Both|Mouse/Touchscreen|Keyboard", $AlphaBlock[$BlockOption]) ;Puts data into drop down box 

GUICtrlCreateTabItem("Run Plates") ;Run plate option tab
GUICtrlCreateLabel("Ability to run plates", 10, 25)  ;creates label for plate running config
GUICtrlCreateLabel("Run Plates", 10, 75) ;creates the label for plate running setting
GUICtrlCreateCombo("", 275, 75) ;creates drop down box
GUICtrlSetData(25, "Yes|No", $RunPlates) ;puts data into drop down box

GUICtrlCreateTabItem("Windows Priority") ;windows priority tab
GUICtrlCreateLabel("Select Windows Priority", 10, 25) ;creates label for windows priority config
GUICtrlCreateLabel("Priority 1:", 10, 40)  ;creates label for windows priority 1
GUICtrlCreateLabel("Maximize:", 100, 40)    ;creates label for maximize window
GUICtrlCreateLabel("Priority 2:", 10, 80)   ;creates label for windows priority 2
GUICtrlCreateLabel("Maximize:", 100, 80)  ;creates label for maximize window
GUICtrlCreateLabel("Priority 3:", 10, 120)   ;creates label for windows priority 3
GUICtrlCreateLabel("Maximize:", 100, 120)   ;creates label for maximize window
GUICtrlCreateLabel("Priority 4:", 10, 160)   ;creates label for windows priority 4
GUICtrlCreateLabel("Maximize:", 100, 160)   ;creates label for maximize window
GUICtrlCreateLabel("Priority 5:", 10, 200)   ;creates label for windows priority 5
GUICtrlCreateLabel("Maximize:", 100, 200)   ;creates label for maximize window
GUICtrlCreateLabel("Priority 6:", 200, 40)   ;creates label for windows priority 6
GUICtrlCreateLabel("Maximize:", 300, 40)   ;creates label for maximize window
GUICtrlCreateLabel("Priority 7:", 200, 80)   ;creates label for windows priority 7
GUICtrlCreateLabel("Maximize:", 300, 80)    ;creates label for maximize window
GUICtrlCreateLabel("Priority 8:", 200, 120)  ;creates label for windows priority 8
GUICtrlCreateLabel("Maximize:", 300, 120)    ;creates label for maximize window
GUICtrlCreateLabel("Priority 9:", 200, 160)  ;creates label for windows priority 9
GUICtrlCreateLabel("Maximize:", 300, 160)   ;creates label for maximize window
GUICtrlCreateLabel("Priority 10:", 200, 200)   ;creates label for windows priority 10
GUICtrlCreateLabel("Maximize:", 300, 200)   ;creates label for maximize window
GUICtrlCreateCombo("", 100, 55)      ;Drop down box for maximize selection
GUICtrlSetData(48, "Yes|No", $IniMaximize[1])  ;puts data into drop down box for maximize selection
GUICtrlCreateCombo("", 100, 95)   ;Drop down box for maximize selection
GUICtrlSetData(49, "Yes|No", $IniMaximize[2])  ;puts data into drop down box for maximize selection
GUICtrlCreateCombo("", 100, 135)    ;Drop down box for maximize selection
GUICtrlSetData(50, "Yes|No", $IniMaximize[3])   ;puts data into drop down box for maximize selection
GUICtrlCreateCombo("", 100, 175)      ;Drop down box for maximize selection
GUICtrlSetData(51, "Yes|No", $IniMaximize[4])    ;puts data into drop down box for maximize selection
GUICtrlCreateCombo("", 100, 215)    ;Drop down box for maximize selection
GUICtrlSetData(52, "Yes|No", $IniMaximize[5])    ;puts data into drop down box for maximize selection
GUICtrlCreateCombo("", 300, 55)    ;Drop down box for maximize selection
GUICtrlSetData(53, "Yes|No", $IniMaximize[6])  ;puts data into drop down box for maximize selection
GUICtrlCreateCombo("", 300, 95)   ;Drop down box for maximize selection
GUICtrlSetData(54, "Yes|No", $IniMaximize[7])     ;puts data into drop down box for maximize selection
GUICtrlCreateCombo("", 300, 135)   ;Drop down box for maximize selection
GUICtrlSetData(55, "Yes|No", $IniMaximize[8])   ;puts data into drop down box for maximize selection
GUICtrlCreateCombo("", 300, 175)   ;Drop down box for maximize selection
GUICtrlSetData(56, "Yes|No", $IniMaximize[9])   ;puts data into drop down box for maximize selection
GUICtrlCreateCombo("", 300, 215)    ;Drop down box for maximize selection
GUICtrlSetData(57, "Yes|No", $IniMaximize[10])   ;puts data into drop down box for maximize selection
$PRT1 = GUICtrlCreateCombo("", 10, 55)    ;Drop down box for priority input
GUICtrlSetData(58, "Spillman Mobile|None|Example1|Example2", $IniPriority[1])  ;puts data into drop down box for priority input/selection
$PRT2 = GUICtrlCreateCombo("", 10, 95)    ;Drop down box for priority input
GUICtrlSetData(59, "Spillman Mobile|None|Example1|Example2", $IniPriority[2])  ;puts data into drop down box for priority input/selection
$PRT3 = GUICtrlCreateCombo("", 10, 135)    ;Drop down box for priority input
GUICtrlSetData(60, "Spillman Mobile|None|Example1|Example2", $IniPriority[3])  ;puts data into drop down box for priority input/selection
$PRT4 = GUICtrlCreateCombo("", 10, 175)    ;Drop down box for priority input
GUICtrlSetData(61, "Spillman Mobile|None|Example1|Example2", $IniPriority[4])  ;puts data into drop down box for priority input/selection
$PRT5 = GUICtrlCreateCombo("", 10, 215)    ;Drop down box for priority input
GUICtrlSetData(62, "Spillman Mobile|None|Example1|Example2", $IniPriority[5])  ;puts data into drop down box for priority input/selection
$PRT6 = GUICtrlCreateCombo("", 200, 55)    ;Drop down box for priority input
GUICtrlSetData(63, "Spillman Mobile|None|Example1|Example2", $IniPriority[6])  ;puts data into drop down box for priority input/selection
$PRT7 = GUICtrlCreateCombo("", 200, 95)    ;Drop down box for priority input
GUICtrlSetData(64, "Spillman Mobile|None|Example1|Example2", $IniPriority[7])  ;puts data into drop down box for priority input/selection
$PRT8 = GUICtrlCreateCombo("", 200, 135)    ;Drop down box for priority input
GUICtrlSetData(65, "Spillman Mobile|None|Example1|Example2", $IniPriority[8])  ;puts data into drop down box for priority input/selection
$PRT9 = GUICtrlCreateCombo("", 200, 175)    ;Drop down box for priority input
GUICtrlSetData(66, "Spillman Mobile|None|Example1|Example2", $IniPriority[9])  ;puts data into drop down box for priority input/selection
$PRT10 = GUICtrlCreateCombo("", 200, 215)    ;Drop down box for priority input
GUICtrlSetData(67, "Spillman Mobile|None|Example1|Example2", $IniPriority[10])  ;puts data into drop down box for priority input/selection
GUISetState(@SW_SHOW)    ;Shows the GUI window
;MsgBox(2, "Checker", $PRT1)   ;Checks the ControlID
;MsgBox(2, "error detection", $DataSelect)   ;error detection(combo 4)

;Makes cancel button and the close button(top right x) close the program
While -1
   $msg = GUIGetMsg()
   Select
   Case $msg = $ButtonCancel Or $msg = $GUI_EVENT_CLOSE
   Case $ButtonSave 
 IniWrite("Archangel.ini", "Show the speed", $ShowSpeed, 10)

   ExitLoop
   EndSelect
WEnd

Share this post


Link to post
Share on other sites

It exits because you put an ExitLoop in there after the first IniWrite statement, after it leaves the While loop, there's nothing left for it to do so it closes.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Fixed:

While -1
$msg = GUIGetMsg()
Select
Case $msg = $ButtonCancel Or $msg = $GUI_EVENT_CLOSE
Quit()
Case $ButtonSave
$result = IniWrite("Archangel.ini", "ProgramOptions", "ShowSpeed", $ShowSpeed)
ConsoleWrite($result & $ShowSpeed & @CR)
EndSelect
WEnd

Func Quit()
Exit
EndFunc

It still does not save yes to the $ShowSpeed variable

Edited by JonBMN

Share this post


Link to post
Share on other sites

Is $ShowSpeed a variable that holds a control ID for a control of some sort? If so, use GUICtrlRead($ShowSpeed) instead.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Thank you BrewMan

EDIT: $ShowSpeed was the variable that holds the default selection from the .ini

Edited by JonBMN

Share this post


Link to post
Share on other sites

Using the GUICtrlRead function instead of putting in the $ShowSpeed variable, which did not particularly work, I put in the handle for the drop down box selection GUICtrlRead(10); which succesfully worked.

Edited by JonBMN

Share this post


Link to post
Share on other sites

Never EVER use hard coded numbers in place of controlIDs or handles. Assign the control IDs and handles to a variable when you create the controls in your script, and always use the variable in the rest of the script. All it takes is for you to add or remove a control and the whole script starts acting weird, with no indication of why it's acting the way it is.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Can you show me an example of the single variable holding all the controlIDs? I don't know if you meant variables or really did mean variable

Share this post


Link to post
Share on other sites

Obviously I didn't mean assign them all to the same variable, that would be silly. You create either a separate variable for each control you're going to need to interact with later, or create one array that holds all the control IDs.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

I'm having trouble getting the $Index to hold the 1-10 numbers so that I don't have to write all the windows priorities out and instead use a loop to plugin 1, 2, 3, etc.. If more of my code needs to be posted let me know, but thanks for the help everyone.

Figured it out; heres the code for it.

;creates the while loop for the cancel button and the save button/saves configuration settings as well
While -1
   $msg = GUIGetMsg()
   Select
   Case $msg = $ButtonCancel Or $msg = $GUI_EVENT_CLOSE
 Quit()
   Case $ButtonSave 
 IniWrite("Archangel.ini", "ProgramOptions", "ShowSpeed", GUICtrlRead($Speed1))
 IniWrite("Archangel.ini", "ProgramOptions", "SpeedLimit", GUICtrlRead($Speed2))
 IniWrite("Archangel.ini", "Communication", "Port", GUICtrlRead($Commun1))
 IniWrite("Archangel.ini", "Communication", "Baudrate", GUICtrlRead($Commun2))
 IniWrite("Archangel.ini", "ProgramOptions", "Block", GUICtrlRead($Block1))
 IniWrite("Archangel.ini", "ProgramOptions", "RunPlates", GUICtrlRead($RunP1))
      ;creates a for loop to plugin 1-10 using index for the windows priorities and maximize boxes
 For $Index = 1 to 10
        IniWrite("Archangel.ini", "WindowPriorties", "WindowPriority" & $Index, GUICtrlRead($PRI[$Index]))
   IniWrite("Archangel.ini", "WindowPriorties", "WindowMaximize"  & $Index, GUICtrlRead($MAX[$Index]))
      Next
;ConsoleWrite($result & $ShowSpeed & @CR)    ;error detector
   EndSelect
WEnd
Edited by JonBMN

Share this post


Link to post
Share on other sites

I have another question. Lets say that one of my windows priorities is "Example1" and I want to enter Example2 into the program; instead of the code; how if I'm using GUICtrlCreateCombo and GUISetData would I be able to do this?

EDIT: There is no way to do what I wanted to do with GUICtrlCreateCombo; I had to change all of them to GUICtrlCreateInput like so:

$PRI[1] = GUICtrlCreateInput("", 10, 55, 100) ;creates input control
GUICtrlSetData($PRI[1], $IniPriority[1], $IniPriority[1]) ;puts data into input control for priority input
Edited by JonBMN

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By DirtyJohny
      Hi everyone.Need rewrite this function how in еxample.
      Original:
      #RequireAdmin #NoTrayIcon Opt("MustDeclareVars",1) Func _a() Local $sls=ObjGet("winmgmts:{impersonationLevel=impersonate," _ &"authenticationLevel=Pkt}!\\"& _ @ComputerName&'\root\wmi'),$lss=$sls.ExecQuery _ ('SELECT * FROM WmiMonitorID'), _ $lll,$sll,$sss="",$lsl,$lls,$i,$z For $z In $lss $lsl=$z.UserFriendlyName For $i=0 To Ubound($lsl)-1 if ($lsl[$i]) Then $lll&=Chr($lsl[$i]) Next $lls=$z.SerialNumberID For $i=0 To Ubound($lls)-1 if ($lls[$i]) Then $sll&=Chr($lls[$i]) Next $sss&="Model"&@TAB&@TAB&": "&$lll&@CR&"Serial Number"&@TAB&": "&$sll&@CR&@CR $lll="" $sll="" Next MsgBox(262144,'Monitors '&$lss.Count,$sss&" "&@CR) $lss=Null $sls=Null EndFunc _a() Example:
      Func _InfoPC() Local $ObjService = ObjGet('winmgmts:{impersonationLevel = impersonate}!\\' & @ComputerName & '\root\cimv2') Local $ObjMB = $ObjService.ExecQuery('SELECT * FROM Win32_BaseBoard', 'WQL', 0x30) If IsObj($ObjService) Then For $objItemMB In $ObjMB $sInfo &= @TAB & 'Motherboard: ...... ' & $objItemMB.Product & @CRLF I'm beginner in this sphere and need  you all speak easy and simply because i'm Russian.Thanks)
    • By Deshanur
      Am trying to automate injecting credential on the login form for all kind of Web application for IE. I know how to identify the form name by viewing the source code and using the method - _IEFormGetObjByName($ie, $form_Name).
      I would like to know how to identify or get the form object for the web app where there is no form name tag for example below, for the is I have used - _IEFormGetCollection($ie, 0) to get the form object.
      My Question is does it work for all kind of application "_IEFormGetCollection($ie, 0)" how to identify Index value? is it always 0? is there any better solution?
      The final solution am looking for is find out form object, get the username, password field and inject credential and submit the form.
      How to find out index value? for the forms which does not have form name field.
      $login_form = _IEFormGetCollection($ie, 0) $email_field = _IEFormElementGetObjByName($login_form, $form_UserName) $pass_field = _IEFormElementGetObjByName($login_form, $form_password) $login_button = _IEFormElementGetObjByName($login_form, $form_submitbutton) _IEFormElementSetValue($email_field, $CmdLine[2]) _IEFormElementSetValue($pass_field, $CmdLine[3]) ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]","{Enter}") OR This works fine if the form has form name. $login_form = _IEFormGetObjByName($ie, $form_Name) $email_field = _IEFormElementGetObjByName($login_form, $form_UserName) $pass_field = _IEFormElementGetObjByName($login_form, $form_password) $login_button = _IEFormElementGetObjByName($login_form, $form_submitbutton) _IEFormElementSetValue($email_field, $CmdLine[2]) _IEFormElementSetValue($pass_field, $CmdLine[3]) ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]","{Enter}")
    • By JuanFelipe
      Hello guys!
      I have a problem with a script, in the past I made a program and it worked perfect, I recently used it again and it already stands still in one step, the problem is a Javascript event that changed but now I cannot execute it.
       
      <td colspan="2" align="center"><input type="button" id="Buscar" name="Buscar" value="Buscar" onclick="javascript:enviarForma(document.obtenercasosPersonaPorDocumento,'0');" class="boton"></td>  
      Previously I used this code and it worked, but now it does nothing
      $botonconsulta = _IEGetObjByName($oIE,"Buscar") _IEAction($botonconsulta, 'click') _IELoadWait($oIE)  
      Now I have tried the following codes but none works.
       
      ;==================== 1 _IEHeadInsertEventScript($oIE, "document", "onclick", "javascript:enviarForma(document.obtenercasosPersonaPorDocumento,'0');") ControlClick("SUPER CELAC", "", "[CLASS:Internet Explorer_Server; INSTANCE:1]") _IELoadWait($oIE) ;==================== 2 $forma = $oIE.document.obtenercasosPersonaPorDocumento $oIE.Navigate("JavaScript:enviarForma("&$forma&",""0"");") _IELoadWait($oIE) ;==================== 3 $boton = _IEGetObjById($oIE, "Buscar") $boton.document.parentwindow.execScript("enviarForma(document.obtenercasosPersonaPorDocumento,'0');", "javascript") I hope you can guide me, because I think the error is in the parameters that the javascript function receives but I don't know how to send it, here I leave the first part of the JavaScript function.
      function enviarForma(frm,tipoForma){ var bExisteDatoConsulta = false; var bError=true; var mensajeError=""; switch (tipoForma) { //--Forma documento case "0": if (validar_campo_no_vacio_no_print(frm.numeroDocumento)) { if (!isNum(frm.numeroDocumento.value)) { bError = false; mensajeError += "El número de documento debe ser un valor numérico\n"; } bExisteDatoConsulta = true; } else { mensajeError += "Debe digitar un número de documento\n"; } break;  Thanks!
    • By paw
      I use SetSoundDevice to control my audio devices but the UI was either
       
      blurry like this:
      or unusable like this:

      so I made this horrible thing to add scaling to the GUI:
      #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Change2CUI=y #AutoIt3Wrapper_Res_HiDpi=y #AutoIt3Wrapper_AU3Check_Parameters=-w 3 -w 4 -w 5 #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/sf /sv /rm #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <File.au3> ;~ _convertGUI("") If $CmdLine[0] <> 0 Then _convertGUI($CmdLine[1]) Func _convertGUI($sFilePath) If $sFilePath <> "" Then Local $aArray = FileReadToArray($sFilePath) Else ;TEST DATA Local $aArray[6] = ['$H_Res_Language = GUICtrlCreateProgress(5, 120, 210 + 25, 480, 20, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE)) ; $CBS_DROPDOWNLIST)', _ 'Local $h_Ok = GUICtrlCreateButton("Ok", 72, 224, 81, 33, 0)', _ 'GUICreate($Warning_TiTle, 700, 310, -1, -1, $WS_SIZEBOX + $WS_SYSMENU + $WS_MINIMIZEBOX)', _ 'GUICtrlCreateLabel("Output type: ", 30, 130, 65, 20) ;, $SS_RIGHT)', _ '$H_FieldNameEdit = GUICtrlCreateEdit($INP_FieldNameEdit, 100,260+25, 500, 150 - 25) ;comment', 'Local $H_CANCEL = GUICtrlCreateGraphic("Cancel", 224, 224, 97, 33, 0)'] EndIf Local $hTimer = TimerInit(), $iGUIElementCount = 0, $sResult = "", $sFileName = "", $sDrive = "", $sDir = "", $sExtension = "" If @Compiled Then _PathSplit($sFilePath, $sDrive, $sDir, $sFileName, $sExtension) $sFileName = StringRegExpReplace($sFilePath, "^.*\\", "") EndIf For $i = 0 To (UBound($aArray) - 1) If StringRegExp($aArray[$i], "GUICtrlCreate|GUICreate") Then $sResult = _splitComma($aArray[$i]) If Not @error Then $aArray[$i] = $sResult $iGUIElementCount += 1 EndIf Next ConsoleWrite("t = " & TimerDiff($hTimer) & " GUI elements = " & $iGUIElementCount & " lines = " & (UBound($aArray) - 1) & @CRLF) If $sFileName <> "" Then Local $hFile = FileOpen("edited." & $sFileName, 2) _FileWriteFromArray("edited." & $sFileName, $aArray) FileClose($hFile) EndIf Exit EndFunc ;==>_convertGUI Func _splitComma($sString) Local $sSplitResult = "", $sTrimmedR = "", $sTrimmedL = "" Local $aSplit = StringSplit($sString, ',') If Not @error Then $sTrimmedR = "" $sTrimmedL = "" For $j = 1 To $aSplit[0] If StringRegExp($aSplit[1], "(?:.GUICtrlCreateGraphic|GUICtrlCreateProgress|GUICtrlCreateSlider|GUICtrlCreateTab|GUICtrlCreateTreeView)") Then If $j = 1 Then While StringLeft($aSplit[$j], 1) <> '(' $sTrimmedL &= StringLeft($aSplit[$j], 1) $aSplit[$j] = StringTrimLeft($aSplit[$j], 1) WEnd $aSplit[$j] = StringTrimLeft($aSplit[$j], 1) EndIf EndIf If $j = $aSplit[0] Then While StringRight($aSplit[$j], 1) <> ')' $sTrimmedR &= StringRight($aSplit[$j], 1) $aSplit[$j] = StringTrimRight($aSplit[$j], 1) WEnd $aSplit[$j] = StringTrimRight($aSplit[$j], 1) EndIf If StringRegExp($aSplit[$j], "[0-9]") And $aSplit[$j] <> -1 And $aSplit[$j] <> 0 And $aSplit[$j] <> 1 And Not StringInStr($aSplit[$j], ')') Then If StringRegExp($aSplit[$j], "\-|\+") Then ;put parenthesis around + or - $aSplit[$j] = '(' & $aSplit[$j] & ")*$g_DPI" Else $aSplit[$j] = $aSplit[$j] & "*$g_DPI" EndIf EndIf If $j < $aSplit[0] Then $sSplitResult &= $aSplit[$j] & ',' ElseIf $j = $aSplit[0] Then $sSplitResult &= $aSplit[$j] & ')' Else $sSplitResult &= $aSplit[$j] EndIf Next If $sTrimmedR <> "" Then $sSplitResult &= StringReverse($sTrimmedR) If $sTrimmedL <> "" Then $sSplitResult = $sTrimmedL & '(' & $sSplitResult Else SetError(1) Return EndIf ConsoleWrite($sSplitResult & @CRLF) Return $sSplitResult EndFunc ;==>_splitComma
      And now it looks good: 
      but it doesn't work on everything, for example the "GUICtrlCreateLabel("Output type: ", 30, 130, 65, 20) ;, $SS_RIGHT)" (from the autoit3wrapper gui)
      because the comment contains a parenthesis and it would break completely if there were variables as parameters..
      Is there some kind of parser around that I could use instead or maybe someone who has already done something like this?
    • By Gowrisankar
      Dear members of the forum,
      I'm working on a project in which I have to use Image recognition technique. 
      Due to client restrictions, I couldn't use AutoIt for this project. 
      Is there a way to use this DLL "ImageSearchDLL.dll" (which is used to do image recognition steps in AutoIt) in VB.Net to achieve the same result? 
      I have used this DLL few years before and got good results. If there is a latest version of this DLL and if you can share it, that will be helpful too.
      Any guidance is deeply appreciated.
×
×
  • Create New...