Sign in to follow this  
Followers 0
SmOke_N

The more I think I got something!##!

4 posts in this topic

No long explinations, I was making a number generator: That works.

As crude as it may be---

#include <GUIConstants.au3>

$parent1 = GUICreate("Number Generator", 190, 70, 400, 300)
;Generate random numbers for product id
$RanProID = Random(1500,999999,1)
GUICtrlCreateLabel("Random Number:", 10,10,120,20)
$ProductID = GUICtrlCreateLabel($RanProID, 110, 10, 55,20)
GUICtrlSetData(1,"")
EnvSet("blah", GUICtrlRead($ProductID))
$info = EnvGet("blah")
$result = _result($info,500, 200, 10, 260, 80, 100)
$submit_button = GUICtrlCreateButton("Calculate", 10, 30,80,30)
$cancel_button = GUICtrlCreateButton("Cancel", 100, 30,80,30)

GUISetState(@SW_SHOW)
While 1
   $msg = GUIGetMsg()
   Select
      Case $msg = $GUI_EVENT_CLOSE Or $msg = $cancel_button
         ExitLoop
     Case $msg = $submit_button
             MsgBox(4096, "Result", $result)
   EndSelect
WEnd

Func _result($info, $multiple,$divisor, $multiple2, $multiple3,$divisor2, $multiple4)
    Return $info * $multiple / $divisor * $multiple2 * $multiple3 / $divisor2 * $multiple4
EndFunc

This was quick and to the point:

So then I thought I'd make a keygenerator for the same concept

#include <GUIConstants.au3>
Global $ProductID, $rahrah, $info, $result, $submit_button, $cancel_button
$parent1 = GUICreate("KeyGen", 230, 100, 400, 300)
;Put in the random numbers from original product id
$ProductID = GUICtrlCreateInput("", 10, 10, 180,20,$ES_AUTOHSCROLL)
GUICtrlSetData(1,"")
$rahrah = EnvSet("blah", GUICtrlRead($ProductID))
$info = EnvGet("blah")
$result = _result($info,500, 200, 10, 260, 80, 100)
$submit_button = GUICtrlCreateButton("Submit", 10, 65,80,30)
$cancel_button = GUICtrlCreateButton("Cancel", 140, 65,80,30)
GUICtrlCreateLabel($info, 10,40,55,20)


GUISetState(@SW_SHOW)
While 1
   $msg = GUIGetMsg()
   Select
      Case $msg = $GUI_EVENT_CLOSE Or $msg = $cancel_button
         ExitLoop
     Case $msg = $submit_button
             MsgBox(4096, "Result", $result)
   EndSelect
WEnd

Func _result($ProductID, $multiple,$divisor, $multiple2, $multiple3,$divisor2, $multiple4)
    Return $ProductID * $multiple / $divisor * $multiple2 * $multiple3 / $divisor2 * $multiple4
EndFunc

Just tried to follow the same lines as the first: No matter how I try to GUICtrlRead the GUICtrlSetInput (or Edit tried that), the message box gives me "0", or "28375" or "8075", depending on what I put for. The above version is 1 of about 50 different combinations I tried.

The $ProductID I've found if left alone has a value of 3, with just("",setting,setting,setting,setting)

Blah, the more I "Get" it the more I get frustrated. :)

Ron


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>
Global $ProductID, $rahrah, $info, $result, $submit_button, $cancel_button
$parent1 = GUICreate("KeyGen", 230, 100, 400, 300)
;Put in the random numbers from original product id
$ProductID = GUICtrlCreateInput("", 10, 10, 180,20,$ES_AUTOHSCROLL)
GUICtrlSetData(1,"")
$rahrah = EnvSet("blah", GUICtrlRead($ProductID))
$info = EnvGet("blah")
$result = _result($info,500, 200, 10, 260, 80, 100)
$submit_button = GUICtrlCreateButton("Submit", 10, 65,80,30)
$cancel_button = GUICtrlCreateButton("Cancel", 140, 65,80,30)
GUICtrlCreateLabel($info, 10,40,55,20)
GUISetState(@SW_SHOW)
While 1
   $msg = GUIGetMsg()
   Select
      Case $msg = $GUI_EVENT_CLOSE Or $msg = $cancel_button
         ExitLoop
     Case $msg = $submit_button
             MsgBox(4096, "Result", $result)
   EndSelect
WEnd

Func _result($ProductID, $multiple,$divisor, $multiple2, $multiple3,$divisor2, $multiple4)
    Return $ProductID * $multiple / $divisor * $multiple2 * $multiple3 / $divisor2 * $multiple4
EndFunc

No matter how I try to GUICtrlRead the GUICtrlSetInput (or Edit tried that), the message box gives me "0", or "28375" or "8075", depending on what I put for. 

Blah, the more I "Get" it the more I get frustrated.  :)

Ron

<{POST_SNAPBACK}>

1. When data is entered into an input box, previously set variables are not automatically updated. As such, the current value must be obtained each time it is to be used.

2. I could not see a reason to set an environment variable, so I removed that bit of code. Also, according to the help file, EnvSet does not return anything, so there is no reason to set a variable to what it returns. That said, EnvSet actually does return a value, and that value is always 1 (therefore still useless).

Here's the working script:

#include <GUIConstants.au3>
Global $ProductID, $rahrah, $info, $result, $submit_button, $cancel_button
$parent1 = GUICreate("KeyGen", 230, 100, 400, 300)
$ProductID = GUICtrlCreateInput("", 10, 10, 180, 20, $ES_AUTOHSCROLL)
GUICtrlSetData(1, "")
$submit_button = GUICtrlCreateButton("Submit", 10, 65, 80, 30)
$cancel_button = GUICtrlCreateButton("Cancel", 140, 65, 80, 30)
GUICtrlCreateLabel($info, 10, 40, 55, 20)

GUISetState(@SW_SHOW)
While 1
   $msg = GUIGetMsg()
   Select
      Case $msg = $GUI_EVENT_CLOSE Or $msg = $cancel_button
         ExitLoop
      Case $msg = $submit_button
         $result = _result2(GUICtrlRead($ProductID), 500, 200, 10, 260, 80, 100)
         MsgBox(4096, "Result", $result)
   EndSelect
WEnd

Func _result2($ProductID, $multiple, $divisor, $multiple2, $multiple3, $divisor2, $multiple4)
   Return $ProductID * $multiple / $divisor * $multiple2 * $multiple3 / $divisor2 * $multiple4
EndFunc  ;==>_result

Phillip

Share this post


Link to post
Share on other sites

Hey, thanks Phillip. You know I wish the help file was in PDF so i could just print it. Think I'll do that myself sometime today or tomorrow.

Ron


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Hey, thanks Phillip.  You know I wish the help file was in PDF so i could just print it.  Think I'll do that myself sometime today or tomorrow.

Ron

<{POST_SNAPBACK}>

You're welcome.

Phillip

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  
Followers 0