Jump to content

reading value gives me 68 and after 0 in GUICtrlCreateInput


Daka
 Share

Recommended Posts

Global $l = GUICtrlCreateInput("3", 16, 48, 25, 22, $ES_NUMBER)
Global $p = GUICtrlCreateInput("3", 56, 48, 25, 22, $ES_NUMBER)
$go = GUICtrlCreateButton("Start", 136, 48, 83, 25)
Global $m = GUICtrlCreateInput("1", 96, 48, 25, 22, $ES_NUMBER)

Case $go
         $l = Number(GUICtrlRead($l))
         $p = Number(GUICtrlRead($p))
         $m = Number(GUICtrlRead($m))

Then I say consolewrite:

ConsoleWrite(" l: " & $l & " p: " & $p & " m: " & $m & @LF);

And first time when I hit Start ($go) button it gives me default numbers and works fine

l: 3 p: 3 m: 1

But then I hit Start again and no need to change the numbers in input it gives me:

l: 68 p: 68 m: 0

Then I hit again Start and this is result:

l: 0 p: 0 m: 0

from this moment it is all the time 0 (zero) so what could be this?

Link to comment
Share on other sites

You are mixing two things: The ID of a control returned by GUICtrlCreate* function and the value entered by the users as returned by GUICtrlRead.
Use separate variables for the ID and the value.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

24 minutes ago, water said:

...Use separate variables for the ID and the value.

For example

;https://www.autoitscript.com/wiki/Best_coding_practices#Names_of_Variables
Global $idL = GUICtrlCreateInput("3", 16, 48, 25, 22, $ES_NUMBER)
Global $idP = GUICtrlCreateInput("3", 56, 48, 25, 22, $ES_NUMBER)
$idGo = GUICtrlCreateButton("Start", 136, 48, 83, 25)
Global $idM = GUICtrlCreateInput("1", 96, 48, 25, 22, $ES_NUMBER)

Case $idGo
         $iL = Number(GUICtrlRead($idL))
         $iP = Number(GUICtrlRead($idP))
         $iM = Number(GUICtrlRead($idM))
         
         ConsoleWrite(" l: " & $iL & " p: " & $iP & " m: " & $iM & @LF);

 

Edited by spudw2k
Link to comment
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
 Share

×
×
  • Create New...